phpinspect currently does not need to fully parse every single file in a project to be fully functional. In stead, an indexation script is used to find specific strings of text in php files within a directory that indicate the definition of a namespace/class/interface. This process is very fast because the definition of a class usually starts near the top of a file, meaning that only a few lines of each file need to be examined to know what classes/interfaces are defined within it.
A problem with this implementation is that it requires the user to have a bash shell and gnu coreutils installed to work, and that the indexation script is a pretty gnarly/hard to read piece of code that was carried over from another project. A more readable, pure elisp implementation without external dependencies would be preferrable.
Alternatives to Explore
An Elisp Implementation of PHP Autoloading standards
The way in which phpinspect parses files on demand is comparable to the way in which PHP software usually loads files on demand using autoloading. The main package manager for PHP, composer, currently supports 4 different types of autoloading: psr-4, psr-0, classmap and files.
PSR-4 and PSR-0 are standards that dictate how the file structure of a project should be layed out in order for the autoloader to be able to find the file a type/function was defined in. It should be possible, and not terribly difficult, to implement these standards in elisp autoloaders to be able to find files.
The classmap option that composer provides entails defining a file that contains a PHP array defining the files in which types/functions can be found. This array could be parsed into a lisp datastructure using phpinspect's parser and then used in an elisp autoloader implementation.
The files option that composer provides simply allows the definition of a PHP file that should be included regardless of the types/functions used in the php code. This file could simply be parsed and added to the project cache without needing to implement a detailed autoloader.
Benefits of this solution
Standardized
(Seems) straight-forward to implement
Supports most modern PHP projects
Downsides of this solution
Only works for autoloaded (composer) projects
Utilizing etags for indexation
Etags is a program for the indexation of source code that is distributed with emacs.
Benefits of this solution
Common way of indexing source code for traditional emacs users
Supported by emacs maintainers
Downsides of this solution
Little documentation available for reliable use of etags in PHP projects.
Still requires indexation of all files in a project, unsure whether or not etags can be configured to only index files partially.
phpinspect currently does not need to fully parse every single file in a project to be fully functional. In stead, an indexation script is used to find specific strings of text in php files within a directory that indicate the definition of a namespace/class/interface. This process is very fast because the definition of a class usually starts near the top of a file, meaning that only a few lines of each file need to be examined to know what classes/interfaces are defined within it.
A problem with this implementation is that it requires the user to have a bash shell and gnu coreutils installed to work, and that the indexation script is a pretty gnarly/hard to read piece of code that was carried over from another project. A more readable, pure elisp implementation without external dependencies would be preferrable.
## Alternatives to Explore
### An Elisp Implementation of PHP Autoloading standards
The way in which phpinspect parses files on demand is comparable to the way in which PHP software usually loads files on demand using autoloading. The main package manager for PHP, composer, currently supports 4 different types of autoloading: psr-4, psr-0, classmap and files.
PSR-4 and PSR-0 are standards that dictate how the file structure of a project should be layed out in order for the autoloader to be able to find the file a type/function was defined in. It should be possible, and not terribly difficult, to implement these standards in elisp autoloaders to be able to find files.
The classmap option that composer provides entails defining a file that contains a PHP array defining the files in which types/functions can be found. This array could be parsed into a lisp datastructure using phpinspect's parser and then used in an elisp autoloader implementation.
The files option that composer provides simply allows the definition of a PHP file that should be included regardless of the types/functions used in the php code. This file could simply be parsed and added to the project cache without needing to implement a detailed autoloader.
#### Benefits of this solution
- Standardized
- (Seems) straight-forward to implement
- Supports most modern PHP projects
#### Downsides of this solution
- Only works for autoloaded (composer) projects
### Utilizing etags for indexation
Etags is a program for the indexation of source code that is distributed with emacs.
#### Benefits of this solution
- Common way of indexing source code for traditional emacs users
- Supported by emacs maintainers
#### Downsides of this solution
- Little documentation available for reliable use of etags in PHP projects.
- Still requires indexation of all files in a project, unsure whether or not etags can be configured to only index files partially.
hugo
changed title from Implement indexation with ctags to Explore alternatives to the index script1 year ago
hugo
added this to the Ready for fieldtesting milestone 1 year ago
phpinspect currently does not need to fully parse every single file in a project to be fully functional. In stead, an indexation script is used to find specific strings of text in php files within a directory that indicate the definition of a namespace/class/interface. This process is very fast because the definition of a class usually starts near the top of a file, meaning that only a few lines of each file need to be examined to know what classes/interfaces are defined within it.
A problem with this implementation is that it requires the user to have a bash shell and gnu coreutils installed to work, and that the indexation script is a pretty gnarly/hard to read piece of code that was carried over from another project. A more readable, pure elisp implementation without external dependencies would be preferrable.
Alternatives to Explore
An Elisp Implementation of PHP Autoloading standards
The way in which phpinspect parses files on demand is comparable to the way in which PHP software usually loads files on demand using autoloading. The main package manager for PHP, composer, currently supports 4 different types of autoloading: psr-4, psr-0, classmap and files.
PSR-4 and PSR-0 are standards that dictate how the file structure of a project should be layed out in order for the autoloader to be able to find the file a type/function was defined in. It should be possible, and not terribly difficult, to implement these standards in elisp autoloaders to be able to find files.
The classmap option that composer provides entails defining a file that contains a PHP array defining the files in which types/functions can be found. This array could be parsed into a lisp datastructure using phpinspect's parser and then used in an elisp autoloader implementation.
The files option that composer provides simply allows the definition of a PHP file that should be included regardless of the types/functions used in the php code. This file could simply be parsed and added to the project cache without needing to implement a detailed autoloader.
Benefits of this solution
Downsides of this solution
Utilizing etags for indexation
Etags is a program for the indexation of source code that is distributed with emacs.
Benefits of this solution
Downsides of this solution
Implement indexation with ctagsto Explore alternatives to the index script 1 year agoElisp based autoloader has been implemented in master.