-
Couldn't load subscription status.
- Fork 24
Open
Description
Hi @shish, Thank you for adding more features to Safe.
Currently, I found an issue where the return value of the \Safe\preg_match() method must be assigned to a variable for PHPStan to correctly infer it; otherwise, it assumes that the array key might not exist.
$result = \Safe\preg_match($pattern, $string, $matches); if ($result === 1){ \PHPStan\Testing\assertType($type, $matches); } if(\Safe\preg_match($pattern, $string, $matches) === 1) { \PHPStan\Testing\assertType($type, $matches); // line 24 } ------ ------------------------------------------------------------------------------------------------------------------------------------ 24 Expected type array{0: string, 1: non-empty-string, 2: 'o', 3?: 'World'}, actual: array{0?: string, 1?: non-empty-string, 2?: 'o', 3?: 'World'} ------ ------------------------------------------------------------------------------------------------------------------------------------ [ERROR] Found 1 error Metadata
Metadata
Assignees
Labels
No labels