1
0
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:
orklah 2022-12-31 12:08:20 +01:00 committed by GitHub
commit ef1264bd46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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(

View File

@ -194,6 +194,13 @@ class ScopeTest extends TestCase
?>
<h1><?= $this->getMessage() ?></h1>',
],
'psalmScopeThisInTemplateFQCN' => [
'code' => '<?php
$e = new Exception(); // necessary to trick Psalms scanner for test
/** @psalm-scope-this \Exception */
?>
<h1><?= $this->getMessage() ?></h1>',
],
'psalmVarThisInTemplate' => [
'code' => '<?php
$e = new Exception(); // necessary to trick Psalms scanner for test