Thanks to visit codestin.com
Credit goes to github.com

Skip to content

preg_match-analysis crashes phpstan #14605

@codebear

Description

@codebear

Bug report

We experience a crash in phpstan.

I narrowed it down to this reproducible code-sample.

It crashes even the phpstan-playground at https://phpstan.org/try so the share-functionality doesn't work

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

function sigh(string $resource) {
	if (preg_match("!^3(/.*)?$!", $resource, $m)) {
		$resource = count($m) > 1 ? substr($m[1], 1) : '';
	}
}

Expected output

I expect phpstan not to crash.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions