Skip to content

Commit 155efd6

Browse files
jrfnljaapio
authored andcommitted
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
1 parent 9ab603b commit 155efd6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Utils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ abstract class Utils
2929
*
3030
* @param string $pattern The pattern to search for, as a string.
3131
* @param string $subject The input string.
32-
* @param int|null $limit If specified, then only substrings up to limit are returned with the
32+
* @param int $limit If specified, then only substrings up to limit are returned with the
3333
* rest of the string being placed in the last substring. A limit of -1 or 0 means "no limit".
3434
* @param int $flags flags can be any combination of the following flags (combined with the | bitwise operator):
3535
* *PREG_SPLIT_NO_EMPTY*
@@ -46,7 +46,7 @@ abstract class Utils
4646
*
4747
* @throws PcreException
4848
*/
49-
public static function pregSplit(string $pattern, string $subject, ?int $limit = -1, int $flags = 0): array
49+
public static function pregSplit(string $pattern, string $subject, int $limit = -1, int $flags = 0) : array
5050
{
5151
$parts = php_preg_split($pattern, $subject, $limit, $flags);
5252
if ($parts === false) {

0 commit comments

Comments
 (0)