Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of #2571965: [meta] Fix PHP coding standards in core
Remove all unused use statements and enable the rule.
To test the patches run phpcs -p --sniffs=Drupal.Classes.UnusedUseStatement
from the core directory.
Comment | File | Size | Author |
---|---|---|---|
#28 | 2674408.28.patch | 576 bytes | alexpott |
#22 | 2674408.22.patch | 561 bytes | alexpott |
#19 | 2674408-19.patch | 76.82 KB | alexpott |
#19 | 17-19-interdiff.txt | 14.37 KB | alexpott |
#17 | 2674408-17.patch | 62.45 KB | alexpott |
Comments
Comment #2
alexpottComment #4
alexpottHmm... so the "Drupal.Classes.UnusedUseStatement" has some problems...
Comment #5
alexpottCreated #2674598: UnusedUseStatement sniff must not be case sensitive for the false positives because of case sensitivity.
Comment #7
alexpottRebased and found a couple more after.
Comment #8
alexpottRerolled due to #2666172: PHPCS configuration should include rules and not exclude them
Comment #10
alexpottRerolled and re-ran phpcs to fix the rule - plenty of new instances being added to core all the time :(
Comment #13
alexpottThis will need to be rerolled for 8.1.x...
Comment #14
alexpottSo #10 passes on 8.2.x - to test this run
phpcs -p --sniffs=Drupal.Classes.UnusedUseStatement
from the core directory.Comment #15
alexpottDue to a revert against 8.2.x this patch needs a reroll - patch might apply to both 8.2.x and 8.1.x now :)
Comment #16
dawehnerWent through all classes.
This class is unused
Comment #17
alexpottGreat spot PHPStorm ;) Need to file a bug against coder.
@dawehner++
Comment #18
dawehnerThere we go!
Comment #19
alexpottI fixed the PHPCS rule in #2685877: Drupal.Classes.UnusedUseStatement misses some and ran it again...
Comment #20
dawehnerOh wow, yeah all of those instances have been caused by myself quite recently.
Comment #21
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!
Comment #22
alexpottA very small followup cause one got introduced and I don't think we should have a yet-another-unused-use-removal issue.
Comment #23
bojanz CreditAttribution: bojanz at Centarro commentedBoom.
Comment #24
catchCommitted/pushed to 8.2.x and cherry-picked to 8.1.x. Thanks!
Comment #28
alexpottOne more crept in...
I'm not opening a new issue because I don;t want additional review credit for this.
Comment #29
dawehner+1
Comment #30
alexpottCommitted 93f9d84 and pushed to 8.1.x and 8.2.x. Thanks!
Comment #33
alexpott#2686207: Convert simpletest kernel tests in modules A-I to phpunit introduced a load more and because #2685877: Drupal.Classes.UnusedUseStatement misses some has not yet been released I missed them when I reviewed...
Comment #35
alexpottDrupalCI had a hiccup.
Comment #36
alexpottRerolled and now it applies to both 8.1.x and 8.2.x.
Comment #37
dawehnerSo many real life usecases!
Comment #38
BerdirLooks good.
It's a bit annoying that you end up with those left-overs as phpstorm adds them when you move a class around but doesn't remove it when you add them back into the same namespac.
Comment #39
alexpottCommitted f33830d and pushed to 8.1.x and 8.2.x. Thanks!
Comment #42
JimmyAx CreditAttribution: JimmyAx commentedIt looks like this commit is somehow breaking my site.
#2716827: OptionsProviderInterface::class is causing a fatal error