Skip to content

Commit

Permalink
Updated coding standard that can run on PHP 7.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk authored and ondrejmirtes committed Oct 22, 2020
1 parent 774d190 commit 4ef28a7
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -11,15 +11,15 @@
},
"require-dev": {
"beberlei/assert": "^2.9.5",
"consistence/coding-standard": "^3.0.1",
"consistence/coding-standard": "^3.10",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"ergebnis/composer-normalize": "^2.0.2",
"phing/phing": "^2.16.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/phpstan-phpunit": "^0.12.3",
"phpstan/phpstan-strict-rules": "^0.12",
"phpunit/phpunit": "^7.5.18",
"slevomat/coding-standard": "^4.5.2"
"slevomat/coding-standard": "^6.4"
},
"config": {
"sort-packages": true
Expand Down
16 changes: 14 additions & 2 deletions phpcs.xml
Expand Up @@ -17,7 +17,7 @@
<property name="newlinesCountBetweenOpenTagAndDeclare" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration">
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<property name="usefulAnnotations" type="array" value="
@dataProvider,
Expand All @@ -28,8 +28,20 @@
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<property name="enableObjectTypeHint" value="false"/>
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
Expand Down
8 changes: 6 additions & 2 deletions src/Type/BeberleiAssert/AssertHelper.php
Expand Up @@ -129,7 +129,9 @@ function (Type $type): Type {
return TypeCombinator::removeNull($type);
}
);
} elseif ($assertName === 'notIsInstanceOf') {
}

if ($assertName === 'notIsInstanceOf') {
$classType = $scope->getType($args[1]->value);
if (!$classType instanceof ConstantStringType) {
return new SpecifiedTypes([], []);
Expand All @@ -144,7 +146,9 @@ function (Type $type) use ($objectType): Type {
return TypeCombinator::remove($type, $objectType);
}
);
} elseif ($assertName === 'notSame') {
}

if ($assertName === 'notSame') {
$valueType = $scope->getType($args[1]->value);
return self::arrayOrIterable(
$typeSpecifier,
Expand Down
Expand Up @@ -33,7 +33,9 @@ public function getTypeFromStaticMethodCall(\PHPStan\Reflection\MethodReflection
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
if ($methodReflection->getName() === 'thatNullOr') {
return $type->toNullOr();
} elseif ($methodReflection->getName() === 'thatAll') {
}

if ($methodReflection->getName() === 'thatAll') {
return $type->toAll();
}

Expand Down
Expand Up @@ -36,7 +36,9 @@ public function getTypeFromFunctionCall(
$type = new AssertThatType($valueExpr, $scope->getType($valueExpr));
if ($functionReflection->getName() === 'Assert\\thatNullOr') {
return $type->toNullOr();
} elseif ($functionReflection->getName() === 'Assert\\thatAll') {
}

if ($functionReflection->getName() === 'Assert\\thatAll') {
return $type->toAll();
}

Expand Down
Expand Up @@ -32,7 +32,9 @@ public function getTypeFromMethodCall(

if ($methodReflection->getName() === 'all') {
return $type->toAll();
} elseif ($methodReflection->getName() === 'nullOr') {
}

if ($methodReflection->getName() === 'nullOr') {
return $type->toNullOr();
}

Expand Down

0 comments on commit 4ef28a7

Please sign in to comment.