diff --git a/rules/Naming/Guard/BreakingVariableRenameGuard.php b/rules/Naming/Guard/BreakingVariableRenameGuard.php index 79df34938bbd..5a6cafbc28c9 100644 --- a/rules/Naming/Guard/BreakingVariableRenameGuard.php +++ b/rules/Naming/Guard/BreakingVariableRenameGuard.php @@ -277,7 +277,6 @@ private function isDateTimeAtNamingConvention(Param $param): bool $objectType = new ObjectType('DateTimeInterface'); $isDateTimeInterfaceNotSuperOfType = $objectType->isSuperTypeOf($type)->no(); - if ($isDateTimeInterfaceNotSuperOfType) { return false; } diff --git a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php index c0ca79622c0a..0112e66f3995 100644 --- a/rules/Php71/NodeAnalyzer/CountableAnalyzer.php +++ b/rules/Php71/NodeAnalyzer/CountableAnalyzer.php @@ -9,6 +9,7 @@ use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Stmt; use PHPStan\Reflection\ReflectionProvider; +use PHPStan\Type\ObjectType; use PHPStan\Type\TypeWithClassName; use PHPStan\Type\UnionType; use Rector\NodeNameResolver\NodeNameResolver; @@ -62,11 +63,12 @@ public function isCastableArrayType(Expr $expr): bool return false; } - if (is_a($callerObjectType->getClassName(), Stmt::class, true)) { - return false; - } + $stmtOrArray = new UnionType([ + new ObjectType(Stmt::class), + new ObjectType(Array_::class), + ]); - if (is_a($callerObjectType->getClassName(), Array_::class, true)) { + if ($stmtOrArray->isSuperTypeOf($callerObjectType)->yes()) { return false; }