mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Fix #728 - remove statement return type when re-analysing
This commit is contained in:
parent
31121cfc6d
commit
318220a1bf
@ -47,6 +47,8 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
|
|||||||
PhpParser\Node\Expr\MethodCall $stmt,
|
PhpParser\Node\Expr\MethodCall $stmt,
|
||||||
Context $context
|
Context $context
|
||||||
) {
|
) {
|
||||||
|
$stmt->inferredType = null;
|
||||||
|
|
||||||
if (ExpressionChecker::analyze($statements_checker, $stmt->var, $context) === false) {
|
if (ExpressionChecker::analyze($statements_checker, $stmt->var, $context) === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,26 @@ class SwitchTypeTest extends TestCase
|
|||||||
}
|
}
|
||||||
}',
|
}',
|
||||||
],
|
],
|
||||||
|
'dontResolveTypesBadly' => [
|
||||||
|
'<?php
|
||||||
|
$a = new A;
|
||||||
|
|
||||||
|
switch (rand(0,1)) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
$dt = $a->maybeReturnsDT();
|
||||||
|
if (!is_null($dt)) {
|
||||||
|
$dt = $dt->format(\DateTime::ISO8601);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
public function maybeReturnsDT(): ?\DateTimeInterface {
|
||||||
|
return rand(0,1) ? new \DateTime("now") : null;
|
||||||
|
}
|
||||||
|
}',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user