|
2 | 2 |
|
3 | 3 | [](https://travis-ci.com/github/php-stubs/generator)
|
4 | 4 |
|
5 |
| -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](https://getpsalm.org) or potentially other tools. Stub generation is particularly useful for code which mixes definitions with side-effects. |
| 5 | +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](https://phpstan.org) or potentially other tools. Stub generation is particularly useful for code which mixes definitions with side-effects. |
6 | 6 |
|
7 | 7 | The generator is based on nikic's [PHP-Parser](https://github.com/nikic/PHP-Parser), and the code also relies on several [Symfony](https://symfony.com) components.
|
8 | 8 |
|
9 |
| -Contributions in the form of issue reports or Pull Requests are welcome! |
| 9 | +Contributions in the form of [issues](https://github.com/php-stubs/generator/issues/new) or Pull Requests are welcome! |
10 | 10 |
|
11 | 11 | ## Example
|
12 | 12 |
|
@@ -69,40 +69,39 @@ namespace MyNamespace {
|
69 | 69 | }
|
70 | 70 | ```
|
71 | 71 |
|
72 |
| - |
73 | 72 | ## Command Line Usage
|
74 | 73 |
|
75 | 74 | To install:
|
76 | 75 |
|
77 |
| -``` |
| 76 | +```bash |
78 | 77 | composer global require php-stubs/generator
|
79 | 78 | ```
|
80 | 79 |
|
81 | 80 | To get the pretty-printed stubs for all the PHP files in a directory:
|
82 | 81 |
|
83 |
| -``` |
| 82 | +```bash |
84 | 83 | generate-stubs /path/to/my-library
|
85 | 84 | ```
|
86 | 85 |
|
87 | 86 | You may also pass multiple directories, or filenames, separated by spaces. All stubs will be concatenated in the output.
|
88 | 87 |
|
89 | 88 | To write the stubs to a file (and see a few statistics in the stdout):
|
90 | 89 |
|
91 |
| -``` |
| 90 | +```bash |
92 | 91 | generate-stubs /path/to/my-library --out=/path/to/output.php
|
93 | 92 | ```
|
94 | 93 |
|
95 | 94 | For the complete set of command line options:
|
96 | 95 |
|
97 |
| -``` |
| 96 | +```bash |
98 | 97 | generate-stubs --help
|
99 | 98 | ```
|
100 | 99 |
|
101 | 100 | ## Usage in PHP
|
102 | 101 |
|
103 | 102 | To install:
|
104 | 103 |
|
105 |
| -``` |
| 104 | +```bash |
106 | 105 | composer require php-stubs/generator
|
107 | 106 | ```
|
108 | 107 |
|
@@ -158,7 +157,3 @@ The set of symbol types are:
|
158 | 157 | - `StubsGenerator::CONSTANTS`: Constant declarations.
|
159 | 158 | - `StubsGenerator::DEFAULT`: Shortcut to include everything _except_ undocumented global variables.
|
160 | 159 | - `StubsGenerator::ALL`: Shortcut to include everything.
|
161 |
| - |
162 |
| -## TODO |
163 |
| - |
164 |
| -- Consider parsing function and method bodies for constant declarations. |
0 commit comments