tlint
tlint copied to clipboard
`AlphabeticalImports` reports imported functions at the end as not alphabetically sorted
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?
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 use
d separately: https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements.
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.
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;
Good to know, thanks 👍🏻
For me to reference later:
- Related to blank line https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/6365
- Add to standards