Skip to content

Commit d020927

Browse files
committed
fix cleanup loop
1 parent d48a512 commit d020927

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/Type/Php/PregSplitDynamicReturnTypeExtension.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,33 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
6868
return new ErrorType();
6969
}
7070

71+
$limits = [];
7172
if ($limitArg === null) {
7273
$limits = [-1];
7374
} else {
7475
$limitType = $scope->getType($limitArg->value);
75-
$limits = $limitType->getConstantScalarValues();
76+
foreach ($limitType->getConstantScalarValues() as $limit) {
77+
if (!is_int($limit)) {
78+
return new ErrorType();
79+
}
80+
$limits[] = $limit;
81+
}
7682
}
7783

84+
$flags = [];
7885
if ($flagArg === null) {
7986
$flags = [0];
8087
} else {
8188
$flagType = $scope->getType($flagArg->value);
82-
$flags = $flagType->getConstantScalarValues();
89+
foreach ($flagType->getConstantScalarValues() as $flag) {
90+
if (!is_int($flag)) {
91+
return new ErrorType();
92+
}
93+
$flags[] = $flag;
94+
}
8395
}
8496

97+
8598
if (count($patternConstantTypes) === 0 || count($subjectConstantTypes) === 0) {
8699
$returnNonEmptyStrings = $flagArg !== null && $this->bitwiseFlagAnalyser->bitwiseOrContainsConstant($flagArg->value, $scope, 'PREG_SPLIT_NO_EMPTY')->yes();
87100
if ($returnNonEmptyStrings) {
@@ -136,13 +149,7 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
136149
foreach ($patternConstantTypes as $patternConstantType) {
137150
foreach ($subjectConstantTypes as $subjectConstantType) {
138151
foreach ($limits as $limit) {
139-
if (!is_int($limit)) {
140-
return null;
141-
}
142152
foreach ($flags as $flag) {
143-
if (!is_int($flag)) {
144-
return null;
145-
}
146153
$result = @preg_split($patternConstantType->getValue(), $subjectConstantType->getValue(), $limit, $flag);
147154
if ($result === false) {
148155
continue;

0 commit comments

Comments
 (0)