Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preg_match has different result when $match variable is declared earlier #11580

Closed
integer opened this issue Aug 29, 2024 · 4 comments
Closed
Labels
Milestone

Comments

@integer
Copy link
Contributor

integer commented Aug 29, 2024

Bug report

Preg_match has different result when $match variable is declared earlier. In code snippet there are 2 functions with same results, but one is reported as error.

Code snippet that reproduces the problem

https://phpstan.org/r/658ff574-8680-4d35-8bb3-26b3143bddab

Expected output

On line 29 is expected Dumped type: array{0: string, 1: non-empty-string, 2?: non-empty-string}

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

Yes! preg_* analysis is killer feature. Thanks!

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Aug 31, 2024
@staabm
Copy link
Contributor

staabm commented Sep 1, 2024

reduced it further to https://phpstan.org/r/269d2eba-0322-40c7-b9f0-83d7c525fa30

I think its not cause by the preg_* related stuff, but a more general TypeSpecifier problem

@ondrejmirtes
Copy link
Member

I think this extension should always overwrite.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@5892e8d

Copy link

github-actions bot commented Oct 5, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants