Closed lipemat closed 1 year ago
Hello @lipemat!
Stubs are as small as they can be. php-cli-tools is a small package and has a nice autoloader and has no dependencies. https://github.com/wp-cli/php-cli-tools/blob/d788a2c79e02f2f735fbb2b9a53db94d0e1bca4f/composer.json#L34-L41 Just require it with Composer.
WAIT! It is already included. https://github.com/search?q=repo%3Aphp-stubs%2Fwp-cli-stubs%20make_progress_bar&type=code
It is already included. https://github.com/search?q=repo%3Aphp-stubs%2Fwp-cli-stubs%20make_progress_bar&type=code
The make_progress_bar
function is included but the definitions for the returned Bar
are not.
Maybe the php-cli-utils stubs could be included as a separate file the way "commands-stubs" and "i18n-stubs" currently are. That would keep the main stubs lean without requiring a separate composer install.
Let me know if this a a viable option and I'll update the pull request. :-)
The
make_progress_bar
function is included but the definitions for the returnedBar
are not.
You are right.
@return \cli\progress\Bar|\WP_CLI\NoOp
Now I remember. I usually generate stubs from php-cli-tools https://github.com/szepeviktor/phpstan-wordpress/blob/master/stub-generators/php-cli-tools-generate-stubs.sh and include that file in my project's tests directory.
I am sorry. This was never requested and publishing a separate stubs package is something I cannot maintain.
Adding php-cli-tools to wp-cli-stubs makes it 48924 bytes bigger.
@lipemat I promise you I will add it by the third request!
In case anyone else is looking for this, I used the generate-stubs.sh
script mentioned above to run off a stub and have included it here.
https://github.com/lipemat/phpstan-wordpress/blob/master/stubs/wp-cli/php-cli-tools-0.11.11.php
I agree with the others here that it would make sense to include it in this package.
Maybe the php-cli-utils stubs could be included as a separate file the way "commands-stubs" and "i18n-stubs" currently are.
@lipemat All right. I merge a PR for a separate stubs file. The request from @srtfisher changed my mind.
@lipemat All right. I merge a PR for a separate stubs file. The request from @srtfisher changed my mind.
Great! I'll put together a pull request which generates the stubs separately.
The
WP_CLI
namespaces contains a number of utilities which are stored in thewp-cli/php-cli-tools
package.For example the Progress Bar. (taken from the docs)
Without the 'php-cli-tools' being included, using these utilities will always fail PHPStan scans.
This change includes the 'php-cli-tools' in the finder and definition file for wp-cli-stubs.php