Bump PHPStan rule level to 1#11151
Conversation
Co-authored-by: Dovid Levine <david@axepress.dev>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
e6bd045 to
bf92684
Compare
PHPStan cannot verify that wp_die() always terminates due to its conditional return type and treatPhpDocTypesAsCertain being disabled.
Co-authored-by: Christoph Daum <christoph.daum@coding-pioneers.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
…into bump/phpstan-level-1
Fixes PHPStan issue:
------ ---------------------------------------------------------------
Line wp-admin/includes/class-wp-posts-list-table.php
------ ---------------------------------------------------------------
357 Variable $class in empty() always exists and is always falsy.
🪪 empty.variable
at src/wp-admin/includes/class-wp-posts-list-table.php:357
------ ---------------------------------------------------------------
…edit_link() takes no args
There was a problem hiding this comment.
@JJJ Do these changes (a47a434) look good to you? PHPStan flagged some issues, in that method_exists() doesn't guarantee the first arg is an object. Also, it was passing $blog_id to wp_cache_switch_to_blog_fallback() which doesn't take an arg.
Ref. r61760 (530fe2e) for Core-23290.
| <header class="entry-header"> | ||
| <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?> | ||
|
|
||
| <?php twentyseventeen_edit_link( get_the_ID() ); ?> |
There was a problem hiding this comment.
@sabernhardt Given that twentyseventeen_edit_link() is a pluggable function, would you feel better to add the new parameter? Or should the param be removed from being passed since it isn't used?
There was a problem hiding this comment.
I'd like to discuss twentyseventeen_edit_link() in a separate ticket.
I wondered why the function did not have a parameter and then found out it had an $id parameter in the initial commit. But then the page/post context was removed, and the parameter was removed before the function was ever pluggable (and before version 1.0). Also, the comment about context does not seem appropriate.
There was a problem hiding this comment.
@sabernhardt I've opened Core-64825 for this.
…into bump/phpstan-level-1
…venteen_edit_link() takes no args" This reverts commit 680d165.
By increasing the PHPStan rule level to 1, the following issues will begin to be detected for new code introduced to core:
Here is the original tally of ignored errors in
tests/phpstan/baseline.phpcategorized by their PHPStan identifier:empty.variableempty()on variables that always exist, are always falsy, or are not falsyconstant.notFoundisset.variableisset()on variables that always exist, are not nullable, or are never definedvariable.undefinedarguments.countconstructor.unusedParameterAnd with the current fixes pushed to this branch, these are the remaining errors in the baseline:
empty.variableempty()on variables that always exist, are always falsy, or are not falsyisset.variableisset()on variables that always exist, are not nullable, or are never definedThis cherry-picks some commits from #11009.
See also #11037 which bumps to level 4.
Trac ticket: https://core.trac.wordpress.org/ticket/64680
Use of AI Tools
n/a
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.