mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Hoist class check above method check
This commit is contained in:
parent
03141e41c2
commit
ad38a26524
@ -471,31 +471,13 @@ class AssignmentChecker
|
||||
return null;
|
||||
}
|
||||
|
||||
if (MethodChecker::methodExists($lhs_type_part . '::__set')) {
|
||||
$context->vars_in_scope[$var_id] = Type::getMixed();
|
||||
continue;
|
||||
}
|
||||
|
||||
$has_regular_setter = true;
|
||||
|
||||
if (ExpressionChecker::isMock($lhs_type_part->value)) {
|
||||
$has_regular_setter = true;
|
||||
$context->vars_in_scope[$var_id] = Type::getMixed();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (($stmt->var instanceof PhpParser\Node\Expr\Variable && $stmt->var->name === 'this')
|
||||
|| $lhs_type_part->value === $context->self
|
||||
) {
|
||||
$class_visibility = \ReflectionProperty::IS_PRIVATE;
|
||||
} elseif ($context->self &&
|
||||
ClassChecker::classExtends($lhs_type_part->value, $context->self)
|
||||
) {
|
||||
$class_visibility = \ReflectionProperty::IS_PROTECTED;
|
||||
} else {
|
||||
$class_visibility = \ReflectionProperty::IS_PUBLIC;
|
||||
}
|
||||
|
||||
if (!ClassChecker::classExists($lhs_type_part->value, $file_checker)) {
|
||||
if (InterfaceChecker::interfaceExists($lhs_type_part->value, $file_checker)) {
|
||||
if (IssueBuffer::accepts(
|
||||
@ -524,6 +506,25 @@ class AssignmentChecker
|
||||
return null;
|
||||
}
|
||||
|
||||
if (MethodChecker::methodExists($lhs_type_part . '::__set')) {
|
||||
$context->vars_in_scope[$var_id] = Type::getMixed();
|
||||
continue;
|
||||
}
|
||||
|
||||
$has_regular_setter = true;
|
||||
|
||||
if (($stmt->var instanceof PhpParser\Node\Expr\Variable && $stmt->var->name === 'this')
|
||||
|| $lhs_type_part->value === $context->self
|
||||
) {
|
||||
$class_visibility = \ReflectionProperty::IS_PRIVATE;
|
||||
} elseif ($context->self &&
|
||||
ClassChecker::classExtends($lhs_type_part->value, $context->self)
|
||||
) {
|
||||
$class_visibility = \ReflectionProperty::IS_PROTECTED;
|
||||
} else {
|
||||
$class_visibility = \ReflectionProperty::IS_PUBLIC;
|
||||
}
|
||||
|
||||
$property_id = $lhs_type_part->value . '::$' . $prop_name;
|
||||
|
||||
if (!ClassLikeChecker::propertyExists($property_id)) {
|
||||
|
Loading…
Reference in New Issue
Block a user