Skip to content

Commit fec2ef6

Browse files
committed
Use TypeCombinator method instead of directly create instance objects
1 parent 90a568f commit fec2ef6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Type/Php/FilterVarDynamicReturnTypeExtension.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@
2121
use PHPStan\Type\FloatType;
2222
use PHPStan\Type\IntegerRangeType;
2323
use PHPStan\Type\IntegerType;
24-
use PHPStan\Type\IntersectionType;
2524
use PHPStan\Type\MixedType;
2625
use PHPStan\Type\NullType;
2726
use PHPStan\Type\StringType;
2827
use PHPStan\Type\Type;
29-
use PHPStan\Type\UnionType;
28+
use PHPStan\Type\TypeCombinator;
3029
use function is_int;
3130
use function sprintf;
3231
use function strtolower;
@@ -161,7 +160,7 @@ public function getTypeFromFunctionCall(
161160
if ($inputType->isNonEmptyString()->yes()
162161
&& $type instanceof StringType
163162
&& !$this->canStringBeSanitized($filterValue, $flagsArg, $scope)) {
164-
$type = new IntersectionType([$type, new AccessoryNonEmptyStringType()]);
163+
$type = TypeCombinator::intersect($type, new AccessoryNonEmptyStringType());
165164
}
166165

167166
if (isset($otherTypes['range'])) {
@@ -183,7 +182,7 @@ public function getTypeFromFunctionCall(
183182
}
184183

185184
if (isset($otherTypes['default']) && $otherTypes['default']->isSuperTypeOf($type)->no()) {
186-
$type = new UnionType([$type, $otherTypes['default']]);
185+
$type = TypeCombinator::union($type, $otherTypes['default']);
187186
}
188187

189188
if ($this->hasFlag($this->getConstant('FILTER_FORCE_ARRAY'), $flagsArg, $scope)) {

0 commit comments

Comments
 (0)