-
Notifications
You must be signed in to change notification settings - Fork 39
[OptimizeUse] Implemented feature optimize use #25
Conversation
change acme in feature to bar
OptimizeUse: uses the new features from NameScanner to implement
|
); | ||
} | ||
|
||
public function testRegressionFindNamesDetectsFQCNCorrectly() { |
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.
wrap {
please
this is way to much anchored in my tiping-fingers :) I think that were all non wrapped braces. To change the constructors to non optional does not look very complicated. And the getters without get, too. |
@pscheit I refactored the Fix Class Names alot today, which makes this PR unmergable due to conflicts, some work needs to be done. My Idea is, in the new |
allright. That was my first attempt to do this as well. But I thought about multi-line-use statements at the top of the file. And for the optimize use I have to append single line use statements at the end of the use statements. That's why I created the more flexible parent instance. Because the PhpName can be in the multi-line-statement over more than one line. |
@pscheit yes, its true with the multi-line use statements. but the problematic kind would be:
And this one is undetectable anyways i would suppose and an edge case. Everything else works fine, finding the last use statement and adding a new line. |
Why isn't it detectable? I think PHPParser is providing the start + endline of the multi line statement (even, when the ; is in the next line) |
@pscheit starting to realize that i need this information myself for the fix-class-names refactoring, just wait a little longer and you get more and more code to use ;-) |
hehe allright. I would have tried to talk you into using the parent property anyway these days |
@pscheit Merged this into my latest master with the fixes for fix-class-names and integrated the current API with this patch. Its working great. Thanks for the contribution! |
hey, cool that you got managed to merge it in the end. I had no time to have a further look at it, but i planned to do so. Great that its working. |
Hi there,
this is my first try at the "optimize use" (-statements) from the roadmap.
I had to extend the Namescanner to collect informations about the parent, because I had to differentiate between PhpNames that are in use statements and are just somewhere in the (class-)file. I wasn't quite sure to extend it here, or create another name scanner function or collector.
Thats why I added a parent property to the PhpName and had to adjust the tests.
While contributing some questions came up, that I can't find a guideline for:
PhpClass::getDeclaredNamespaceLine
vsPhpName::fullyQualifiedName()
)"constant" === $variable
like in Symfony or does it matter at all?Best regards
Philipp