Skip to content

Build/Test Tools: Raise the PHPStan rule level to 4 - #12853

Closed
westonruter wants to merge 1 commit into
WordPress:trunkfrom
westonruter:bump/phpstan-level-4-baselines
Closed

Build/Test Tools: Raise the PHPStan rule level to 4#12853
westonruter wants to merge 1 commit into
WordPress:trunkfrom
westonruter:bump/phpstan-level-4-baselines

Conversation

@westonruter

@westonruter westonruter commented Aug 5, 2026

Copy link
Copy Markdown
Member

✅ Committed in r63023 (79d902a)


This rule level includes:

basic dead code checking - always false instanceof and other type checks, dead else branches, unreachable code after return; etc.

Baselines are regenerated for errors at this level.

Follow-up to r61699, r63019, r63020, r63021, r63022.

Trac ticket: https://core.trac.wordpress.org/ticket/64680

$ composer phpstan:baselines
Analyzing with phpstan.neon.dist, existing baselines suppressed...

                                                                                                                        
 [OK] Baseline generated with 1391 errors.                                                                              
                                                                                                                        

tests/phpstan/baselines/arguments.count.neon: 6 entries, 9 errors
tests/phpstan/baselines/assign.propertyType.neon: 28 entries, 30 errors
tests/phpstan/baselines/binaryOp.invalid.neon: 3 entries, 4 errors
tests/phpstan/baselines/booleanAnd.alwaysFalse.neon: 2 entries, 2 errors
tests/phpstan/baselines/booleanAnd.alwaysTrue.neon: 1 entries, 2 errors
tests/phpstan/baselines/booleanAnd.leftAlwaysTrue.neon: 5 entries, 5 errors
tests/phpstan/baselines/booleanAnd.rightAlwaysFalse.neon: 1 entries, 1 errors
tests/phpstan/baselines/booleanAnd.rightAlwaysTrue.neon: 9 entries, 16 errors
tests/phpstan/baselines/booleanNot.alwaysFalse.neon: 6 entries, 7 errors
tests/phpstan/baselines/booleanNot.alwaysTrue.neon: 8 entries, 8 errors
tests/phpstan/baselines/booleanOr.alwaysFalse.neon: 1 entries, 1 errors
tests/phpstan/baselines/booleanOr.alwaysTrue.neon: 2 entries, 2 errors
tests/phpstan/baselines/booleanOr.rightAlwaysTrue.neon: 1 entries, 1 errors
tests/phpstan/baselines/catch.neverThrown.neon: 1 entries, 1 errors
tests/phpstan/baselines/class.nameCase.neon: 1 entries, 1 errors
tests/phpstan/baselines/class.notFound.neon: 14 entries, 14 errors
tests/phpstan/baselines/deadCode.unreachable.neon: 57 entries, 91 errors
tests/phpstan/baselines/empty.offset.neon: 2 entries, 2 errors
tests/phpstan/baselines/empty.property.neon: 9 entries, 13 errors
tests/phpstan/baselines/empty.variable.neon: 9 entries, 9 errors
tests/phpstan/baselines/encapsedStringPart.nonString.neon: 1 entries, 1 errors
tests/phpstan/baselines/foreach.nonIterable.neon: 1 entries, 1 errors
tests/phpstan/baselines/function.alreadyNarrowedType.neon: 17 entries, 19 errors
tests/phpstan/baselines/function.impossibleType.neon: 4 entries, 6 errors
tests/phpstan/baselines/function.resultUnused.neon: 4 entries, 4 errors
tests/phpstan/baselines/greater.invalid.neon: 1 entries, 1 errors
tests/phpstan/baselines/greaterOrEqual.alwaysTrue.neon: 8 entries, 8 errors
tests/phpstan/baselines/identical.alwaysFalse.neon: 5 entries, 5 errors
tests/phpstan/baselines/identical.alwaysTrue.neon: 4 entries, 4 errors
tests/phpstan/baselines/if.alwaysFalse.neon: 7 entries, 8 errors
tests/phpstan/baselines/if.alwaysTrue.neon: 7 entries, 9 errors
tests/phpstan/baselines/instanceof.alwaysTrue.neon: 1 entries, 1 errors
tests/phpstan/baselines/isset.offset.neon: 4 entries, 4 errors
tests/phpstan/baselines/isset.property.neon: 40 entries, 44 errors
tests/phpstan/baselines/isset.variable.neon: 6 entries, 6 errors
tests/phpstan/baselines/method.childParameterType.neon: 7 entries, 7 errors
tests/phpstan/baselines/method.nonObject.neon: 7 entries, 7 errors
tests/phpstan/baselines/method.notFound.neon: 5 entries, 5 errors
tests/phpstan/baselines/method.unused.neon: 5 entries, 5 errors
tests/phpstan/baselines/notIdentical.alwaysTrue.neon: 11 entries, 13 errors
tests/phpstan/baselines/nullCoalesce.offset.neon: 1 entries, 1 errors
tests/phpstan/baselines/nullCoalesce.property.neon: 7 entries, 7 errors
tests/phpstan/baselines/offsetAccess.nonOffsetAccessible.neon: 3 entries, 6 errors
tests/phpstan/baselines/offsetAccess.notFound.neon: 4 entries, 6 errors
tests/phpstan/baselines/offsetAssign.valueType.neon: 1 entries, 2 errors
tests/phpstan/baselines/parameter.defaultValue.neon: 17 entries, 17 errors
tests/phpstan/baselines/parameter.notFound.neon: 3 entries, 3 errors
tests/phpstan/baselines/parameter.phpDocType.neon: 1 entries, 1 errors
tests/phpstan/baselines/parameter.unresolvableType.neon: 1 entries, 1 errors
tests/phpstan/baselines/parameterByRef.type.neon: 6 entries, 8 errors
tests/phpstan/baselines/parameterByRef.unusedType.neon: 2 entries, 2 errors
tests/phpstan/baselines/property.defaultValue.neon: 18 entries, 18 errors
tests/phpstan/baselines/property.nonObject.neon: 47 entries, 75 errors
tests/phpstan/baselines/property.notFound.neon: 62 entries, 113 errors
tests/phpstan/baselines/property.onlyWritten.neon: 1 entries, 1 errors
tests/phpstan/baselines/property.phpDocType.neon: 5 entries, 5 errors
tests/phpstan/baselines/property.private.neon: 8 entries, 29 errors
tests/phpstan/baselines/property.protected.neon: 8 entries, 11 errors
tests/phpstan/baselines/property.unusedType.neon: 1 entries, 1 errors
tests/phpstan/baselines/return.empty.neon: 2 entries, 2 errors
tests/phpstan/baselines/return.missing.neon: 41 entries, 44 errors
tests/phpstan/baselines/return.type.neon: 29 entries, 32 errors
tests/phpstan/baselines/return.unusedType.neon: 16 entries, 16 errors
tests/phpstan/baselines/smallerOrEqual.alwaysTrue.neon: 1 entries, 1 errors
tests/phpstan/baselines/staticClassAccess.privateMethod.neon: 34 entries, 55 errors
tests/phpstan/baselines/ternary.alwaysFalse.neon: 1 entries, 2 errors
tests/phpstan/baselines/ternary.alwaysTrue.neon: 2 entries, 2 errors
tests/phpstan/baselines/varTag.noVariable.neon: 8 entries, 17 errors
tests/phpstan/baselines/variable.undefined.neon: 195 entries, 479 errors
tests/phpstan/baselines/while.alwaysFalse.neon: 1 entries, 1 errors
tests/phpstan/baselines/while.alwaysTrue.neon: 56 entries, 56 errors
phpstan.neon.dist: `includes` updated.

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.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@westonruter

