phpstan-wordpress: Cannot redeclare wp_set_password() when using roots/bedrock
It seems that there are few conflicts when using https://roots.io/bedrock/ with roots/wp-password-bcrypt which declares its own variants of some funtions:
- wp_set_password
- wp_generate_password
- wp_check_password
- wp_hash_password
Running vendor/bin/phpstan analyze throws:
$ vendor/bin/phpstan analyze
Note: Using configuration file /var/www/example.com/phpstan.neon.
Fatal error: Cannot redeclare wp_hash_password() (previously declared in /var/www/example.com/vendor/roots/wp-password-bcrypt/wp-password-bcrypt.php:52) in /var/www/example.com/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 105420
Steps to reproduce
# Install roots/bedrock
composer create-project roots/bedrock
cd bedrock
# Create some dummy plugin to test
mkdir -p web/app/plugins/test/
touch web/app/plugins/test/test.php
# Run phpstan
vendor/bin/phpstan analyze web/app/plugins/test/
[...]
Fatal error: Cannot redeclare wp_hash_password() (previously declared in /var/www/example.com/bedrock/vendor/roots/wp-password-bcrypt/wp-password-bcrypt.php:52) in /var/www/example.com/bedrock/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php on line 105420
Workaround
As bad as this is - I just comment out these four functions mentioned above from vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22 (12 by maintainers)
I also saw this on a project in the past and decided it was actually
roots/wp-password-bcryptthat was at fault for not wrapping its pluggable definition ofwp_set_password()in afunction_existscheck but then I forgot to do anything about it.@timnolte I gladly extend the Dirty corner section for you!! 😍
@mklepaczewski Done.
https://github.com/szepeviktor/phpstan-wordpress/commit/452e14714df8a584bd0ebf4c4e10da3936330455