Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Jul 15, 2024

this PREG_UNMATCHED_AS_NULL thing really affects all kind of types :-)

@staabm staabm changed the base branch from 1.12.x to 1.11.x July 15, 2024 07:48
@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.12.x. If your code is relevant on 1.11.x and you want it to be released sooner, please rebase your pull request and change its target to 1.11.x.

@staabm
Copy link
Contributor Author

staabm commented Jul 15, 2024

//cc @Seldaek

@staabm staabm marked this pull request as ready for review July 15, 2024 07:53
@phpstan-bot
Copy link
Collaborator

This pull request has been marked as ready for review.

class UnmatchedAsNullWithTopLevelAlternation {
function doFoo(string $s): void {
if (preg_match('/Price: (?:(£)|(€))\d+/', $s, $matches, PREG_UNMATCHED_AS_NULL)) {
assertType('array{string, string|null, string|null}', $matches); // could be array{0: string, 1: null, 2: string}|array{0: string, 1: string, 2: null}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that would be nicer for sure ;) But strictly speaking at least this is correct.

@ondrejmirtes ondrejmirtes merged commit b116e71 into phpstan:1.11.x Jul 15, 2024
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the reg-top branch July 15, 2024 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants