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
Enhancement: Implement InstanceofStrategy #100
Enhancement: Implement InstanceofStrategy #100
Conversation
d853835
to
d8350d8
Compare
fb53040
to
3955714
Compare
$class = $node->class; | ||
|
||
return [ | ||
$class->toString(), |
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.
Should this method return an array of class names or an array of namespace names?
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.
This should be the FQN of the class.
The method name is changed in #89 to extractSymbolNames
which is more fitting.
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.
based on this question I am trying to improve phpdocs to make these point clear:
d39533e
to
3e0f239
Compare
For me absolutely 👍 |
3e0f239
to
e256078
Compare
Same for me 👍 |
], | ||
'Instanceof' => [ | ||
'expectedUseNamespaces' => [ | ||
'Bar\Baz', |
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.
This makes the tests pass, but this should be Foo\Bar\Baz
as well.
Do you have an idea how to resolve the absolute class name from the relative class name Bar\Baz
, @icanhazstring?
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 did something similar in #89.
https://github.com/composer-unused/composer-unused/pull/89/files#diff-0e5fd3b0f38e3517fafece6f83d2ef2b5af2256f267e53a53db137a2746856b3R29
Basically, you enter the file, save the namespace, and go further in the AST.
I think you can check for isFullyQualified
on the $node
and prepend the namespace.
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.
Ah I see what you are doing.
Maybe you even found a bug that is pretty old ;)
I think the problem is that "relative" symbols are not parsed correctly.
As they are not combined with a partial import.
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.
Shall I comment this case out for now, then?
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.
Shall I comment this case out for now, then?
Yes, and if you don't mind you could then also create a new issue for this, so maybe I can give it a try next week :)
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.
Hmm, commenting out passes this tests, but does not solve the problem @OskarStark and I have.
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.
Hm. Maybe we should let this PR open to support instanceof
recognition and try to fix the underlying bug with partial imports respectively relative class names.
After this is fixed, your test should work.
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.
Hmm, commenting out passes this tests, but does not solve the problem @OskarStark and I have.
I mean I can for now use the FQCN instead of a partial one 🤔
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.
Either way, it should be fixed 😉
But if that solves your problem, for now, I would merge this PR and see If we can fix this afterward.
cc57eea
to
91f1cf0
Compare
91f1cf0
to
74a8692
Compare
Thank you, @icanhazstring! |
Merged and tagged with 0.7.5. Thanks 👍 |
All Submissions:
New Feature Submissions:
Changes to Core Features:
@OskarStark and I ran into an issue in a project that requires
psr/http-message
, and where we useHowever, running
results in
psr/http-message
not being used, so I figured I take a look.Does that make sense?