From ffff80c1a6d19c0eb81b682c887dd4f0b7c0f80b Mon Sep 17 00:00:00 2001 From: Jaapio Date: Sun, 8 Aug 2021 21:29:16 +0200 Subject: [PATCH] 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. --- src/Utils.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Utils.php b/src/Utils.php index 89da35d..2c544a0 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -15,6 +15,7 @@ namespace phpDocumentor\Reflection; use phpDocumentor\Reflection\Exception\PcreException; +use Webmozart\Assert\Assert; use function preg_last_error; 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 * matched string at offset 0 and its string offset into subject at offset 1. * - * @return array> Returns an array containing substrings of subject + * @return string[] Returns an array containing substrings of subject * split along boundaries matched by pattern * * @throws PcreException @@ -54,6 +55,8 @@ abstract class Utils throw PcreException::createFromPhpError(preg_last_error()); } + Assert::allString($parts); + return $parts; } }