-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Complete inside class constant declaration #1985
Complete inside class constant declaration #1985
Conversation
I'm not sure if it's the correct logic but first tests suggest that it works. |
'<?php class Foobar { private const FOO; private const BAR = self::F<> }', [ | ||
[ | ||
'type' => Suggestion::TYPE_CONSTANT, | ||
'name' => 'self::FOO', |
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.
Please check if the expectation is correct.
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.
why do you suspect it not to be correct?
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.
At the first I started with name => 'FOO'
- the whole 'self::FOO'
caught my attention.
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, yeah that doesn't seem quite right, did you test it in the editor?
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,
complete-in-class-declaration.mp4
but I found that the new test case checks something that works already on master 😁 so I need to add the proper case before refactoring discussed in the other comment.
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.
@@ -42,6 +43,10 @@ public static function expression(?Node $node): bool | |||
return false; | |||
} | |||
|
|||
if ($parent instanceof ConstElement) { |
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.
think we can move this to the similar expressions in the final return
below?
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.
or is it triggered by classMembersBody somehow?
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.
The final return
is unavailable in this case because of classMembersBody
:
Maybe moving the new condition into classMembersBody()
would be good idea but
- I need to ensure if we expect
true
if the parent of$node
isConstElement
- it's public and used in other places so we need to inspect what will happen then (with the hope that existing tests tests cover enough amount of cases first).
What are you missing ? |
Note that it does not work inside array. I need some free time to fix it again. |
it's a mine field, good luck! |
complete-in-class-declaration-2.mp4Now it's time to return to the question where |
I think it's fine, its not a "query" but just an I've just spent the past 30m trying to stop but I think we can merge this in it's current state as an improvement? |
I agree that at the moment almost accurate suggestion list is better than none and we could merge this PR. Independently it would be good to keep in |
thanks,I updated the changelog and changed the test to simulate something more realistic... |
Closes #1978