1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Support old-style namespaced constructors

This commit is contained in:
Matthew Brown 2016-12-27 01:06:05 +00:00
parent dac54c41ab
commit 324b7b4801
2 changed files with 12 additions and 7 deletions

View File

@ -1057,15 +1057,15 @@ abstract class FunctionLikeChecker extends SourceChecker implements StatementsSo
if ($fq_class_name && ClassLikeChecker::isUserDefined($fq_class_name)) {
$method_params = MethodChecker::getMethodParams($method_id);
if ($method_params === null) {
throw new \UnexpectedValueException('Not expecting $method_params to be null');
}
return $method_params;
} elseif (!$fq_class_name && FunctionChecker::inCallMap($method_id)) {
$function_param_options = FunctionChecker::getParamsFromCallMap($method_id);
if ($function_param_options === null) {
throw new \UnexpectedValueException('Not expecting $function_param_options to be null');
}

View File

@ -301,7 +301,7 @@ class MethodChecker extends FunctionLikeChecker
$method_id = $this->fq_class_name . '::' . strtolower($method->name);
$cased_method_id = self::$cased_method_ids[$method_id] = $this->fq_class_name . '::' . $method->name;
if (strtolower((string)$method->name) === strtolower((string)$this->fq_class_name)) {
if (strtolower((string)$method->name) === strtolower((string)$this->class_name)) {
self::setDeclaringMethodId($this->fq_class_name . '::__construct', $method_id);
}
@ -739,12 +739,17 @@ class MethodChecker extends FunctionLikeChecker
}
/**
* @param string $method_id
* @param string $original_method_id
* @return string
*/
public static function getCasedMethodId($method_id)
public static function getCasedMethodId($original_method_id)
{
$method_id = self::getDeclaringMethodId($method_id);
$method_id = self::getDeclaringMethodId($original_method_id);
if ($method_id === null) {
throw new \UnexpectedValueException('Cannot get declaring method id for ' . $original_method_id);
}
return self::$cased_method_ids[$method_id];
}