mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Also catch static invocations of non-static methods
This commit is contained in:
parent
9a35742803
commit
0e600665bb
@ -860,6 +860,7 @@ class StatementsChecker
|
|||||||
} else {
|
} else {
|
||||||
$absolute_class = ($this->_namespace ? '\\' : '') . $this->_namespace . '\\' . $this->_class_name;
|
$absolute_class = ($this->_namespace ? '\\' : '') . $this->_namespace . '\\' . $this->_class_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif ($this->_check_classes) {
|
} elseif ($this->_check_classes) {
|
||||||
ClassChecker::checkClassName($stmt->class, $this->_namespace, $this->_aliased_classes, $this->_file_name);
|
ClassChecker::checkClassName($stmt->class, $this->_namespace, $this->_aliased_classes, $this->_file_name);
|
||||||
$absolute_class = ClassChecker::getAbsoluteClassFromName($stmt->class, $this->_namespace, $this->_aliased_classes);
|
$absolute_class = ClassChecker::getAbsoluteClassFromName($stmt->class, $this->_namespace, $this->_aliased_classes);
|
||||||
@ -881,6 +882,17 @@ class StatementsChecker
|
|||||||
throw new CodeException('Method ' . $method_id . ' is not static', $this->_file_name, $stmt->getLine());
|
throw new CodeException('Method ' . $method_id . ' is not static', $this->_file_name, $stmt->getLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if ($stmt->class->parts[0] === 'self' && $stmt->name !== '__construct') {
|
||||||
|
if (!isset(self::$_static_methods[$method_id])) {
|
||||||
|
self::_extractReflectionMethodInfo($method_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!self::$_static_methods[$method_id]) {
|
||||||
|
throw new CodeException('Cannot call non-static method ' . $method_id . ' as if it were static', $this->_file_name, $stmt->getLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$return_types = $this->_getMethodReturnTypes($method_id);
|
$return_types = $this->_getMethodReturnTypes($method_id);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user