Skip to content

Commit a88d888

Browse files
committed
Start using rules from slevomat/coding-standard
1 parent 3d19fe8 commit a88d888

19 files changed

+34
-46
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: "Install dependencies"
3131
run: "composer update --no-progress --prefer-dist"
3232
- name: "PHPCS"
33-
run: "php vendor/bin/phpcs src"
33+
run: "php vendor/bin/phpcs"
3434
- name: "PHPStan"
3535
run: "php vendor/bin/phpstan analyze"
3636
tests:

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"phpstan/phpstan-deprecation-rules": "^1.0",
2626
"phpstan/phpstan-strict-rules": "^1.0",
2727
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.0 || ^9",
28+
"slevomat/coding-standard": "^7.1",
2829
"squizlabs/php_codesniffer": "^3.3",
2930
"symfony/phpunit-bridge": "^3.4.3 || ^4.4 || ^5.4 || ^6.0"
3031
},

phpcs.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Modfied PSR2">
2+
<ruleset name="phpstan-drupal">
3+
<config name="php_version" value="70400"/>
4+
<arg name="colors"/>
5+
<arg name="extensions" value="php"/>
6+
<arg name="encoding" value="utf-8"/>
7+
<arg name="ignore" value="tests/*/data" />
8+
<file>src</file>
9+
<!-- <file>tests/src</file> -->
310
<rule ref="PSR2"/>
411
<!-- The following rules should be kept excluded -->
512
<rule ref="Generic.Files.LineLength.TooLong">
613
<severity>0</severity>
714
</rule>
15+
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
16+
<properties>
17+
<property name="caseSensitive" value="false"/>
18+
<property name="psr12Compatible" value="true"/>
19+
</properties>
20+
</rule>
21+
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>
22+
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
23+
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
24+
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
25+
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
826
</ruleset>

src/Reflection/EntityFieldMethodsViaMagicReflectionExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace mglaman\PHPStanDrupal\Reflection;
44

55
use PHPStan\Reflection\ClassReflection;
6-
use PHPStan\Reflection\MethodsClassReflectionExtension;
76
use PHPStan\Reflection\MethodReflection;
7+
use PHPStan\Reflection\MethodsClassReflectionExtension;
88
use PHPStan\Type\ObjectType;
99

1010
/**

src/Reflection/FieldItemListMethodReflection.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22

33
namespace mglaman\PHPStanDrupal\Reflection;
44

5-
use Drupal\Core\Field\EntityReferenceFieldItemListInterface;
5+
use PHPStan\Reflection\ClassMemberReflection;
66
use PHPStan\Reflection\ClassReflection;
77
use PHPStan\Reflection\MethodReflection;
8-
use PHPStan\Reflection\ClassMemberReflection;
9-
use PHPStan\Reflection\ReflectionProviderStaticAccessor;
108
use PHPStan\Reflection\TrivialParametersAcceptor;
11-
use PHPStan\ShouldNotHappenException;
129
use PHPStan\TrinaryLogic;
13-
use PHPStan\Type\NullType;
14-
use PHPStan\Type\ObjectType;
15-
use PHPStan\Type\StringType;
1610
use PHPStan\Type\Type;
1711

1812
/**
@@ -21,11 +15,9 @@
2115
class FieldItemListMethodReflection implements MethodReflection
2216
{
2317

24-
/** @var ClassReflection */
25-
private $declaringClass;
18+
private ClassReflection $declaringClass;
2619

27-
/** @var string */
28-
private $methodName;
20+
private string $methodName;
2921

3022
public function __construct(ClassReflection $declaringClass, string $methodName)
3123
{

src/Rules/Classes/PluginManagerInspectionRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\ReflectionProvider;
88
use PHPStan\Rules\Rule;
9-
use PHPStan\ShouldNotHappenException;
109
use PHPStan\Type\ObjectType;
1110

1211
/**

src/Rules/Deprecations/AccessDeprecatedConstant.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
7-
use PHPStan\Broker\Broker;
87
use PHPStan\Reflection\FunctionReflection;
98
use PHPStan\Reflection\ReflectionProvider;
109

src/Rules/Deprecations/GetDeprecatedServiceRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace mglaman\PHPStanDrupal\Rules\Deprecations;
44

5-
use PhpParser\Node;
6-
use PHPStan\Analyser\Scope;
75
use mglaman\PHPStanDrupal\Drupal\DrupalServiceDefinition;
86
use mglaman\PHPStanDrupal\Drupal\ServiceMap;
7+
use PhpParser\Node;
8+
use PHPStan\Analyser\Scope;
99
use PHPStan\Rules\Rule;
1010

1111
final class GetDeprecatedServiceRule implements Rule

src/Rules/Deprecations/PluginAnnotationContextDefinitionsRule.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use PhpParser\Node;
66
use PHPStan\Analyser\Scope;
77
use PHPStan\Reflection\ClassReflection;
8-
use PHPStan\Reflection\ReflectionProvider;
98
use PHPStan\ShouldNotHappenException;
109

1110
final class PluginAnnotationContextDefinitionsRule extends DeprecatedAnnotationsRuleBase

src/Rules/Deprecations/StaticServiceDeprecatedServiceRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace mglaman\PHPStanDrupal\Rules\Deprecations;
44

5-
use PhpParser\Node;
6-
use PHPStan\Analyser\Scope;
75
use mglaman\PHPStanDrupal\Drupal\DrupalServiceDefinition;
86
use mglaman\PHPStanDrupal\Drupal\ServiceMap;
7+
use PhpParser\Node;
8+
use PHPStan\Analyser\Scope;
99
use PHPStan\Rules\Rule;
1010

1111
final class StaticServiceDeprecatedServiceRule implements Rule

0 commit comments

Comments
 (0)