preg_match's referenced matches not considered updated #5361
Answered
by
ondrejmirtes
hollodotme
asked this question in
Support
-
Code<?php declare(strict_types = 1);
$matches = [];
$pattern = '#^C\s+(?<productId>\d+)$#i';
$subject = 'C 1234567890';
$found = (bool)preg_match( $pattern, $subject, $matches ) && isset( $matches['productId'] );PHPStan ErrorSee: https://phpstan.org/r/dc55b6b9-5285-4b3c-895f-bb036dd1e2d5 IMO this is a false positive as the second condition The |
Beta Was this translation helpful? Give feedback.
Answered by
ondrejmirtes
Jul 22, 2021
Replies: 1 comment 1 reply
-
|
Looks like PHPStan is a bit confused about already existing |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ondrejmirtes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like PHPStan is a bit confused about already existing
$matchesvariable, without it it works: https://phpstan.org/r/ae249e12-2326-494c-968c-316e503e9768