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.
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
Improving support for anonymous classes #2613
base: master
Are you sure you want to change the base?
Improving support for anonymous classes #2613
Changes from 2 commits
c597a53
5cc2e4d
71bf377
f76d62f
d98a9f8
5e5389a
4889c1c
836d962
8e24b48
f32ad1b
7a53a6b
701944a
8b69ecb
168f3e2
cbeb726
07dd87c
c79260d
f91f1b4
ae72ace
046ff0c
f8044f4
10d4180
202087e
175266d
bc3b1b4
0ea9d3e
14802b4
0ea17a9
f197e6f
e5ff010
c30b479
4f76488
9249c6a
6640629
caa112a
da577f9
011b095
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check failure on line 63 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 69 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 114 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 255 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 256 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 256 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 351 in lib/WorseReflection/Bridge/TolerantParser/Reflection/ReflectionClass.php
GitHub Actions / PHPStan (8.1)
Check failure on line 78 in lib/WorseReflection/Core/Reflection/Collection/ClassLikeReflectionMemberCollection.php
GitHub Actions / PHPStan (8.1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a better way to generate class names as the code is currently duplicated everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHPStan does it like this: https://github.com/dantleech/phpstan-src/blob/f7b89d47cfa1fa636fb571b4315841a9af0e976f/src/Broker/AnonymousClassNameHelper.php#L22-L25
but I don't think this is the correct place to do it.
We can create the reflection class in the resolver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, technically using the line number is not 100% garanteed to be unique but who has two anon classes on the same line. :D
But what you mean with "creating the reflection class in the resolver"? I wanted to try to avoid making a
ReflectionAnonymousClass
class as anon classes should be the same except for their weird name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you are right. A different approach for this would probably make more sense but that would require a lot of refactoring as the
fromNode
function is used quite a lot.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it needs refactoring and would also fix the issue Thomas raised below, but would need to show an example.
Check failure on line 26 in lib/WorseReflection/Core/Reflection/Collection/ReflectionTraitCollection.php
GitHub Actions / PHPStan (8.1)