Fix PHPStan warnings and deprecated notices#1733
Fix PHPStan warnings and deprecated notices#1733westonruter merged 5 commits intoWordPress:trunkfrom
Conversation
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
|
|
| - plugins/performance-lab/load.php | ||
| bootstrapFiles: | ||
| - tools/phpstan/constants.php | ||
| - plugins/performance-lab/load.php |
There was a problem hiding this comment.
It’s unclear to me why this file was included in the bootstrapFiles, considering PERFLAB_PLUGIN_DIR_PATH is already defined in tools/phpstan/constants.php:
performance/tools/phpstan/constants.php
Line 21 in 6f588ee
After removing the file, the warnings about the duplicate constant definition no longer appear.
There was a problem hiding this comment.
It was added by @westonruter in 5509f2c#diff-4b1024a6caff35a4396a209a68a5d634397320ff3b049b7c59e4937a78bd7d07R21 not sure why 🤔
There was a problem hiding this comment.
The constant PERFLAB_PLUGIN_DIR_PATH was likely added to tools/phpstan/constants.php to avoid this error:
------ -----------------------------------------------------------------------------
Line plugins/performance-lab/includes/admin/load.php
------ -----------------------------------------------------------------------------
232 Parameter #1 $value of function trailingslashit expects string, null given.
------ -----------------------------------------------------------------------------
[ERROR] Found 1 error
Currently, both constants.php and plugins/performance-lab/load.php define PERFLAB_PLUGIN_DIR_PATH. However, the one in plugins/performance-lab/load.php evaluates to null:
performance/plugins/performance-lab/load.php
Lines 23 to 24 in b1bf1ae
This issue also becomes apparent if the order of files in bootstrapFiles is changed as follows:
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index c66cc423..9c617d12 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -9,9 +9,9 @@ parameters:
- performance.php
- plugins/performance-lab/load.php
bootstrapFiles:
- - tools/phpstan/constants.php
- plugins/performance-lab/load.php
+ - tools/phpstan/constants.php
- plugins/webp-uploads/load.php
scanDirectories:
- vendor/wp-phpunit/wp-phpunit/
scanFiles:
With this change, both the warning and the error occur:
PHP Warning: Constant PERFLAB_PLUGIN_DIR_PATH already defined in /home/shyam/Workspace/rtCamp/wp-performance/tools/phpstan/constants.php on line 21
Warning: Constant PERFLAB_PLUGIN_DIR_PATH already defined in /home/shyam/Workspace/rtCamp/wp-performance/tools/phpstan/constants.php on line 21
206/206 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
------ -----------------------------------------------------------------------------
Line plugins/performance-lab/includes/admin/load.php
------ -----------------------------------------------------------------------------
232 Parameter #1 $value of function trailingslashit expects string, null given.
------ -----------------------------------------------------------------------------
[ERROR] Found 1 error
Since none of the other constants defined in plugins/performance-lab/load.php appear to be required for static analysis, removing this file from bootstrapFiles seems appropriate.
This reverts commit 6f588ee.
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
|
The WordPress is not fully support in that version do we needs to change that version to |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Summary
Fixes #1728