From 155efd647fbc4e1b272cf283caf80af4431257ee Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 1 Aug 2021 01:58:21 +0200 Subject: [PATCH] Utils::pregSplit: limit is not nullable Correctly flagged by Psalm: ``` ERROR: PossiblyNullArgument - src\Utils.php:50:53 - Argument 3 of preg_split cannot be null, possibly null value provided (see https://psalm.dev/078) $parts = php_preg_split($pattern, $subject, $limit, $flags); ``` The `$limit` argument of the PHP native `preg_split()` function is not nullable. Ref: https://www.php.net/manual/en/function.preg-split --- src/Utils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Utils.php b/src/Utils.php index 55d4e03..8559ff4 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -29,7 +29,7 @@ abstract class Utils * * @param string $pattern The pattern to search for, as a string. * @param string $subject The input string. - * @param int|null $limit If specified, then only substrings up to limit are returned with the + * @param int $limit If specified, then only substrings up to limit are returned with the * rest of the string being placed in the last substring. A limit of -1 or 0 means "no limit". * @param int $flags flags can be any combination of the following flags (combined with the | bitwise operator): * *PREG_SPLIT_NO_EMPTY* @@ -46,7 +46,7 @@ abstract class Utils * * @throws PcreException */ - public static function pregSplit(string $pattern, string $subject, ?int $limit = -1, int $flags = 0): array + public static function pregSplit(string $pattern, string $subject, int $limit = -1, int $flags = 0) : array { $parts = php_preg_split($pattern, $subject, $limit, $flags); if ($parts === false) {