Skip to content

Commit

Permalink
Fix #5 by simplifying oldstyle constructor support
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Dec 7, 2016
1 parent 76ca483 commit 364a0dc
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Psalm/Checker/MethodChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,11 @@ public static function getMethodReturnTypeLocation($method_id, CodeLocation &$de
*/
public static function extractReflectionMethodInfo(\ReflectionMethod $method)
{
$method_id = $method->class . '::' . strtolower((string)$method->name);
self::$cased_method_ids[$method_id] = $method->class . '::' . $method->name;

if (strtolower((string)$method->name) === strtolower((string)$method->class)) {
$method_id = $method->class . '::__construct';
self::$cased_method_ids[$method_id] = $method->class . '::__construct';
}
else {
$method_id = $method->class . '::' . strtolower((string)$method->name);
self::$cased_method_ids[$method_id] = $method->class . '::' . $method->name;
self::setDeclaringMethodId($method->class . '::__construct', $method_id);
}

if (isset(self::$have_reflected[$method_id])) {
Expand Down Expand Up @@ -292,14 +290,13 @@ public static function checkMethodStatic($method_id, CodeLocation $code_location
*/
protected function registerMethod(PhpParser\Node\Stmt\ClassMethod $method)
{
if (strtolower($method->name) === strtolower((string)$this->class_name)) {
$method_id = $this->fq_class_name . '::__construct';
} else {
$method_id = $this->fq_class_name . '::' . strtolower($method->name);
}

$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)) {
self::setDeclaringMethodId($this->fq_class_name . '::__construct', $method_id);
}

if (isset(self::$have_reflected[$method_id]) || isset(self::$have_registered[$method_id])) {
$this->suppressed_issues = self::$method_suppress[$method_id];

Expand Down

0 comments on commit 364a0dc

Please sign in to comment.