Skip to content

Commit a830aa6

Browse files
committed
test static anonyous functions
1 parent 33e8c09 commit a830aa6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Analyser/MutatingScope.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,8 @@ private function enterAnonymousFunctionWithoutReflection(
37443744
&& $expr->var instanceof Variable
37453745
&& is_string($expr->var->name)
37463746
&& $expr->var->name === 'this'
3747+
&& !$closure->static
3748+
&& $this->hasVariableType('this')->yes()
37473749
&& $this->phpVersion->supportsReadOnlyProperties()
37483750
) {
37493751
$propertyReflection = $this->propertyReflectionFinder->findPropertyReflectionFromNode($expr, $this);

tests/PHPStan/Analyser/nsrt/bug-13321.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public function bar(): void
3737
};
3838

3939
$test();
40+
41+
$test = static function () {
42+
assertType('mixed', $this->foo);
43+
assertType('mixed', $this->writableFoo);
44+
45+
echo $this->foo->value;
46+
};
47+
48+
$test();
4049
}
4150

4251
}

0 commit comments

Comments
 (0)