Description
Unfortunately, I don't know how to reproduce this issue with the OOTB standards, but here's the minimal required setup:
cat > composer.json << 'EOF'
{
"require-dev": {
"doctrine/coding-standard": "^4.0"
}
}
EOF
cat > phpcs.xml.dist << 'EOF'
<?xml version="1.0"?>
<ruleset>
<rule ref="Doctrine"/>
</ruleset>
EOF
cat > PhpCodeSnifferFailure.php << 'EOF'
<?php
namespace Doctrine\DBAL;
class PhpCodeSnifferFailure
{
public function foo()
{
return [
<<<HERE
HERE
,
];
}
}
EOF
composer install
vendor/bin/phpcs --version
# PHP_CodeSniffer version 3.3.1 (stable) by Squiz (http://www.squiz.net)
vendor/bin/phpcbf --parallel=2 PhpCodeSnifferFailure.php
The run results in the following error:
-
PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_closer in vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php on line 156 in /home/morozov/t1/vendor/squizlabs/php_codesniffer/src/Runner.php on line 562
This error happens in the child process outside of the PHP_CodeSniffer codebase because the
T_CLASS
token doesn't have thescope_closer
attribute defined. -
PHP_CodeSniffer\Exceptions\RuntimeException: Undefined variable: childOutput in vendor/squizlabs/php_codesniffer/src/Runner.php on line 705 in vendor/squizlabs/php_codesniffer/src/Runner.php on line 562
This error happens in PHP_CodeSniffer itself. The parent creates an empty shared file before running the child:
PHP_CodeSniffer/src/Runner.php
Line 418 in 4725c01
but the child dies before writing its contents due to the error above. However, the parent only checks if the file exists:
PHP_CodeSniffer/src/Runner.php
Line 677 in 4725c01
Besides the bug in the runner, is the fact that a T_CLASS
token doesn't have scope_closer
also a bug?