Closed szepeviktor closed 5 years ago
$ vendor/bin/phpstan analyze
------ ---------------------------------------------------------------------------------------------------
Line class-core.php
------ ---------------------------------------------------------------------------------------------------
116 Parameter #1 $path of method JB\FlyImages\Core::get_fly_dir() expects string, int given.
226 Method JB\FlyImages\Core::get_attachment_image_src() should return array but returns array|false.
252 Parameter #1 $path of method JB\FlyImages\Core::get_fly_dir() expects string, int given.
279 Parameter #1 $path of function wp_get_image_editor expects string, string|false given.
320 Parameter #3 $icon of function wp_get_attachment_image expects bool, array given.
338 Cannot access property $post_excerpt on WP_Post|null.
341 Cannot access property $post_title on WP_Post|null.
------ ---------------------------------------------------------------------------------------------------
------ -------------------------------------------------------------------------------------------------------------
Line class-fly_cli.php
------ -------------------------------------------------------------------------------------------------------------
39 Parameter #1 $attachment_id of method JB\FlyImages\Core::delete_attachment_fly_images() expects int, string
given.
------ -------------------------------------------------------------------------------------------------------------
This is the result of static analysis using https://github.com/szepeviktor/phpstan-wordpress
This is phpstan.neon.dist
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: max
inferPrivatePropertyTypeFromConstructor: true
paths:
- %currentWorkingDirectory%/inc/
autoload_files:
- /home/viktor/tmp/action-scheduler/wp-cli-stubs-2.2.0.php
- %currentWorkingDirectory%/fly-dynamic-image-resizer.php
- %currentWorkingDirectory%/inc/helpers.php
ignoreErrors:
# Uses func_get_args()
- '#^Function apply_filters invoked with [34567] parameters, 2 required\.$#'
- '#^Function do_action invoked with [3456] parameters, 1-2 required\.$#'
# WP-CLI accepts a class as callable
- '/^Parameter #2 \$callable of static method WP_CLI::add_command\(\) expects callable\(\): mixed, \S+ given\.$/'
wp-cli-stubs-2.2.0.php is from https://github.com/szepeviktor/phpstan-wordpress/blob/master/stub-generators/wp-cli-generate-stubs.sh
Are you interested?
Hey @szepeviktor thanks for the issue. I'm closing it as it doesn't add any functionality to the plugin.
Okay. Static analysis is like adding 100 pairs of 👀 to your project. It prevents errors humans are not always able to detect.
@junaidbhura Please reconsider applying the fixes from the first comment
Thank you.
Hello @junaidbhura !
inc/class-fly-cli.php
is loaded by the autoloader as/inc/class-fly_cli.php
Could you rename the file?And some type problems.