Skip to content

Commit 331e01f

Browse files
committed
Apply comments.
1 parent daa1bd1 commit 331e01f

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎src/Type/Php/FilterFunctionReturnTypeHelper.php‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,12 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
191191
$type = TypeCombinator::intersect($type, $accessory);
192192
}
193193

194-
if ($exactType === null || $hasOptions->maybe() || (!$inputType->equals($type) && $inputType->isSuperTypeOf($type)->yes())) {
195-
// Default type is handled as the exactType when flag FILTER_FLAG_EMPTY_STRING_NULL is set.
196-
if (!$defaultType->isSuperTypeOf($type)->yes() && $this->hasFlag('FILTER_FLAG_EMPTY_STRING_NULL', $flagsType)->no()) {
194+
if (
195+
$exactType === null
196+
|| $hasOptions->maybe()
197+
|| ($this->isValidationFilter($filterValue) && (!$inputType->equals($type) && $inputType->isSuperTypeOf($type)->yes()))
198+
) {
199+
if (!$defaultType->isSuperTypeOf($type)->yes()) {
197200
$type = TypeCombinator::union($type, $defaultType);
198201
}
199202
}
@@ -209,7 +212,7 @@ public function getType(Type $inputType, ?Type $filterType, ?Type $flagsType): T
209212
return new ArrayType($inputArrayKeyType ?? $mixedType, $type);
210213
}
211214

212-
if ($this->isValidationFilter($filterValue) && $this->hasFlag('FILTER_THROW_ON_FAILURE', $flagsType)->yes()) {
215+
if ($this->hasFlag('FILTER_THROW_ON_FAILURE', $flagsType)->yes()) {
213216
$type = TypeCombinator::remove($type, $defaultType);
214217
}
215218

0 commit comments

Comments
 (0)