Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4713464

Browse files
committed
fix
1 parent b7395e0 commit 4713464

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;
@@ -3738,7 +3737,6 @@ private function enterAnonymousFunctionWithoutReflection(
37383737
&& $expr->var instanceof Variable
37393738
&& is_string($expr->var->name)
37403739
&& $expr->var->name === 'this'
3741-
&& $closure->getAttribute(ImmediatelyInvokedClosureVisitor::ATTRIBUTE_NAME) === true
37423740
&& !$closure->static
37433741
&& $this->hasVariableType('this')->yes()
37443742
&& $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)

AltStyle によって変換されたページ (->オリジナル) /