1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Exit early for invalid class or interface

This commit is contained in:
Matthew Brown 2016-08-09 12:11:58 -04:00
parent 588ae82ffb
commit b0f6a020da

View File

@ -1348,8 +1348,38 @@ class StatementsChecker
$class_visibility = \ReflectionProperty::IS_PUBLIC;
}
if (!ClassChecker::classExists($lhs_type_part->value)) {
if (ClassChecker::interfaceExists($lhs_type_part->value)) {
if (IssueBuffer::accepts(
new NoInterfaceProperties(
'Interfaces cannot have properties',
$this->_file_name,
$stmt->getLine()
),
$this->_suppressed_issues
)) {
return false;
}
return;
}
if (IssueBuffer::accepts(
new UndefinedClass(
'Cannot set properties of undefined class ' . $lhs_type_part->value,
$this->_file_name,
$stmt->getLine()
),
$this->_suppressed_issues
)) {
return false;
}
return;
}
$class_properties = ClassChecker::getInstancePropertiesForClass(
(string) $lhs_type_part,
$lhs_type_part->value,
$class_visibility
);