mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 18:13:13 +00:00
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:
+4
-1
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user