Skip to content

Document return type of CodeUnitFindingVisitor::enterNode() so that Symfony's DebugClassLoader does not trigger a deprecation warning #887

@tft7000

Description

@tft7000
Q A
php-code-coverage version 9.2.9
PHP version 8.0.13 / 8.1.0
Driver Xdebug
Xdebug version (if used) 3.1.2
Installation Method Composer
Usage Method PHPUnit
PHPUnit version (if used) 9.5.10

Since Symfony 5.4 release PHPUnit ends with exit code 1 if I start it with code coverage:

XDEBUG_MODE=coverage symfony php vendor/bin/simple-phpunit --coverage-text

the above command ends with the message:

Remaining indirect deprecation notices (1)

  1x: Method "PhpParser\NodeVisitor::enterNode()" might add "int|Node|null" as a native return type declaration in the future. Do the same in implementation "SebastianBergmann\CodeCoverage\StaticAnalysis\CodeUnitFindingVisitor" now to avoid errors or add an explicit @return annotation to suppress this message.
    1x in CodeCoverage::stop from SebastianBergmann\CodeCoverage

exit status 1

I believe this has the same reason as here: sebastianbergmann/php-file-iterator#74 (Document return type of Iterator::accept() so that Symfony's DebugClassLoader does not trigger a deprecation warning)

If I manually set a @return int|Node|null php doc comment for \SebastianBergmann\CodeCoverage\StaticAnalysis\CodeUnitFindingVisitor::enterNode phpunit will end without error.

Also if I add "symfony/error-handler": "<5.4" as require-dev dependency in composer.json, I do not experience an error.
This seems to be the only workaround I can do as end-user.

Suggested fix:
add correct return type php doc comment for the enterNode method. I assume it is null (is void and null the same?)

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