Skip to content

Commit

Permalink
Merge pull request #8692 from weirdan/fix-8602
Browse files Browse the repository at this point in the history
Fixes #8602
  • Loading branch information
weirdan committed Nov 11, 2022
2 parents 6faf4c9 + d122cef commit 55933a5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Expand Up @@ -811,6 +811,7 @@ private function inferPropertyTypeFromConstructor(
}

$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;
Expand Down
26 changes: 26 additions & 0 deletions tests/ClassTest.php
Expand Up @@ -372,6 +372,32 @@ function foo(string $a_class) : void {
}
}',
],
'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 {
Expand Down

0 comments on commit 55933a5

Please sign in to comment.