0

When I run codesniffer for magento2 extension by following the doc - https://developer.adobe.com/commerce/php/coding-standards/

From magento root directory I run

vendor/bin/phpcbf --standard=Magento2 ./app/code/Test/Module

I get the following error

PHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: The $start position for getTokensAsString() must exist in the token stack in /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Files/File.php:2112
Stack trace:
#0 /home/cloudpanel/htdocs/magento2.mgt/vendor/magento/magento-coding-standard/Magento2/Sniffs/Functions/FunctionsDeprecatedWithoutArgumentSniff.php(66): PHP_CodeSniffer\Files\File->getTokensAsString()
#1 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): Magento2\Sniffs\Functions\FunctionsDeprecatedWithoutArgumentSniff->process()
#2 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Fixer.php(174): PHP_CodeSniffer\Files\LocalFile->process()
#4 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Runner.php(657): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Runner.php(434): PHP_CodeSniffer\Runner->processFile()
#8 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Runner.php(200): PHP_CodeSniffer\Runner->run()
#9 /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/bin/phpcbf(18): PHP_CodeSniffer\Runner->runPHPCBF()
#10 /home/cloudpanel/htdocs/magento2.mgt/vendor/bin/phpcbf(120): include('...')
#11 {main}
  thrown in /home/cloudpanel/htdocs/magento2.mgt/vendor/squizlabs/php_codesniffer/src/Files/File.php on line 2112

my php version is

PHP 8.1.8 (cli) (built: Jul  8 2022 07:08:08) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.8, Copyright (c), by Zend Technologies

I am using Magento 2.4.4

What is the issue here?

footy
  • 5,803
  • 13
  • 48
  • 96

0 Answers0