Skip to content

Commit 7cb9f2c

Browse files
committed
fix
1 parent 6a22dbc commit 7cb9f2c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/Analyser/MutatingScope.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
use PHPStan\Node\Printer\ExprPrinter;
5151
use PHPStan\Node\PropertyAssignNode;
5252
use PHPStan\Parser\ArrayMapArgVisitor;
53-
use PHPStan\Parser\ImmediatelyInvokedClosureVisitor;
5453
use PHPStan\Parser\NewAssignedToPropertyVisitor;
5554
use PHPStan\Parser\Parser;
5655
use PHPStan\Php\PhpVersion;
@@ -3715,7 +3714,6 @@ private function enterAnonymousFunctionWithoutReflection(
37153714
&& $expr->var instanceof Variable
37163715
&& is_string($expr->var->name)
37173716
&& $expr->var->name === 'this'
3718-
&& $closure->getAttribute(ImmediatelyInvokedClosureVisitor::ATTRIBUTE_NAME) === true
37193717
&& !$closure->static
37203718
&& $this->hasVariableType('this')->yes()
37213719
&& $this->phpVersion->supportsReadOnlyProperties()

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public function __construct(
2222

2323
public function bar(): void
2424
{
25+
(function () {
26+
assertType(Foo::class.'|null', $this->foo);
27+
assertType(Foo::class.'|null', $this->writableFoo);
28+
29+
echo $this->foo->value;
30+
})();
31+
2532
if ($this->foo === null) {
2633
return;
2734
}
@@ -37,7 +44,7 @@ public function bar(): void
3744
})();
3845

3946
$test = function () {
40-
assertType(Foo::class.'|null', $this->foo);
47+
assertType(Foo::class, $this->foo);
4148
assertType(Foo::class.'|null', $this->writableFoo);
4249

4350
echo $this->foo->value;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function bar(): void
3232
assertType('non-empty-string', $this->foo->value);
3333

3434
$test = function () {
35-
assertType(Foo::class.'|null', $this->foo);
35+
assertType(Foo::class, $this->foo);
3636
assertType('string', $this->foo->value);
3737
};
3838

0 commit comments

Comments
 (0)