Download the PHP package permafrost-dev/php-code-search without Composer
On this page you can find all versions of the php package permafrost-dev/php-code-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download permafrost-dev/php-code-search
More information about permafrost-dev/php-code-search
Files in permafrost-dev/php-code-search
Package php-code-search
Short Description Search PHP code for function & method calls, variable assignments, and more
License MIT
Homepage https://github.com/permafrost-dev/php-code-search
Informations about the package php-code-search
Searching PHP source code made easy
Search PHP source code for function & method calls, variable assignments, classes and more directly from PHP.
Installation
Searching
To search a file, use the search
method. Its only parameter may be either a string containing a valid filename or an instance of \Permafrost\PhpCodeSearch\Support\File
.
To search a string instead, use the searchCode
method.
The search methods return an instance of Permafrost\PhpCodeSearch\Results\FileSearchResults
, which has a results
property.
Each result
is an instance of Permafrost\PhpCodeSearch\Results\SearchResult
with the following properties:
node
- the specific item that was foundnode->name(): string
location
- the location in the file that the item was foundlocation->startLine(): int
location->endLine(): int
snippet
- a snippet of code lines from the file with the result line in the middlesnippet->toString(): string
file()
(method) - provides access to the file that was searched
Searching
To search through the code in a string or file, use the Searcher
class:
To search a file, use the search
method, and the searchCode
method to search a string of code.
When searching using any of the available methods, regular expressions can be used by surrounding the name with slashes /
, i.e. /test\d+/
.
Variable names
To search for variables by name, use the variables
method.
Functions
To search for function calls or definitions, use the functions
method.
Method calls
To search for a method call by name, use the methods
method.
Method call nodes have an args
property that can be looped through to retrieve the arguments for the method call.
Static calls
To search for static method or property calls, use the static
method.
Valid search terms are either a class name like Cache
, or a class name and a method name like Cache::remember
.
Classes
To search for either a class definition or a class created by the new
keyword, use the classes
method.
Variable assignments
To search for a variable assignment by variable name, use the assignments
method. Note: The $
should be omitted.
Results without code snippets
To return search results without associated code snippets, use the withoutSnippets
method:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Patrick Organ
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of php-code-search with dependencies
nikic/php-parser Version ^5.0
permafrost-dev/code-snippets Version ^1.2.0