Skip to content

Commit ffff80c

Browse files
committed
Resolve psalm return type
The original php method preg_split might return `string[][]` in some situations, however this should never be the case for this library. By adding an extra assert, we should be more safe.
1 parent aa1efc0 commit ffff80c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Utils.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use phpDocumentor\Reflection\Exception\PcreException;
1717

18+
use Webmozart\Assert\Assert;
1819
use function preg_last_error;
1920
use function preg_split as php_preg_split;
2021

@@ -42,7 +43,7 @@ abstract class Utils
4243
* Note that this changes the return value in an array where every element is an array consisting of the
4344
* matched string at offset 0 and its string offset into subject at offset 1.
4445
*
45-
* @return array<int|string, array<int|string, string>> Returns an array containing substrings of subject
46+
* @return string[] Returns an array containing substrings of subject
4647
* split along boundaries matched by pattern
4748
*
4849
* @throws PcreException
@@ -54,6 +55,8 @@ public static function pregSplit(string $pattern, string $subject, int $limit =
5455
throw PcreException::createFromPhpError(preg_last_error());
5556
}
5657

58+
Assert::allString($parts);
59+
5760
return $parts;
5861
}
5962
}

0 commit comments

Comments
 (0)