Download the PHP package php-stubs/generator without Composer
On this page you can find all versions of the php package php-stubs/generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download php-stubs/generator
More information about php-stubs/generator
Files in php-stubs/generator
Package generator
Short Description Generate stubs from any PHP code for IDE completion and static analysis.
License MIT
Homepage https://github.com/php-stubs/generator
Informations about the package generator
PHP Stubs Generator
Use this tool to generate stub declarations for functions, classes, interfaces, and global variables defined in any PHP code. The stubs can subsequently be used to facilitate IDE completion or static analysis via PHPStan or potentially other tools. Stub generation is particularly useful for code which mixes definitions with side-effects.
The generator is based on nikic's PHP-Parser, and the code also relies on several Symfony components.
Contributions in the form of issues or Pull Requests are welcome!
Example
The idea is to turn this:
Into this:
Command Line Usage
To install:
To get the pretty-printed stubs for all the PHP files in a directory:
You may also pass multiple directories, or filenames, separated by spaces. All stubs will be concatenated in the output.
To write the stubs to a file (and see a few statistics in the stdout):
For the complete set of command line options:
Usage in PHP
To install:
Simple Example
Additional Features
You can restrict the set of symbol types for which stubs are generated:
The set of symbol types are:
StubsGenerator::FUNCTIONS
: Function declarations.StubsGenerator::CLASSES
: Class declarations.StubsGenerator::TRAITS
: Trait declarations.StubsGenerator::INTERFACES
: Interface declarations.StubsGenerator::DOCUMENTED_GLOBALS
: Global variables, but only those with a doc comment.StubsGenerator::UNDOCUMENTED_GLOBALS
: Global variable, but only those without a doc comment.StubsGenerator::GLOBALS
: Shortcut to include both documented and undocumented global variables.StubsGenerator::CONSTANTS
: Constant declarations.StubsGenerator::DEFAULT
: Shortcut to include everything except undocumented global variables.StubsGenerator::ALL
: Shortcut to include everything.
All versions of generator with dependencies
nikic/php-parser Version ^4.10
symfony/console Version ^5.1 || ^6.0
symfony/filesystem Version ^5.0 || ^6.0
symfony/finder Version ^5.0 || ^6.0