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:
parent
410c7bb474
commit
d122cef1ca
@ -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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user