-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for isMatch in phpstan type ext #26
Conversation
The other question I have is that it does |
I will have a look, but cannot promise today/tomorrow
I think thats already fixed - but not yet released - with phpstan/phpstan-src#3219 |
@@ -27,6 +27,13 @@ function doMatch(string $s): void | |||
assertType('array{}', $matches); | |||
} | |||
assertType('array{}|array{0: string, 1?: string|null}', $matches); | |||
|
|||
if (Preg::isMatch('/Price: (?P<currency>£|€)\d+/', $s, $matches)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something is wrong with Hoa parsing the AST for the pattern.
it works as expected with a pattern like
if (Preg::isMatch('/Price: (?P<currency>£|€)\d+/', $s, $matches)) { | |
if (Preg::isMatch('/Price: (£|€)\d+/', $s, $matches)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened a upstream bug report regarding the bogus-pattern:
I think these should be doable in a similar way you did in this PR
match all is on the todo-list and not yet support in phpstan-src |
@staabm sorry to bug you again but any clue why this does not work?
Ideally we'd have support for:
But at least isMatch would be great because that's used all over the place (I never use match as it returns int), and it is API compatible with match so I don't get why this fails.