-
Notifications
You must be signed in to change notification settings - Fork 588
Keep property fetches on the receiver when a static method or static closure invalidates it #6391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
staabm
merged 10 commits into
phpstan:2.3.x
from
phpstan-bot:create-pull-request/patch-khmowo9
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
91db796
Keep property fetches on the receiver when a static method or static …
staabm e6a37d8
Update FuncCallScopeEffectsHelper.php
staabm 40e4325
Test static method invoked via static:: (late static binding)
phpstan-bot a0eb0f9
Invalidate object arguments of an impure static closure
phpstan-bot f7a3ba8
Document that reaching the object through static state is not tracked
phpstan-bot 69b43a5
Test $this passed as an argument into a method call and a static call
phpstan-bot e69bfaa
Test a resource argument passed to an impure static closure
phpstan-bot 4df96db
Bump expected turbo version
phpstan-bot 1fc3bac
Invalidate the receiver when a static closure writes through a capture
phpstan-bot a348658
Give the static-closure carve-out up as soon as the closure has a cap…
phpstan-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?php // lint >= 8.0 | ||
|
|
||
| declare(strict_types = 1); | ||
|
|
||
| namespace Bug13735; | ||
|
|
||
| use function PHPStan\Testing\assertType; | ||
|
|
||
| class Bug13735Test | ||
| { | ||
| private ?Foo $foo = null; | ||
|
|
||
| public function testFoo(): void | ||
| { | ||
| $this->foo = new Foo(); | ||
| assertType('Bug13735\Foo', $this->foo); | ||
| self::assertTrue(true); | ||
| assertType('Bug13735\Foo', $this->foo); | ||
| } | ||
|
|
||
| public static function assertTrue(mixed $condition, string $message = ''): void | ||
| { | ||
|
|
||
| } | ||
| } | ||
|
|
||
| class Foo { | ||
| public ?Foo $inner = null; | ||
|
|
||
| public function doSomething(): bool { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| class Test | ||
| { | ||
| private string $data; | ||
|
|
||
| public function __construct() { | ||
| $this->data = 'abc'; | ||
| assertType("'abc'", $this->data); | ||
| self::noop('foo'); | ||
| assertType("'abc'", $this->data); | ||
| } | ||
|
|
||
| static final public function noop(string $message): void { | ||
| file_put_contents('log file', $message); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| final class FinalTest | ||
| { | ||
| private string $data; | ||
|
|
||
| public function __construct() { | ||
| $this->data = 'abc'; | ||
| assertType("'abc'", $this->data); | ||
| self::noop('foo'); | ||
| assertType("'abc'", $this->data); | ||
| } | ||
|
|
||
| static public function noop(string $message): void { | ||
| file_put_contents('log file', $message); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| final class PrivateTest | ||
| { | ||
| private string $data; | ||
|
|
||
| public function __construct() { | ||
| $this->data = 'abc'; | ||
| assertType("'abc'", $this->data); | ||
| self::noop('foo'); | ||
| assertType("'abc'", $this->data); | ||
| } | ||
|
|
||
| static private function noop(string $message): void { | ||
| file_put_contents('log file', $message); | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.