Skip to content

Commit c386c2b

Browse files
committed
Updated coding standard
1 parent adf4cf1 commit c386c2b

File tree

6 files changed

+32
-27
lines changed

6 files changed

+32
-27
lines changed

Diff for: build.xml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<arg value="--extensions=php"/>
4545
<arg value="--encoding=utf-8"/>
4646
<arg value="--tab-width=4"/>
47-
<arg value="--ignore=tests/*/data"/>
4847
<arg value="-sp"/>
4948
<arg path="src"/>
5049
<arg path="tests"/>

Diff for: composer.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"phpstan/phpstan": "^0.10"
1515
},
1616
"require-dev": {
17-
"consistence/coding-standard": "^2.0.0",
18-
"jakub-onderka/php-parallel-lint": "^0.9.2",
17+
"consistence/coding-standard": "^3.0.1",
18+
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
19+
"jakub-onderka/php-parallel-lint": "^1.0",
1920
"phing/phing": "^2.16.0",
2021
"phpstan/phpstan-phpunit": "^0.10",
2122
"phpunit/phpunit": "^7.0",
22-
"slevomat/coding-standard": "^3.3.0"
23+
"slevomat/coding-standard": "^4.5.2"
2324
},
2425
"autoload": {
2526
"psr-4": {

Diff for: phpcs.xml

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
<?xml version="1.0"?>
2-
<ruleset name="PHPStan">
2+
<ruleset name="PHPStan strict rules">
33
<rule ref="vendor/consistence/coding-standard/Consistence/ruleset.xml">
44
<exclude name="Squiz.Functions.GlobalFunction.Found"/>
5-
</rule>
6-
<rule ref="vendor/slevomat/coding-standard/SlevomatCodingStandard/ruleset.xml">
7-
<exclude name="SlevomatCodingStandard.Files.TypeNameMatchesFileName"/>
85
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameAfterKeyword"/>
9-
<exclude name="SlevomatCodingStandard.Namespaces.UseOnlyWhitelistedNamespaces"/>
6+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
7+
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
108
<exclude name="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly"/>
11-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
12-
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
13-
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation.NonFullyQualifiedClassName"/>
14-
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalConstants"/>
15-
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedGlobalFunctions"/>
169
</rule>
1710
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
1811
<properties>
@@ -32,4 +25,18 @@
3225
"/>
3326
</properties>
3427
</rule>
28+
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
29+
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
30+
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
31+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
32+
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
33+
<!-- <rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
34+
<!-- <rule ref="SlevomatCodingStandard.Namespaces.RequireOneNamespaceInFile"/> -->
35+
<!-- <rule ref="SlevomatCodingStandard.PHP.ShortList"/> -->
36+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
37+
<properties>
38+
<property name="rootNamespaces" type="array" value="src=>PHPStan,tests=>PHPStan"/>
39+
</properties>
40+
</rule>
41+
<exclude-pattern>tests/*/data</exclude-pattern>
3542
</ruleset>

Diff for: src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
class DynamicCallOnStaticMethodsRule implements \PHPStan\Rules\Rule
1212
{
1313

14-
/**
15-
* @var \PHPStan\Rules\RuleLevelHelper
16-
*/
14+
/** @var \PHPStan\Rules\RuleLevelHelper */
1715
private $ruleLevelHelper;
1816

1917
public function __construct(RuleLevelHelper $ruleLevelHelper)

Diff for: src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ public function processNode(\PhpParser\Node $node, \PHPStan\Analyser\Scope $scop
3333
}
3434

3535
$caseType = $scope->getType($case->cond);
36-
if ($conditionType->isSuperTypeOf($caseType)->no()) {
37-
$messages[] = sprintf(
38-
'Switch condition type (%s) does not match case condition %s (%s).',
39-
$conditionType->describe(),
40-
$this->printer->prettyPrintExpr($case->cond),
41-
$caseType->describe()
42-
);
36+
if (!$conditionType->isSuperTypeOf($caseType)->no()) {
37+
continue;
4338
}
39+
40+
$messages[] = sprintf(
41+
'Switch condition type (%s) does not match case condition %s (%s).',
42+
$conditionType->describe(),
43+
$this->printer->prettyPrintExpr($case->cond),
44+
$caseType->describe()
45+
);
4446
}
4547

4648
return $messages;

Diff for: tests/Rules/StrictCalls/DynamicCallOnStaticMethodsRuleTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
class DynamicCallOnStaticMethodsRuleTest extends \PHPStan\Testing\RuleTestCase
99
{
1010

11-
/**
12-
* @var bool
13-
*/
11+
/** @var bool */
1412
private $checkThisOnly;
1513

1614
protected function getRule(): Rule

0 commit comments

Comments
 (0)