Skip to content

fix: Error in Symplify\PHPStanRules\Rules\NoReferenceRule with #[MapEntity] (fixes symplify/phpstan-rules#263)#265

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
fix/issue-263-error-in-symplify-phpstanrules-rules-noreferenceru
Closed

fix: Error in Symplify\PHPStanRules\Rules\NoReferenceRule with #[MapEntity] (fixes symplify/phpstan-rules#263)#265
TomasVotruba wants to merge 1 commit into
mainfrom
fix/issue-263-error-in-symplify-phpstanrules-rules-noreferenceru

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Summary

Fixes #263 — Error in Symplify\PHPStanRules\Rules\NoReferenceRule with #[MapEntity]

Root cause

See the commit message and diff for details of what was changed and why.

Testing

  • Test suite was run locally — see commit for details.

Opened automatically by bin/handyman.php. Please review carefully before merging.

…263)

PHPStan's hasMethod()/getMethod() include methods reported by class
reflection extensions (e.g. Doctrine's magic findOneBy* finders). When
such an extension reports hasMethod() = true for a method like
findOneBySlug() but the method isn't actually native, getMethod() throws
MissingMethodFromReflectionException, crashing NoReferenceRule.

Switching to hasNativeMethod()/getNativeMethod() restricts the lookup to
real source methods, which is what we actually need since the resolver's
downstream consumer parses the method's AST node.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

Error in Symplify\PHPStanRules\Rules\NoReferenceRule with #[MapEntity]

1 participant