1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #3531 - ignore mixed returns from template

This commit is contained in:
Brown 2020-06-06 10:33:49 -04:00
parent 438eb17e58
commit fcf0a681d9
2 changed files with 28 additions and 0 deletions

View File

@ -289,6 +289,10 @@ class ReturnAnalyzer
return null;
}
if ($local_return_type->isMixed()) {
return null;
}
if (!$context->collect_initializations
&& !$context->collect_mutations
&& $statements_analyzer->getFilePath() === $statements_analyzer->getRootFilePath()

View File

@ -4114,6 +4114,30 @@ class ClassTemplateExtendsTest extends TestCase
takesSubjects($subjects);
}'
],
'implementMixedReturnNull' => [
'<?php
/** @template T */
interface Templated {
/** @return T */
public function foo();
}
class Concrete implements Templated {
private array $t;
public function __construct(array $t) {
$this->t = $t;
}
public function foo() {
if (rand(0, 1)) {
return null;
}
return $this->t;
}
}'
],
];
}