Skip to content

Commit

Permalink
change is_a in CountableAnalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Mar 19, 2021
1 parent 2752f2c commit 22e41e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion rules/Naming/Guard/BreakingVariableRenameGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ private function isDateTimeAtNamingConvention(Param $param): bool

$objectType = new ObjectType('DateTimeInterface');
$isDateTimeInterfaceNotSuperOfType = $objectType->isSuperTypeOf($type)->no();

if ($isDateTimeInterfaceNotSuperOfType) {
return false;
}
Expand Down
10 changes: 6 additions & 4 deletions rules/Php71/NodeAnalyzer/CountableAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 22e41e5

Please sign in to comment.