Skip to content

RegexArrayShapeMatcher - Fix PREG_UNMATCHED_AS_NULL with optional leading groups #3234

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

Merged
merged 3 commits into from
Jul 14, 2024

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 14, 2024

@staabm
Copy link
Contributor Author

staabm commented Jul 14, 2024

//cc @Seldaek

@staabm staabm marked this pull request as ready for review July 14, 2024 06:05
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

| (?# the alternation making it so that only either should match)
git@([^:]+):/? (?# group 2 here can be null if group 1 matches)
)
(?# removing what follows makes the two first groups nullable, although it then has group 2 unsettable which looks buggy too as PREG_UNMATCHED_AS_NULL is present)
Copy link
Contributor Author

@staabm staabm Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Seldaek not sure what this means. could you come up with a concrete code sample and assertions for it?

(sounds unrelated to the other bugs and might be worth a separate report)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just meant if you delete the lines of regex below this comment, then the type of the groups 1 and 2 become correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see thanks. I will remove the comment from the test so it not confuses others :)

@ondrejmirtes ondrejmirtes merged commit 0f3622a into phpstan:1.11.x Jul 14, 2024
451 of 454 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants