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

Fix #1337 - don’t crash when examining __call methods in initialisation checks

This commit is contained in:
Matthew Brown 2019-02-18 16:04:27 -05:00
parent 81a5a24e15
commit 6b419452af
2 changed files with 16 additions and 1 deletions

View File

@ -139,7 +139,8 @@ class CallAnalyzer
}
if (!$declaring_method_id) {
throw new \UnexpectedValueException('Could not find declaring method for ' . $method_id);
// can happen for __call
return;
}
}

View File

@ -2157,6 +2157,20 @@ class PropertyTypeTest extends TestCase
}',
'error_message' => 'PossiblyNullArgument'
],
'noCrashOnMagicCall' => [
'<?php
class A {
/** @var string */
private $a;
public function __construct() {
$this->setA();
}
public function __call(string $var, array $args) {}
}',
'error_message' => 'PropertyNotSetInConstructor'
],
];
}
}