File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 5050use PHPStan \Node \Printer \ExprPrinter ;
5151use PHPStan \Node \PropertyAssignNode ;
5252use PHPStan \Parser \ArrayMapArgVisitor ;
53- use PHPStan \Parser \ImmediatelyInvokedClosureVisitor ;
5453use PHPStan \Parser \NewAssignedToPropertyVisitor ;
5554use PHPStan \Parser \Parser ;
5655use 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 ()
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments