mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
Merge pull request #9030 from kkmuffme/psalm-scope-this-doesnt-work-with-FQCN-leading-backslash
fix @psalm-scope-this not working with FQCN with leading backslash
This commit is contained in:
commit
ef1264bd46
@ -76,6 +76,7 @@ use function fwrite;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function is_string;
|
||||
use function ltrim;
|
||||
use function preg_split;
|
||||
use function reset;
|
||||
use function round;
|
||||
@ -793,6 +794,7 @@ class StatementsAnalyzer extends SourceAnalyzer
|
||||
|
||||
if (isset($comments->tags['psalm-scope-this'])) {
|
||||
$trimmed = trim(reset($comments->tags['psalm-scope-this']));
|
||||
$trimmed = ltrim($trimmed, '\\');
|
||||
|
||||
if (!$codebase->classExists($trimmed)) {
|
||||
IssueBuffer::maybeAdd(
|
||||
|
@ -194,6 +194,13 @@ class ScopeTest extends TestCase
|
||||
?>
|
||||
<h1><?= $this->getMessage() ?></h1>',
|
||||
],
|
||||
'psalmScopeThisInTemplateFQCN' => [
|
||||
'code' => '<?php
|
||||
$e = new Exception(); // necessary to trick Psalm’s scanner for test
|
||||
/** @psalm-scope-this \Exception */
|
||||
?>
|
||||
<h1><?= $this->getMessage() ?></h1>',
|
||||
],
|
||||
'psalmVarThisInTemplate' => [
|
||||
'code' => '<?php
|
||||
$e = new Exception(); // necessary to trick Psalm’s scanner for test
|
||||
|
Loading…
x
Reference in New Issue
Block a user