-
Notifications
You must be signed in to change notification settings - Fork 461
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
RichParser: stricter identifiers parser #3079
Conversation
|
||
yield [ | ||
'<?php' . PHP_EOL . | ||
'test(); // @phpstan-ignore mečoun' . PHP_EOL, |
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.
The identifier grammar should be the same as any other PHP identifier grammar, ie. allow \x80-\xff
to be valid identifier character - https://www.php.net/manual/en/language.variables.basics.php#language.variables.basics.
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.
No, it's very simple ASCII for good reasons
phpstan-src/src/Analyser/Error.php
Line 19 in 16d5b01
public const PATTERN_IDENTIFIER = '[a-zA-Z0-9](?:[a-zA-Z0-9\\.]*[a-zA-Z0-9])?'; |
|
||
yield [ | ||
'<?php' . PHP_EOL . | ||
'test(); // @phpstan-ignore identifier -- comment' . PHP_EOL, // phpcs comment style |
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.
Just a question - if the identifiers have to be delimited by comma, what are the reasons to not allow free-text comment, ie. comment not wrapped in parenthesis?
ex: @phpstan-ignore return.reg https://github.com/doctrine/dbal/pull/6407
Such grammar is unambiguous as after @phpstan-ignore
and ,\s*
one identifier will be still required.
I find this more natural and it will also URL issue we currently have - @phpstan-ignore return.reg (https://github.com/doctrine/dbal/pull/6407)
- is opened as https://github.com/doctrine/dbal/pull/6407)
.
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.
With that, you could not use comma in comment, right?
@phpstan-ignore identifier.one ignored, because of PHPStan bug, identifier.two
Now you can (and you can even use parenthesis inside):
@phpstan-ignore identifier.one (ignored, because of PHPStan bug), identifier.two
@phpstan-ignore identifier.one (ignored (because of PHPStan bug)), identifier.two
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.
@phpstan-ignore return.reg (doctrine/dbal#6407) - is opened as doctrine/dbal#6407).
Most widely used IDE (PHPStorm) does not do that (luckily for us).
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.
99% ignores are consisting of a single identifier. So I mean to parse anything after the current \w+( \(...\))?(, \w+( \(...\))?)*
(simplified) grammar as a free-text comment.
4eee9a8
to
c32b70c
Compare
c32b70c
to
78072da
Compare
Thank you! |
No description provided.