-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Labels
Milestone
Description
Discussed in #5361
Originally posted by hollodotme July 22, 2021
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 Error
LINE ERROR
-------------------------------------
7 Result of && is always false.
See: https://phpstan.org/r/dc55b6b9-5285-4b3c-895f-bb036dd1e2d5
IMO this is a false positive as the second condition isset($matches['productId']) is true after evaluation of the preg_match function.
The $matches array was changed by preg_match() via reference.
Reactions are currently unavailable