Copy link
Copy Markdown
Member Author

There are quite a few error identifiers introduced at this level.

The next level up is level 5, which is much smaller, only introducing 3:

M	phpstan.neon.dist
A	tests/phpstan/baselines/argument.type.neon
A	tests/phpstan/baselines/argument.unresolvableType.neon
A	tests/phpstan/baselines/arrayValues.list.neon

@apermo apermo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

pento pushed a commit that referenced this pull request Aug 5, 2026
This rule level includes:

> basic dead code checking - always false `instanceof` and other type checks, dead `else` branches, unreachable code after return; etc.

Baselines are regenerated for errors at this level.

Developed in #12853.
Follow-up to r61699, r63019, r63020, r63021, r63022.

Props westonruter, apermo.
See #64680.


git-svn-id: https://develop.svn.wordpress.org/trunk@63023 602fd350-edb4-49c9-b593-d223f7449a82
@westonruter westonruter closed this Aug 5, 2026
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Aug 5, 2026
This rule level includes:

> basic dead code checking - always false `instanceof` and other type checks, dead `else` branches, unreachable code after return; etc.

Baselines are regenerated for errors at this level.

Developed in WordPress/wordpress-develop#12853.
Follow-up to r61699, r63019, r63020, r63021, r63022.

Props westonruter, apermo.
See #64680.

Built from https://develop.svn.wordpress.org/trunk@63023


git-svn-id: http://core.svn.wordpress.org/trunk@62242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
DanielHudson2 pushed a commit to DanielHudson2/wordpress-develop that referenced this pull request Aug 10, 2026
This rule level includes:

> basic dead code checking - always false `instanceof` and other type checks, dead `else` branches, unreachable code after return; etc.

Baselines are regenerated for errors at this level.

Developed in WordPress#12853.
Follow-up to r61699, r63019, r63020, r63021, r63022.

Props westonruter, apermo.
See #64680.


git-svn-id: https://develop.svn.wordpress.org/trunk@63023 602fd350-edb4-49c9-b593-d223f7449a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants