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

AlphabeticalImports reports imported functions at the end as not alphabetically sorted #290

Closed
Gummibeer opened this issue Apr 27, 2022 · 5 comments · Fixed by tighten/duster#43

Comments

@Gummibeer
Copy link
Contributor

use Closure;
use Illuminate\Http\Request;
use Sentry\State\Scope;
use function Sentry\configureScope;

This is reported by the AlphabeticalImports rule - I assume that it's because of the imported function at the end!? Is this intended? So should the function be imported between the classes to be alphabetical?

@bakerkretzmar
Copy link
Contributor

Interesting. To fix the lint, yes, function namespaces and names should be sorted alphabetically mixed in with classes. Not sure what we actually want here though.

Does adding a blank line between the class and function use statements make the lint go away? Apparently under PSR-12 they should actually be used separately: https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements.

@Gummibeer
Copy link
Contributor Author

We've worked around it by using the container binding instead of global helper function. 🙈
So no real issue for us anymore. And you are absolutely right that there should be a spacing line between the import types.

Will give it try with the spacing line.

@Gummibeer
Copy link
Contributor Author

Okay, spacing line doesn't help.

use Closure;
use Illuminate\Http\Request;
use Sentry\State\HubInterface;
use Sentry\State\Scope;

use function Sentry\configureScope;

! Imports should be ordered alphabetically.
5 : use Closure;

@bakerkretzmar
Copy link
Contributor

Good to know, thanks 👍🏻

@driftingly
Copy link
Member

For me to reference later:

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

Successfully merging a pull request may close this issue.

3 participants