Skip to content
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

Not removing unused import if has same name function #3020

Closed
abhimanyu003 opened this issue Sep 5, 2017 · 3 comments · Fixed by #5720
Closed

Not removing unused import if has same name function #3020

abhimanyu003 opened this issue Sep 5, 2017 · 3 comments · Fixed by #5720
Labels

Comments

@abhimanyu003
Copy link

abhimanyu003 commented Sep 5, 2017

PHP CS Fixer not removing unused import that has the same name as that of the function used somewhere in class.

Sample Code

<?php

namespace App\Controllers;

use App\Api\Controller;
use Zend\Diactoros\Exception;

class ValidationController extends Controller
{
    public function ipSubnet()
    {
        return exception('Something', 404);
    }
}

Expected Code

<?php

namespace App\Controllers;

use App\Api\Controller;
// Remove unused import here

class ValidationController extends Controller
{
    public function ipSubnet()
    {
        return exception('Something', 404);
    }
}

The PHP version you are using:
$ php -v

PHP 7.1.9 (cli) (built: Aug 30 2017 18:58:30) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

PHP CS Fixer version you are using:
$ php-cs-fixer -V

PHP CS Fixer 2.4.0 Silver Gingerbread by Fabien Potencier and Dariusz Ruminski (63661f3)
@keradus
Copy link
Member

keradus commented Sep 5, 2017

Hi. Thanks you for your report 👍
It looks like sth we could improve for sure, happily it's not causing issues for changed code.
Sadly, maintainers here cannot handle all filed issues themselves.
Could you help with it and propose a solution (probably for 2.2 branch) ?

@julienfalque
Copy link
Member

Related: #2814.

@SpacePossum
Copy link
Contributor

it is and it isn't related I think, function imports and class imports are done explicitly so could be checked against, with or without checking comments and/or PHPDocs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants