-
Notifications
You must be signed in to change notification settings - Fork 574
Handle for infinite loop on recursive trait #5488
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
+70
−3
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2416632
add test for infinite loop on recursive trait
samsonasik 27455a6
keep spacing
samsonasik e175dc4
clean up test
samsonasik 67727b0
remove unused use
samsonasik 35e30bd
fix with detect nested trait
samsonasik 423507d
avoid duplicated class BaseModel to other class
samsonasik 1a0e745
final touch: ensure result test consistent
samsonasik db81623
final touch: fix cs
samsonasik 248527f
final touch: fix phpstan notice on php 7.4
samsonasik eba0376
fix phpstan on php 8+
samsonasik f090089
fix phpstan on php 7.4
samsonasik b6b9117
fix cache concat key
samsonasik 44d4c03
final touch: cs fix
samsonasik 10f93cd
move to AnalyserIntegrationTest and increase cache key
samsonasik 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
31 changes: 31 additions & 0 deletions
31
tests/PHPStan/Type/data/bug-self-referenced-trait/BaseModelUseTrait.php
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,31 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace BugSelfReferencedTrait; | ||
|
|
||
| use BugSelfReferencedTrait\RecursiveTrait; | ||
|
|
||
| class Model | ||
| { | ||
| } | ||
|
|
||
| /** @template TModel of Model */ | ||
| class Builder | ||
| { | ||
| } | ||
|
|
||
| class BelongsTo | ||
| { | ||
| } | ||
|
|
||
| /** | ||
| * @method static Builder<static>|BaseModelUseTrait query() | ||
| */ | ||
| class BaseModelUseTrait extends Model | ||
| { | ||
| use RecursiveTrait; | ||
|
|
||
| public function parent(): BelongsTo | ||
| { | ||
| return new BelongsTo(); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
tests/PHPStan/Type/data/bug-self-referenced-trait/RecursiveTrait.php
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,14 @@ | ||
| <?php declare(strict_types = 1); | ||
|
|
||
| namespace BugSelfReferencedTrait; | ||
|
|
||
| trait RecursiveTrait | ||
| { | ||
| public function getRecursive(): object | ||
| { | ||
| return new class () { | ||
| use RecursiveTrait; | ||
| }; | ||
| } | ||
|
|
||
| } |
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.