Closed assertchris closed 6 years ago
I think it's fine to add this as a new function at parsers.php
:
function method_modifiers(): Parser {
return optional(
repeat(
either(
token(T_PUBLIC),
token(T_PROTECTED),
token(T_PRIVATE),
token(T_STATIC)
)
)
);
}
You may or may not add a check for duplicated modifiers as in:
public public static function bar() // [...]
Actually, nevermind about the extra checks. It seems PHP goes for a compilation error rather than a syntax error https://3v4l.org/ZZJpB. And the same goes for contradictory modifiers as in private public foo()
.
Ok, I'll make a PR for this and some tests.
Going to submit as PR if I get a solution that looks good.
Do you think it would be a good idea to add a parser for something like this?
...and if so, how would you recommend I do this?