Skip to content

Commit

Permalink
feat(AlphabeticallySortedUses): Add sniff to check and fix use statem…
Browse files Browse the repository at this point in the history
…ent order (#3310013)
  • Loading branch information
jonathan1055 authored Apr 29, 2023
1 parent 5a1779e commit a40711d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
phpstan: ['0']
# We only need to run PHPStan once on the latest PHP version.
include:
Expand Down
1 change: 1 addition & 0 deletions coder_sniffer/Drupal/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<rule ref="PSR2.Namespaces.UseDeclaration" />

<rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" />
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses" />
<rule ref="SlevomatCodingStandard.PHP.ShortList" />

<rule ref="Squiz.Arrays.ArrayDeclaration" />
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
],
"license": "GPL-2.0-or-later",
"require": {
"php": ">=7.1",
"php": ">=7.2",
"ext-mbstring": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1 || ^1.0.0",
"sirbrillig/phpcs-variable-analysis": "^2.11.7",
"slevomat/coding-standard": "^7.0 || ^8.0",
"slevomat/coding-standard": "^8.11",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/yaml": ">=3.4.0"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/Classes/ClassCreateInstanceUnitTest.inc.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Vendor\DateTools\DateInterval;
use Vendor\DateTools;
use Vendor\DateTools\DateInterval;

$x = array(new Foo(), array());
$y = new Foo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Example.
*/

use Test\MultiLineSecond;
use Test\Foo;
use Test\NotUsed;
use Test\Bar;
use Test\Alias as TestAlias;
use Test\Bar;
use Test\Foo;
use Test\MultiLine as MultiLineAlias;
use Test\MultiLineSecond;
use Test\NotUsed;

/**
* Example.
Expand Down
8 changes: 4 additions & 4 deletions tests/Drupal/Classes/UnusedUseStatementUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace MyNamespace\Depth;

use Thing\NotUsed;
use Thing\Fail\ActuallyUsed;
use Test\TraitTest;
use Thing\DifferentName as UsedOtherName;
use Example\MyUrlHelper;
use MyNamespace\Depth\SomeClass as CoreSomeClass;
use Test\TraitTest;
use Thing\DifferentName as UsedOtherName;
use Thing\Fail\ActuallyUsed;
use Thing\NotUsed;

/**
* Bla.
Expand Down
2 changes: 1 addition & 1 deletion tests/Drupal/Classes/UseGlobalClassUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* Example.
*/

use Namespaced\MultiLine2 as MultiLineAlias2;
use Namespaced\TestClass;
use Namespaced\TestClassSecond as NamespacedAlias;
use Namespaced\MultiLine2 as MultiLineAlias2;
use function count;

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Drupal/good/good.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

declare(strict_types=1);

use Drupal\very_long_module_name_i_am_inventing_here_trololololo\SuperManager;
use Drupal\some_module\ExampleClass as AliasedExampleClass;
use Drupal\mymodule\TestReturnType;
use Drupal\some_module\ExampleClass as AliasedExampleClass;
use Drupal\very_long_module_name_i_am_inventing_here_trololololo\SuperManager;

// Singleline comment before a code line.
$foo = 'bar';
Expand Down

0 comments on commit a40711d

Please sign in to comment.