Skip to content

TokenPolyfill tries to construct itself with an id which is a string #974

Closed
@phil-davis

Description

@phil-davis

I updated to PhpParser https://github.com/nikic/PHP-Parser/releases/tag/v5.0.0

When I run phpunit in one repo, I get:

$ make test-php-unit
php -d zend.enable_gc=0 ../../lib/composer/bin/phpunit --configuration ./phpunit.xml --testsuite unit
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.3-4ubuntu2.19 with Xdebug 2.9.2
Configuration: ./phpunit.xml

id is not an int
/home/phil/git/owncloud/core/lib/composer/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php:204:
string(16) "T_NAME_QUALIFIED"
the value is: T_NAME_QUALIFIED
Argument 1 passed to PhpParser\Internal\TokenPolyfill::__construct() must be of the type int, string given, called in /home/phil/git/owncloud/core/lib/composer/nikic/php-parser/lib/PhpParser/Internal/TokenPolyfill.php on line 207
make: *** [Makefile:57: test-php-unit] Error 2

Related issue https://github.com/owncloud/files_classifier/issues/847 (sorry, that is a private repo)

Note: I added some debug lines in https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/Internal/TokenPolyfill.php
And discovered that the constant \T_NAME_QUALIFIED is just becoming the literal string "T_NAME_QUALIFIED", when it should be some number, like in https://github.com/nikic/PHP-Parser/blob/master/lib/PhpParser/Parser/Php7.php
public const T_NAME_QUALIFIED = 393;

I don't see where TokenPolyfill.php includes that Php7.php

Is there something I need to do around the environment of PHP-parser, or does the code of TokenPolyfill.php need to include Php7.php and use it?

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