Skip to content

Commit b1760a7

Browse files
committed
feat: Handle case when preg_split returns false
1 parent 307cf54 commit b1760a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/Type/Php/PregSplitDynamicReturnTypeExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use PHPStan\Type\StringType;
2727
use PHPStan\Type\Type;
2828
use PHPStan\Type\TypeCombinator;
29+
use PHPUnit\Framework\Assert;
2930
use function count;
3031
use function is_array;
3132
use function is_int;
@@ -157,6 +158,9 @@ public function getTypeFromFunctionCall(FunctionReflection $functionReflection,
157158
foreach ($limits as $limit) {
158159
foreach ($flags as $flag) {
159160
$result = @preg_split($patternConstantType->getValue(), $subjectConstantType->getValue(), (int) $limit, (int) $flag);
161+
if ($result === false) {
162+
return new ErrorType();
163+
}
160164
$constantArray = ConstantArrayTypeBuilder::createEmpty();
161165
foreach ($result as $key => $value) {
162166
if (is_array($value)) {

0 commit comments

Comments
 (0)