-
Notifications
You must be signed in to change notification settings - Fork 545
Support posix character classes in preg_match() inference #3241
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
Conversation
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.
Ok I'll try to debug this, thanks. Might not have time before later this week though.
Just adding %token posix_class \[^?:[a-z]+:\] and not the class_literal line because that breaks everything, and then using ( <posix_class> | <class_> | range() | literal() | quantifier() | <alternation> | <capturing_> | <_capturing> )+ <range>? to parse the class contents.. it gets almost to the end:
Unexpected token ")" (_capturing) at line 1 and column 34:
/([*|+?{}()]+)([^*|+[:digit:]?{}()]+)/
↑
Unfortunately I don't manage to make it capture the last ), no clue why it'd fail there..
And also this is super brittle, and I can break it by adding [(?:] for example or any other token to the character class, which then gets matched and results in an:
Unexpected token "(?:" (non_capturing_) at line 1 and column 10:
/([*|+?{}(?:)]+)([^*|+[:digit:]?{}()]+)/
↑
@mvorisek are you familiar with this parser? Is there a syntax to turn this silly scanning-of-all-tokens off and tell it to not look at other tokens while it is in the middle of parsing a class section?
I guess I'll need to read up on https://github.com/hoaproject/Compiler - but no time for this anymore today ..
here seems to be something like a documentation
@mvorisek are you familiar with this parser? Is there a syntax to turn this silly scanning-of-all-tokens off and tell it to not look at other tokens while it is in the middle of parsing a
classsection?
Of course class_literal needs to go before class_, more precisely class_ needs to be removed - if that is not possible, the only option is to list "all" tokens in phpstan/phpstan#11323 (comment) and my following comment.
as far as I understood the other parallel PRs, current progress happens in #3244 and this one here is obsolete.
therefore closing.
Uh oh!
There was an error while loading. Please reload this page.
closes phpstan/phpstan#11323
composer install- so the patch is appliedvendor/bin/phpunit tests/PHPStan/Analyser/NodeScopeResolverTest.php(will test all preg_match() related tests)for a faster debug loop, you might just put the test into a
test.phpfile:and run
php bin/phpstan analyze test.php --debugon it(append an additional
--xdebugin case you want to step-debug)