Visitar URL original
Update Error Docs by phpstan-bot · Pull Request #15427 · phpstan/phpstan · GitHub
Skip to content

Update Error Docs - #15427

Open
phpstan-bot wants to merge 1 commit into
phpstan:2.3.xfrom
phpstan-bot:create-pull-request/patch-acdoqoq
Open

phpstan-bot wants to merge 1 commit into
phpstan:2.3.xfrom
phpstan-bot:create-pull-request/patch-acdoqoq

Conversation

@phpstan-bot

Copy link
Copy Markdown
Contributor

The latest errorsIdentifiers.json update only moved the phpunit.assertEmpty source line (L48 → L54). That move comes from phpstan-phpunit making AssertEmptyIsDiscouragedRule auto-fixable. Seven identifiers for the new @pure-unless-parameter-passed PHPDoc tag (phpstan-src 2.3.x) were also still undocumented.

New pages

  • pureFunction.nonOptionalParameterPassed, pureMethod.nonOptionalParameterPassed, purePropertyHook.nonOptionalParameterPassed: the tag names a parameter that is not optional, so the function is never pure.
  • pureFunction.parameterPassedNotByRef, pureMethod.parameterPassedNotByRef, purePropertyHook.parameterPassedNotByRef: the tag names a by-value parameter, so passing it cannot add a side effect.
  • method.impureOverridePureUnlessParameterPassed: an @phpstan-impure method overrides a parent method marked @pure-unless-parameter-passed (bleeding edge, reportMethodPurityOverride).

The research covered FunctionPurityCheck, MethodSignatureRule and their test fixtures. The function, method and override examples, and the suggested fixes, were checked on the playground, and each example reports the expected identifier.

Note on purePropertyHook.*: I couldn't reproduce these two identifiers. MutatingScope::enterPropertyHook() passes empty pure-unless parameter lists to the hook reflection, so the tag is never read on hooks right now. The identifiers exist only because the rule builds them with sprintf. The existing purePropertyHook.redundantUnlessCallable page has the same limitation. These pages explain why the tag can't work on a set hook, whose $value is always required and passed by value, and suggest removing it.

Updated page

  • phpunit.assertEmpty: says the call can be rewritten with --fix and lists the replacements by native type: bool → assertTrue/assertFalse, array → assertCount(0)/assertNotCount(0), int → assertSame(0)/assertNotSame(0), and a nullable final class that isn't Countable → assertNull/assertNotNull.

🤖 Generated with Claude Code

- Add docs for pureFunction/pureMethod/purePropertyHook.nonOptionalParameterPassed
- Add docs for pureFunction/pureMethod/purePropertyHook.parameterPassedNotByRef
- Add docs for method.impureOverridePureUnlessParameterPassed
- Update phpunit.assertEmpty: the rule is now auto-fixable with --fix
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.

1 participant