Download the PHP package plutonium/stubs-generator without Composer
On this page you can find all versions of the php package plutonium/stubs-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download plutonium/stubs-generator
More information about plutonium/stubs-generator
Files in plutonium/stubs-generator
Package stubs-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 stubs-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 stubs-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