Skip to content

Commit b9c303a

Browse files
committed
fix cleanup
1 parent a647277 commit b9c303a

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/Type/Php/PregSplitDynamicReturnTypeExtension.php

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php declare(strict_types = 1);
22

33
namespace PHPStan\Type\Php;
44

@@ -87,14 +87,15 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
8787
if ($returnNonEmptyStrings) {
8888
$returnStringType = TypeCombinator::intersect(
8989
new StringType(),
90-
new AccessoryNonEmptyStringType()
90+
new AccessoryNonEmptyStringType(),
9191
);
9292
} else {
9393
$returnStringType = new StringType();
9494
}
9595

9696
$capturedArrayType = new ConstantArrayType(
97-
[new ConstantIntegerType(0), new ConstantIntegerType(1)], [$returnStringType, IntegerRangeType::fromInterval(0, null)],
97+
[new ConstantIntegerType(0), new ConstantIntegerType(1)],
98+
[$returnStringType, IntegerRangeType::fromInterval(0, null)],
9899
[2],
99100
[],
100101
TrinaryLogic::createYes()
@@ -113,9 +114,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
113114
$capturedArrayListType = TypeCombinator::intersect($capturedArrayListType, new NonEmptyArrayType());
114115
}
115116

116-
return TypeUtils::toBenevolentUnion(
117-
TypeCombinator::union($capturedArrayListType, new ConstantBooleanType(false))
118-
);
117+
return TypeUtils::toBenevolentUnion(TypeCombinator::union($capturedArrayListType, new ConstantBooleanType(false)));
119118
}
120119
if ($flagState->maybe()) {
121120
$returnInternalValueType = TypeCombinator::union(new StringType(), $capturedArrayType);
@@ -130,12 +129,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
130129
);
131130
}
132131

133-
return TypeUtils::toBenevolentUnion(
134-
TypeCombinator::union(
135-
$returnListType,
136-
new ConstantBooleanType(false)
137-
)
138-
);
132+
return TypeUtils::toBenevolentUnion(TypeCombinator::union($returnListType, new ConstantBooleanType(false)));
139133
}
140134

141135
$resultTypes = [];
@@ -150,27 +144,29 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
150144
return null;
151145
}
152146
$result = @preg_split($patternConstantType->getValue(), $subjectConstantType->getValue(), $limit, $flag);
153-
if ($result !== false) {
154-
$constantArray = ConstantArrayTypeBuilder::createEmpty();
155-
foreach ($result as $key => $value) {
156-
if (is_array($value)) {
157-
$valueConstantArray = ConstantArrayTypeBuilder::createEmpty();
158-
$valueConstantArray->setOffsetValueType(new ConstantIntegerType(0), new ConstantStringType($value[0]));
159-
$valueConstantArray->setOffsetValueType(new ConstantIntegerType(1), new ConstantIntegerType($value[1]));
160-
$returnInternalValueType = $valueConstantArray->getArray();
161-
} else {
162-
$returnInternalValueType = new ConstantStringType($value);
163-
}
164-
$constantArray->setOffsetValueType(new ConstantIntegerType($key), $returnInternalValueType);
147+
if ($result === false) {
148+
continue;
149+
}
150+
$constantArray = ConstantArrayTypeBuilder::createEmpty();
151+
foreach ($result as $key => $value) {
152+
if (is_array($value)) {
153+
$valueConstantArray = ConstantArrayTypeBuilder::createEmpty();
154+
$valueConstantArray->setOffsetValueType(new ConstantIntegerType(0), new ConstantStringType($value[0]));
155+
$valueConstantArray->setOffsetValueType(new ConstantIntegerType(1), new ConstantIntegerType($value[1]));
156+
$returnInternalValueType = $valueConstantArray->getArray();
157+
} else {
158+
$returnInternalValueType = new ConstantStringType($value);
165159
}
166-
167-
$resultTypes[] = $constantArray->getArray();
160+
$constantArray->setOffsetValueType(new ConstantIntegerType($key), $returnInternalValueType);
168161
}
162+
163+
$resultTypes[] = $constantArray->getArray();
169164
}
170165
}
171166
}
172167
}
173168

174169
return TypeCombinator::union(...$resultTypes);
175170
}
171+
176172
}

0 commit comments

Comments
 (0)