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

Mark inferred mutation-free constructor as such

Previously Psalm treated those constructors as explicitly mutation-free,
and thus required descendant constructors to be explicitly marked too.

Fixes vimeo/psalm#8602
This commit is contained in:
Bruce Weirdan 2022-11-10 00:12:40 -04:00
parent 410c7bb474
commit d122cef1ca
2 changed files with 27 additions and 0 deletions

View File

@ -811,6 +811,7 @@ class FunctionLikeNodeScanner
}
$storage->external_mutation_free = true;
$storage->mutation_free_inferred = true;
foreach ($assigned_properties as $property_name => $property_type) {
$classlike_storage->properties[$property_name]->type = $property_type;

View File

@ -372,6 +372,32 @@ class ClassTest extends TestCase
}
}',
],
'markInferredMutationFreeDuringPropertyTypeInferenceAsActuallyInferred' => [
'code' => '<?php
class A {}
/**
* @psalm-consistent-constructor
*/
abstract class AbstractClass
{
protected $renderer;
public function __construct(A $r)
{
$this->renderer = $r;
}
}
class ConcreteClass extends AbstractClass
{
public function __construct(A $r)
{
parent::__construct($r);
}
}
',
],
'interfaceExistsCreatesClassString' => [
'code' => '<?php
function funB(string $className) : ?ReflectionClass {