facebook / definition-finder
Find definitions in PHP or Hack files. Useful for autoloaders.
Installs: 40 133
Dependents: 7
Suggesters: 0
Security: 0
Stars: 10
Watchers: 17
Forks: 9
Open Issues: 0
Language:Hack
Requires
- hhvm: ^4.158
- hhvm/hhast: ^4.158
- hhvm/type-assert: ^3.2|^4.0
Requires (Dev)
- facebook/fbexpect: ^2.6.1
- hhvm/hacktest: ^2.0
- hhvm/hhvm-autoload: ^2.0|^3.0
- dev-main / 2.x-dev
- v2.16.0
- v2.15.0
- v2.14.2
- v2.14.1
- v2.14.0
- v2.13.5
- v2.13.4
- v2.13.3
- v2.13.2
- v2.13.1
- v2.13.0
- v2.12.6
- v2.12.5
- v2.12.4
- v2.12.3
- v2.12.2
- 2.12.1
- 2.12.0
- v2.11.1
- v2.11.0
- v2.10.0
- v2.9.0
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.x-dev
- v1.7.7
- v1.7.6
- v1.7.5
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.4
- v1.4.3
This package is auto-updated.
Last update: 2023-08-07 02:00:24 UTC
README
This library finds all the definitions in a file or tree that HHVM understands. It is used to generate the Hack reference documentation, and be used for other purposes such as generating autoload maps
This project requires HHVM 3.9 or later - however, if the code being scanned requires a later version of HHVM, definition-finder may not be able to parse it on the lower version.
Usage
There are three main entrypoints:
FileParser::FromFile(string $filename)
FileParser::FromData(string $data, ?string $filename = null)
TreeParser::FromPath(string $path)
FileParser
returns definitions from a single file, whereas TreeParser
recurses over an entire directory tree. All 3 of these functions return an implementation of BaseParser
. There are three forms of accessors:
getClasses(): vec<ScannedClass>
- returns avec
of [ScannedClass
](src/definitions/ScannedClass.php], which has a similar interface toReflectionClass
getClassNames(): vec<string>
- returns avec
of class namesgetClass(string $name): ScannedClass
- returns aScannedClass
for the specified class, or throws an exception if it was not found
Similar functions exist for interfaces, traits, constants, enums, and typedefs.
Installation
hhvm composer require facebook/definition-finder
Status
The API is stable, and this is used in production to generate the Hack reference documentation.
Implementation
This is a recursive parser built on the token stream exposed by token_get_all()
.
Contributing
We welcome GitHub issues and pull requests - please see CONTRIBUTING.md for details.
License
definition-finder is MIT-licensed.