Skip to content

Commit

Permalink
[NodeTypeCorrector] Directly use StringType on Intersection of string…
Browse files Browse the repository at this point in the history
…s on AccessoryNonEmptyStringTypeCorrector (#5933)

* [NodeTypeCorrector] Directly use StringType on Intersection of strings on AccessoryNonEmptyStringTypeCorrector

* [ci-review] Rector Rectify

---------

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
samsonasik and actions-user committed Jun 1, 2024
1 parent 564992f commit 6b69971
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

namespace Rector\NodeTypeResolver\NodeTypeCorrector;

use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
use PHPStan\Type\StringType;
use PHPStan\Type\IntersectionType;
use PHPStan\Type\Type;

Expand All @@ -21,23 +20,6 @@ public function correct(Type $mainType): Type | IntersectionType
return $mainType;
}

$clearIntersectionedTypes = [];
foreach ($mainType->getTypes() as $intersectionedType) {
if ($intersectionedType instanceof AccessoryNonEmptyStringType) {
continue;
}

if ($intersectionedType instanceof AccessoryNonFalsyStringType) {
continue;
}

$clearIntersectionedTypes[] = $intersectionedType;
}

if (count($clearIntersectionedTypes) === 1) {
return $clearIntersectionedTypes[0];
}

return new IntersectionType($clearIntersectionedTypes);
return new StringType();
}
}

0 comments on commit 6b69971

Please sign in to comment.