Closed szepeviktor closed 2 years ago
Just two commands.
# PHP 8.0
composer require --dev szepeviktor/phpstan-wordpress
vendor/bin/phpstan analyze -c vendor/szepeviktor/phpstan-wordpress/extension.neon -l 5 simple-page-ordering.php
------ -----------------------------------------------------------------------------------------------
Line simple-page-ordering.php
------ -----------------------------------------------------------------------------------------------
32 Class Simple_Page_Ordering referenced with incorrect case: Simple_page_Ordering. 👈
77 Function apply_filters invoked with 3 parameters, 2 required.
191 Method Simple_Page_Ordering::page_ordering() has invalid return type obj. 👈
369 Method Simple_Page_Ordering::page_ordering() should return obj|WP_Error but returns string. 👈
375 Method Simple_Page_Ordering::page_ordering() should return obj|WP_Error but returns stdClass. 👈
408 Function apply_filters invoked with 3 parameters, 2 required.
468 Result of && is always false. 👈
468 Variable $nextid in isset() always exists and is not nullable. 👈
468 Variable $previd in isset() always exists and is not nullable. 👈
------ -----------------------------------------------------------------------------------------------
Marked ones are resolved in PR-s. The ones mentioning apply_filters
could be ignored.
On higher levels (6, 7, 8, 9) you have to supply more information to PHPStan in docblocks/typehints.
Just two commands.
@szepeviktor Running your command on this PR, I got this report
------ ----------------------------------------------------------------
Line simple-page-ordering.php
------ ----------------------------------------------------------------
77 Function apply_filters invoked with 3 parameters, 2 required.
408 Function apply_filters invoked with 3 parameters, 2 required.
468 Result of && is always false.
468 Variable $nextid in isset() always exists and is not nullable.
468 Variable $previd in isset() always exists and is not nullable.
------ ----------------------------------------------------------------
The first two are safe to ignore, but do you think we should fix the remaining?
The first two are safe to ignore, but do you think we should fix the remaining?
Please see https://github.com/10up/simple-page-ordering/pull/94
Description of the Change
Ran @phpstan and fixed reported problems.
Verification Process
Nope.
Checklist:
Changelog Entry
Fixed coding standards