Skip to content

Commit 4ef28a7

Browse files
ruudkondrejmirtes
authored andcommitted
Updated coding standard that can run on PHP 7.4
1 parent 774d190 commit 4ef28a7

6 files changed

+31
-9
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
},
1212
"require-dev": {
1313
"beberlei/assert": "^2.9.5",
14-
"consistence/coding-standard": "^3.0.1",
14+
"consistence/coding-standard": "^3.10",
1515
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
1616
"ergebnis/composer-normalize": "^2.0.2",
1717
"phing/phing": "^2.16.0",
1818
"php-parallel-lint/php-parallel-lint": "^1.2",
1919
"phpstan/phpstan-phpunit": "^0.12.3",
2020
"phpstan/phpstan-strict-rules": "^0.12",
2121
"phpunit/phpunit": "^7.5.18",
22-
"slevomat/coding-standard": "^4.5.2"
22+
"slevomat/coding-standard": "^6.4"
2323
},
2424
"config": {
2525
"sort-packages": true

phpcs.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
1818
</properties>
1919
</rule>
20-
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
20+
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
2121
<properties>
2222
<property name="usefulAnnotations" type="array" value="
2323
@dataProvider,
@@ -28,8 +28,20 @@
2828
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
2929
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
3030
</rule>
31+
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
32+
<properties>
33+
<property name="enableNativeTypeHint" value="false"/>
34+
</properties>
35+
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
36+
</rule>
37+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
38+
<properties>
39+
<property name="enableObjectTypeHint" value="false"/>
40+
</properties>
41+
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
42+
</rule>
3143
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
32-
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
44+
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
3345
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
3446
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
3547
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>

src/Type/BeberleiAssert/AssertHelper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ function (Type $type): Type {
129129
return TypeCombinator::removeNull($type);
130130
}
131131
);
132-
} elseif ($assertName === 'notIsInstanceOf') {
132+
}
133+
134+
if ($assertName === 'notIsInstanceOf') {
133135
$classType = $scope->getType($args[1]->value);
134136
if (!$classType instanceof ConstantStringType) {
135137
return new SpecifiedTypes([], []);
@@ -144,7 +146,9 @@ function (Type $type) use ($objectType): Type {
144146
return TypeCombinator::remove($type, $objectType);
145147
}
146148
);
147-
} elseif ($assertName === 'notSame') {
149+
}
150+
151+
if ($assertName === 'notSame') {
148152
$valueType = $scope->getType($args[1]->value);
149153
return self::arrayOrIterable(
150154
$typeSpecifier,

src/Type/BeberleiAssert/AssertThatDynamicMethodReturnTypeExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public function getTypeFromStaticMethodCall(\PHPStan\Reflection\MethodReflection
3333
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
3434
if ($methodReflection->getName() === 'thatNullOr') {
3535
return $type->toNullOr();
36-
} elseif ($methodReflection->getName() === 'thatAll') {
36+
}
37+
38+
if ($methodReflection->getName() === 'thatAll') {
3739
return $type->toAll();
3840
}
3941

src/Type/BeberleiAssert/AssertThatFunctionDynamicReturnTypeExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public function getTypeFromFunctionCall(
3636
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
3737
if ($functionReflection->getName() === 'Assert\\thatNullOr') {
3838
return $type->toNullOr();
39-
} elseif ($functionReflection->getName() === 'Assert\\thatAll') {
39+
}
40+
41+
if ($functionReflection->getName() === 'Assert\\thatAll') {
4042
return $type->toAll();
4143
}
4244

src/Type/BeberleiAssert/AssertionChainDynamicReturnTypeExtension.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public function getTypeFromMethodCall(
3232

3333
if ($methodReflection->getName() === 'all') {
3434
return $type->toAll();
35-
} elseif ($methodReflection->getName() === 'nullOr') {
35+
}
36+
37+
if ($methodReflection->getName() === 'nullOr') {
3638
return $type->toNullOr();
3739
}
3840

0 commit comments

Comments
 (0)