Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiLineArrayCommaSniff for PHP 8.3 #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brianvarskonst
Copy link

Hello,

I got this following error by running vendor/bin/phpcbf:

PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Increment on type bool has no effect, this will change in the next major version of PHP in /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php on line 97 in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:623
Stack trace:
#0 /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php(97): PHP_CodeSniffer\Runner->handleErrors()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/File.php(519): Symfony\Sniffs\Arrays\MultiLineArrayCommaSniff->process()
#2 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Fixer.php(175): PHP_CodeSniffer\Files\LocalFile->process()
#4 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(706): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(519): PHP_CodeSniffer\Runner->processFile()
#8 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#9 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#10 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#11 {main}
  thrown in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php on line 623

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Increment on type bool has no effect, this will change in the next major version of PHP in /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php on line 97 in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:623
Stack trace:
#0 /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php(97): PHP_CodeSniffer\Runner->handleErrors()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/File.php(519): Symfony\Sniffs\Arrays\MultiLineArrayCommaSniff->process()
#2 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Fixer.php(175): PHP_CodeSniffer\Files\LocalFile->process()
#4 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(706): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(519): PHP_CodeSniffer\Runner->processFile()
#8 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#9 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#10 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#11 {main}
  thrown in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php on line 623
PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Increment on type bool has no effect, this will change in the next major version of PHP in /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php on line 97 in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:623
Stack trace:
#0 /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php(97): PHP_CodeSniffer\Runner->handleErrors()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/File.php(519): Symfony\Sniffs\Arrays\MultiLineArrayCommaSniff->process()
#2 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Fixer.php(175): PHP_CodeSniffer\Files\LocalFile->process()
#4 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(706): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(519): PHP_CodeSniffer\Runner->processFile()
#8 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#9 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#10 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#11 {main}
  thrown in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php on line 623

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Increment on type bool has no effect, this will change in the next major version of PHP in /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php on line 97 in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:623
Stack trace:
#0 /var/www/html/app/vendor/escapestudios/symfony2-coding-standard/Symfony/Sniffs/Arrays/MultiLineArrayCommaSniff.php(97): PHP_CodeSniffer\Runner->handleErrors()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/File.php(519): Symfony\Sniffs\Arrays\MultiLineArrayCommaSniff->process()
#2 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Fixer.php(175): PHP_CodeSniffer\Files\LocalFile->process()
#4 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(706): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(519): PHP_CodeSniffer\Runner->processFile()
#8 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#9 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#10 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#11 {main}
  thrown in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php on line 623
PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: One or more child processes failed to run in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:561
Stack trace:
#0 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#2 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#3 {main}
  thrown in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php on line 561

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: One or more child processes failed to run in /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php:561
Stack trace:
#0 /var/www/html/app/vendor/squizlabs/php_codesniffer/src/Runner.php(215): PHP_CodeSniffer\Runner->run()
#1 /var/www/html/app/vendor/squizlabs/php_codesniffer/bin/phpcbf(14): PHP_CodeSniffer\Runner->runPHPCBF()
#2 /var/www/html/app/vendor/bin/phpcbf(119): include('...')
#3 {main}

This error appears because the line of code return a boolean or an integer and for PHP 8.3 its deprecaded to increase a boolean, so this early return fixes this issue.

/** @return false|int */
$lastCommaPtr = $phpcsFile->findPrevious(
     T_COMMA,
     $closePtr,
     $stackPtr
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants