Repository navigation
fix(scanner): queue the class of @psalm-scope-this for scanning - #14565
Conversation
…#11661 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Behaviour change
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 63ee866. Configure here.
✅ Performance: unchanged · Types: unchanged
How to read this table
head 2a26cb6 · base 680d78d (merge-base) · workflow run |
…cblock vimeo#11661 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
orklah
left a comment
There was a problem hiding this comment.
Thanks! The fix is in the right place, and it also fixes a crash: with an aliased class (use RuntimeException as E; /** @psalm-scope-this E */ ?> <?= $this->getMessage() ?>), master currently crashes with Could not get class storage for runtimeexception.
One regression, though: a tag whose value resolves to an empty name now crashes the scanner. For example:
<?php
/** @psalm-scope-this \ */
?>
<h1><?= 1 ?></h1>On master this reports UndefinedDocblockClass: Scope class does not exist. On this branch Psalm crashes with Uninitialized string offset 0 in Scanner::queueClassLikeForScanning(), because Type::getFQCLNFromString('\') returns ''. Since the scanner also runs on vendor files, such a docblock in a dependency would now take the whole run down. Could you check the resolved name instead of (or as well as) the trimmed tag, e.g.
$scope_fqcn = $scope_class !== '' ? Type::getFQCLNFromString($scope_class, $this->aliases) : '';
if ($scope_fqcn !== '') {and add a test for it, like testPsalmScopeThisWithoutAClassInAFileThatIsOnlyScanned but with @psalm-scope-this \?
…othing vimeo#11661 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

A class named only by
@psalm-scope-this(not otherwise referenced in the project) is never loaded, unlike the class of a@var.Before
After: no issue; the class is queued for scanning like the class of a
@var(ScopeTest::psalmScopeThisInTemplateIsTheOnlyReferenceToTheClass).Fixes #11661