Repository navigation
Update Error Docs - #15427
Open
phpstan-bot wants to merge 1 commit into
Open
Update Error Docs#15427phpstan-bot wants to merge 1 commit into
phpstan-bot wants to merge 1 commit into
Conversation
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The latest
errorsIdentifiers.jsonupdate only moved thephpunit.assertEmptysource line (L48 → L54). That move comes from phpstan-phpunit makingAssertEmptyIsDiscouragedRuleauto-fixable. Seven identifiers for the new@pure-unless-parameter-passedPHPDoc 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-impuremethod overrides a parent method marked@pure-unless-parameter-passed(bleeding edge,reportMethodPurityOverride).The research covered
FunctionPurityCheck,MethodSignatureRuleand 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 withsprintf. The existingpurePropertyHook.redundantUnlessCallablepage has the same limitation. These pages explain why the tag can't work on asethook, whose$valueis always required and passed by value, and suggest removing it.Updated page
phpunit.assertEmpty: says the call can be rewritten with--fixand 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'tCountable→assertNull/assertNotNull.🤖 Generated with Claude Code