Skip to content

Commit d068557

Browse files
committed
resolve feedback
Addresses phpstan#3613 (comment)
1 parent e99bf4f commit d068557

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Type/Php/ParseUrlFunctionDynamicReturnTypeExtension.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
132132

133133
private function createAllComponentsReturnType(bool $urlIsLowercase, bool $urlIsUppercase): Type
134134
{
135+
if ($urlIsLowercase && $urlIsUppercase) {
136+
if (
137+
$this->allComponentsTogetherTypeForLowercaseString === null
138+
&& $this->allComponentsTogetherTypeForLowercaseString === null
139+
) {
140+
$returnTypes = [
141+
new ConstantBooleanType(false),
142+
new NullType(),
143+
IntegerRangeType::fromInterval(0, 65535),
144+
new IntersectionType([new StringType(), new AccessoryLowercaseStringType(), new AccessoryUppercaseStringType()]),
145+
$this->createComponentsArray(true, true),
146+
];
147+
148+
$union = TypeCombinator::union(...$returnTypes);
149+
$this->allComponentsTogetherTypeForLowercaseString = $union;
150+
$this->allComponentsTogetherTypeForUppercaseString = $union;
151+
return $union;
152+
}
153+
}
154+
135155
if ($urlIsLowercase) {
136156
if ($this->allComponentsTogetherTypeForLowercaseString === null) {
137157
$returnTypes = [

0 commit comments

Comments
 (0)