Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Apr 24, 2023
1 parent d875bd4 commit 5e1b9ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Flip objectType control from null compare to use exclusive instanceof objectType', [
return new RuleDefinition('Flip type control from null compare to use exclusive instanceof object', [
new CodeSample(
<<<'CODE_SAMPLE'
function process(?DateTime $dateTime)
Expand Down
9 changes: 1 addition & 8 deletions rules/Strict/NodeFactory/ExactCompareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,6 @@ private function collectCompareExprs(UnionType $unionType, Expr $expr, bool $tre
return $compareExprs;
}

private function cleanUpPossibleNullableUnionType(UnionType $unionType): Type
{
return count($unionType->getTypes()) === 2
? TypeCombinator::removeNull($unionType)
: $unionType;
}

/**
* @param array<Identical|BooleanOr|NotIdentical|BooleanAnd|Instanceof_|BooleanNot|null> $compareExprs
*/
Expand Down Expand Up @@ -200,7 +193,7 @@ private function createTruthyFromUnionType(
Expr $expr,
bool $treatAsNonEmpty
): BooleanOr|NotIdentical|Identical|BooleanNot|Instanceof_|BooleanAnd|null {
$unionType = $this->cleanUpPossibleNullableUnionType($unionType);
$unionType = TypeCombinator::removeNull($unionType);

if ($unionType instanceof UnionType) {
$compareExprs = $this->collectCompareExprs($unionType, $expr, $treatAsNonEmpty);
Expand Down

0 comments on commit 5e1b9ab

Please sign in to comment.