Closed johnbillion closed 1 year ago
Perhaps related: https://github.com/wp-cli/wp-cli/issues/5795
Some more information: The project does not depend directly on wp-cli/wp-cli
, it depends on lucatume/wp-browser
for automated testing, and that package depends on wp-cli/wp-cli
.
Please use php-stubs/wp-cli-stubs
for static analysis.
@chesio not "perhaps related", but what prompted me to open that issue in the first place 😇
Temporary workaround is to set wp-cli/wp-cli
to ~2.7.x
locally, to stop other deps from leaking the higher version.
What a flash mob!!
Reading through the issue above, I think this is a problem in WP-CLI. It's trying to redeclare a \WpOrg\Requests
class after it's already defined by WordPress core (or in this case, by the stubs).
This has been fixed in WP-CLI 2.8.1
WP-CLI 2.8.0 was released yesterday. One of the larger changes was to upgrade to Requests v2, which means its autoloader now looks for and loads classes in the
\WpOrg\Requests
namespace.The
szepeviktor/phpstan-wordpress
package depends on thephp-stubs/wordpress-stubs
package and loads it when running PHPStan. Thephp-stubs/wordpress-stubs
package includes the\WpOrg\Requests
classes in its stubs.Running the PHPStan analysis on a project that depends on both
szepeviktor/phpstan-wordpress
andwp-cli/wp-cli
results in a redeclaration error. I've not dug into the details but it appears the stubs definitions load first, then something inside Requests still causes it to attempt to redeclare\WpOrg\Requests\Autoload
. I will try to find some time to look into why that's happening.