Repository navigation
fix(visitor): document the return types of the overridden node visitor methods - #245
Merged
Merged
Conversation
…r methods PhpParser\NodeVisitor declares its return types in docblocks only. Visitor methods without a native return type and without their own @return made Symfony's DebugClassLoader report a "might add a native return type" deprecation for every application that reflects code in debug mode. The methods now document their return types instead of inheriting the docblock; no native types are declared, so PHP-Parser stays in charge of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DaSZY1jAz2XfyjhPa
Member
Author
|
PHPStan analysis will fail here, but not because of this PR. The only error is Generated by Claude Code |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FxhC1DaSZY1jAz2XfyjhPa
lisachenko
marked this pull request as ready for review
November 2, 2026 17:27
This was referenced Nov 2, 2026
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.
Summary
Fixes #243.
RootNamespaceNormalizer::beforeTraverse(),GeneratorDetector::enterNode()andStaticVariablesCollector::enterNode()replace{@inheritDoc}with an explicit@returndocblock. That silences Symfony's DebugClassLoader "might add a native return type" deprecation. No native return types are declared, so PHP-Parser stays in charge of these signatures if it adds native types later.Targets
4.x;cascade-merge.ymlcarries it intomasterafter the merge.Changes
@return(and a one-line description) on the three overridden visitor methods:Node[]|nullforbeforeTraverse()int|nullfor the twoenterNode(), which only returnDONT_TRAVERSE_CHILDRENornulltests/NodeVisitor/NodeVisitorReturnTypeTest.php: everyPhpParser\NodeVisitormethod overridden insrc/NodeVisitorhas a@returntag and no native return type, so the decision is enforced for future visitors too.Testing
4.xwithout the change (3 failures) and passes with it.DebugClassLoaderagainst the three classes: 3 deprecations before, none after.vendor/bin/phpunit: OK (13750 tests; the 133 skipped and 2 incomplete are already on4.x).vendor/bin/phpstan analyse src: 1 error, which4.xalready has without this change:Traits/ReflectionClassLikeTrait.php:1303, "Strict comparison using === between (int|string) and null will always evaluate to false" (PHPStan 2.3.4).Generated by Claude Code