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:
parent
438eb17e58
commit
fcf0a681d9
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user