Skip to content

Add file and line context to "Unknown identifier" exceptions#14776

Open
iliaal wants to merge 1 commit into
phpstan:2.2.xfrom
iliaal:fix/identifier-extractor-error-context
Open

Add file and line context to "Unknown identifier" exceptions#14776
iliaal wants to merge 1 commit into
phpstan:2.2.xfrom
iliaal:fix/identifier-extractor-error-context

Conversation

@iliaal
Copy link
Copy Markdown

@iliaal iliaal commented Jun 5, 2026

ErrorWithIdentifierCollector, RuleErrorBuilderCollector and RestrictedUsageCollector threw ShouldNotHappenException with a static "Unknown identifier" message built by a placeholder-less sprintf. When a rule passes a non-constant-string identifier the whole extraction aborts with no indication of which file or call caused it. Each message now includes the analysed file and line. php -l clean.

The three identifier collectors threw ShouldNotHappenException with a static
"Unknown identifier" message (and a placeholder-less sprintf), so a rule passing
a non-constant-string identifier aborted the whole extraction with no clue which
file or call caused it. Include the analysed file and line in each message.
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