Skip to content

Commit

Permalink
Utilize Type->isString() (#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Nov 15, 2022
1 parent 04257d3 commit 1b236c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private function isScalarType(Type $type): bool
return true;
}

return $type instanceof BooleanType || $type instanceof StringType || $type instanceof IntegerType || $type instanceof FloatType;
return $type instanceof BooleanType || $type->isString()->yes() || $type instanceof IntegerType || $type instanceof FloatType;
}

private function isAlwaysTruableUnionType(Type $type): bool
Expand Down
16 changes: 1 addition & 15 deletions packages/NodeTypeResolver/TypeAnalyzer/StringTypeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ public function __construct(
public function isStringOrUnionStringOnlyType(Expr $expr): bool
{
$nodeType = $this->nodeTypeResolver->getType($expr);
if ($nodeType instanceof StringType) {
return true;
}

if ($nodeType instanceof UnionType) {
foreach ($nodeType->getTypes() as $singleType) {
if ($singleType->isSuperTypeOf(new StringType())->no()) {
return false;
}
}

return true;
}

return false;
return $nodeType->isString()->yes();
}
}

0 comments on commit 1b236c8

Please sign in to comment.