Skip to content

TokenPolyfill issue on PHP 7.4 platform #981

@llaville

Description

@llaville

Hello,

I've worked today to make a package compatible with both PHP-Parser 4.18 and 5.0

I've detected an issue on (I know old platform PHP 7.4, but this package is still compatible PHP 7). Here are the details of my analysis

When PHP-Parser 5.0.0 is installed with PHP_CodeSniffer (3.9.0 in my situation), I got a TypeError

TypeError: Argument 1 passed to PhpParser\Internal\TokenPolyfill::__construct() must be of the type int, string given, called in /shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php on line 202

/shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php:42
/shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php:202
/shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/Lexer.php:31
/shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/Lexer/Emulative.php:71
/shared/backups/forks/symbol-parser/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php:182
/shared/backups/forks/symbol-parser/src/Parser/PHP/SymbolNameParser.php:41
/shared/backups/forks/symbol-parser/tests/Integration/Parser/PHP/SymbolNameParserTest.php:42

Version 5.0 is supposed to be compatible with PHP 7.4 min (see https://github.com/nikic/PHP-Parser/blob/v5.0.0/composer.json#L16-L17)

But :

Reason is PHPCS define these tokens as string.
And TokenPolyfill first argument of class constructor is int

Hope my explains are enough clear ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions