Problem/Motivation

In general, having an unused use statement in a class or file doesn't have any impact on the code; it simply provides an alias that ends up not being used. However, this is slightly bad for developer experience, since it suggests to the developer that there is a dependency when there actually isn't. Use statement changes also create unneeded merge conflicts that git can't resolve generally.

Proposed resolution

Remove all the unused use statements in a single patch.

Remaining tasks

Create a single patch that removes all unused use statements from core. The patch should be created and committed during the RC phase to make the cleanup while minimizing disruption.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

For reference https://www.jetbrains.com/phpstorm/help/optimizing-imports.html will help to file the patch.

mgifford’s picture

darrenwh’s picture

Hi,
I use Netbeans and there is inbuilt functionality to do this https://blogs.oracle.com/netbeansphp/entry/how_to_fix_your_use
D

alexpott’s picture

Status: Postponed » Needs review
FileSize
300.96 KB

Preparing this patch so it can go in first thing after the RC 1 release. 564 files changed, 3 insertions(+), 877 deletions(-) :D

alexpott’s picture

Missed a few.

PHPStorm can now not find a single missing use statement.

cosmicdreams’s picture

Status: Needs review » Reviewed & tested by the community

Wow, it's great that we have all these tests right? That's a lot of files that are being touched. I downloaded the patch and searched for more use statements to remove and couldn't find any.

RTBC from me.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 8b65164 on 8.0.x
    Issue #2533800 by alexpott: Remove all unused use statements from core
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.