Skip to content

preg_match + if: false positive #11908

@lazka

Description

@lazka

Bug report

it says Right side of && is always true., but it isn't true there.

<?php declare(strict_types = 1);

$matches = false;
if (preg_match('/a/', '', $matches) !== false && $matches) {
	var_export($matches);
}

Code snippet that reproduces the problem

https://phpstan.org/r/bc430066-e198-435e-bc2d-95dac3ff3d05

Expected output

No phpstan error.

Did PHPStan help you today? Did it make you happy in any way?

always

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions