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.
This commit is contained in:
Jaapio
2021-08-08 21:32:57 +02:00
parent aa1efc030b
commit ffff80c1a6
+4 -1
View File
@@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection;
use phpDocumentor\Reflection\Exception\PcreException; use phpDocumentor\Reflection\Exception\PcreException;
use Webmozart\Assert\Assert;
use function preg_last_error; use function preg_last_error;
use function preg_split as php_preg_split; use function preg_split as php_preg_split;
@@ -42,7 +43,7 @@ abstract class Utils
* Note that this changes the return value in an array where every element is an array consisting of the * Note that this changes the return value in an array where every element is an array consisting of the
* matched string at offset 0 and its string offset into subject at offset 1. * matched string at offset 0 and its string offset into subject at offset 1.
* *
* @return array<int|string, array<int|string, string>> Returns an array containing substrings of subject * @return string[] Returns an array containing substrings of subject
* split along boundaries matched by pattern * split along boundaries matched by pattern
* *
* @throws PcreException * @throws PcreException
@@ -54,6 +55,8 @@ abstract class Utils
throw PcreException::createFromPhpError(preg_last_error()); throw PcreException::createFromPhpError(preg_last_error());
} }
Assert::allString($parts);
return $parts; return $parts;
} }
} }