Skip to content

Commit

Permalink
[Naming] Reduce instanceof ObjectType on ExpectedNameResolver (take 5) (
Browse files Browse the repository at this point in the history
rectorphp#6423)

* [Naming] Reduce instanceof ObjectType on ExpectedNameResolver

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user authored Nov 12, 2024
1 parent 84bb596 commit 26b8b54
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions rules/Naming/Naming/ExpectedNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function resolveForCall(MethodCall | StaticCall | FuncCall $expr): ?strin
}

$returnedType = $this->nodeTypeResolver->getType($expr);
if (! $returnedType->isObject()->yes()) {
if (! $returnedType instanceof ObjectType) {
return null;
}

Expand Down Expand Up @@ -215,17 +215,13 @@ private function resolveReturnTypeFromArrayType(ArrayType $arrayType): ?Type
/**
* Skip date time, as custom naming
*/
private function isDateTimeType(Type $type): bool
private function isDateTimeType(ObjectType $objectType): bool
{
if (! $type instanceof ObjectType) {
return false;
}

if ($type->isInstanceOf('DateTimeInterface')->yes()) {
if ($objectType->isInstanceOf('DateTimeInterface')->yes()) {
return true;
}

return $type->isInstanceOf('DateTime')
return $objectType->isInstanceOf('DateTime')
->yes();
}
}

0 comments on commit 26b8b54

Please sign in to comment.