Skip to content
Permalink
Browse files

Emit undefined docblock class error where appropriate on property fet…

…cthes
  • Loading branch information...
muglug committed May 16, 2019
1 parent ee3dfba commit 9a93525d33a0f2d540fcd8e7af5c70195f6b2127
Showing with 23 additions and 9 deletions.
  1. +23 −9 src/Psalm/Internal/Analyzer/Statements/Expression/Fetch/PropertyFetchAnalyzer.php
@@ -20,6 +20,7 @@
use Psalm\Issue\PossiblyInvalidPropertyFetch;
use Psalm\Issue\PossiblyNullPropertyFetch;
use Psalm\Issue\UndefinedClass;
use Psalm\Issue\UndefinedDocblockClass;
use Psalm\Issue\UndefinedPropertyFetch;
use Psalm\Issue\UndefinedThisPropertyFetch;
use Psalm\Issue\UninitializedProperty;
@@ -425,15 +426,28 @@ public static function analyzeInstance(
}
if (!$class_exists && !$interface_exists) {
if (IssueBuffer::accepts(
new UndefinedClass(
'Cannot set properties of undefined class ' . $lhs_type_part->value,
new CodeLocation($statements_analyzer->getSource(), $stmt),
$lhs_type_part->value
),
$statements_analyzer->getSuppressedIssues()
)) {
// fall through
if ($lhs_type_part->from_docblock) {
if (IssueBuffer::accepts(
new UndefinedDocblockClass(
'Cannot set properties of undefined docblock class ' . $lhs_type_part->value,
new CodeLocation($statements_analyzer->getSource(), $stmt),
$lhs_type_part->value
),
$statements_analyzer->getSuppressedIssues()
)) {
// fall through
}
} else {
if (IssueBuffer::accepts(
new UndefinedClass(
'Cannot set properties of undefined class ' . $lhs_type_part->value,
new CodeLocation($statements_analyzer->getSource(), $stmt),
$lhs_type_part->value
),
$statements_analyzer->getSuppressedIssues()
)) {
// fall through
}
}
return null;

0 comments on commit 9a93525

Please sign in to comment.
You can’t perform that action at this time.