mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
GH-9825
This commit is contained in:
parent
b99857cb9c
commit
f279c39503
@ -981,17 +981,23 @@ class AssignmentAnalyzer
|
||||
$context->references_to_external_scope[$lhs_var_id] = true;
|
||||
}
|
||||
if (strpos($rhs_var_id, '->') !== false) {
|
||||
IssueBuffer::maybeAdd(new UnsupportedPropertyReferenceUsage(
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt),
|
||||
));
|
||||
IssueBuffer::maybeAdd(
|
||||
new UnsupportedPropertyReferenceUsage(
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt),
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues(),
|
||||
);
|
||||
// Reference to object property, we always consider object properties to be an external scope for references
|
||||
// TODO handle differently so it's detected as unused if the object is unused?
|
||||
$context->references_to_external_scope[$lhs_var_id] = true;
|
||||
}
|
||||
if (strpos($rhs_var_id, '::') !== false) {
|
||||
IssueBuffer::maybeAdd(new UnsupportedPropertyReferenceUsage(
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt),
|
||||
));
|
||||
IssueBuffer::maybeAdd(
|
||||
new UnsupportedPropertyReferenceUsage(
|
||||
new CodeLocation($statements_analyzer->getSource(), $stmt),
|
||||
),
|
||||
$statements_analyzer->getSuppressedIssues(),
|
||||
);
|
||||
}
|
||||
|
||||
$lhs_location = new CodeLocation($statements_analyzer->getSource(), $stmt->var);
|
||||
|
@ -5,11 +5,30 @@ declare(strict_types=1);
|
||||
namespace Psalm\Tests;
|
||||
|
||||
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
|
||||
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
|
||||
|
||||
class UnsupportedPropertyReferenceUsage extends TestCase
|
||||
{
|
||||
use ValidCodeAnalysisTestTrait;
|
||||
use InvalidCodeAnalysisTestTrait;
|
||||
|
||||
public function providerValidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
'can be suppressed' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
class A {
|
||||
public int $b = 0;
|
||||
}
|
||||
$a = new A();
|
||||
/** @psalm-suppress UnsupportedPropertyReferenceUsage */
|
||||
$b = &$a->b;
|
||||
PHP,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function providerInvalidCodeParse(): iterable
|
||||
{
|
||||
return [
|
||||
|
Loading…
Reference in New Issue
Block a user