Download the PHP package giacocorsiglia/stubs-generator without Composer
On this page you can find all versions of the php package giacocorsiglia/stubs-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download giacocorsiglia/stubs-generator
More information about giacocorsiglia/stubs-generator
Files in giacocorsiglia/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/GiacoCorsiglia/php-stubs-generator
Informations about the package stubs-generator
‼️ This project is not maintained ‼️
You should use the fork at php-stubs/generator, which is thanks to @szepeviktor.
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 Psalm 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 issue reports 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::DEFAULT
: Shortcut to include everything except undocumented global variables.StubsGenerator::ALL
: Shortcut to include everything.
TODO
- Add support for constants declared with
const
. - Add support for constants declared with
define()
.- Consider parsing function and method bodies for these declarations.
All versions of stubs-generator with dependencies
symfony/console Version ^4.0
nikic/php-parser Version ^3.1
symfony/finder Version ^4.0
symfony/filesystem Version ^4.0