Skip to content

Fix missing scope for unreachable statements after labels - #8971

Open
samsonasik wants to merge 5 commits into
mainfrom
after-lable
Open

samsonasik wants to merge 5 commits into
mainfrom
after-lable

Conversation

@samsonasik

Copy link
Copy Markdown
Member

Fixes #8966

@samsonasik

Copy link
Copy Markdown
Member Author

Fixed 🎉 /cc @hmennen90

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

@TomasVotruba

Copy link
Copy Markdown
Member

Can you make a bench before/after this change? Look quite expensive

@samsonasik

samsonasik commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

@TomasVotruba yes, I added benchmark script at 4aa630f

It slower when dead Label statement exists

Case main this branch Statements without scope
No labels (BetterStandardPrinter.php, 283 stmts) 68.39 / 70.06 / 68.48 68.02 / 68.72 / 68.95 0 → 0
Labels (GotoLabelSource.php, 484 stmts) 34.02 / 34.70 72.68 / 73.14 / 73.10 200 → 0

If this can't be here, I guess PHPStan NodeScopeResolver is better place to handle it.

https://github.com/phpstan/phpstan-src/blob/a60e937647b3432a8ce73487ba17bee57ff676cd/src/Analyser/NodeScopeResolver.php#L187

@samsonasik

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Print a hint at the end of a run when files were skipped because of errors

2 participants