tolerant-php-parser
tolerant-php-parser copied to clipboard
Function names cannot be keywords
Summary
A function name must be a T_STRING token (or whatever its equivalent is in this parser).
Sample code:
function empty() {}
Expected
Parse error: syntax error, unexpected 'empty' (T_EMPTY), expecting '('
Actual No error.
You may not redeclare language constructs.
https://3v4l.org/90mgr
It is still a parse error which should be detected. To contrast, function strlen($s) {} would not be a parse error, but evaluation would result in a PHP error at runtime.
Also something to note: empty is a valid name for a class method in PHP 7
@jens1o empty is a language construct, not a function
Nice catch :)