Skip to content

PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML #1266

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

Closed
es02 opened this issue Jan 11, 2017 · 4 comments
Closed

Comments

@es02
Copy link

es02 commented Jan 11, 2017

PHP Warning:  str_repeat(): Second argument has to be greater than or equal to 0 in /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php on line 181
PHP Stack trace:
PHP   1. {main}() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf:0
PHP   2. PHP_CodeSniffer_CLI->runphpcbf() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/scripts/phpcbf:23
PHP   3. PHP_CodeSniffer_CLI->process() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:182
PHP   4. PHP_CodeSniffer->processFiles() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php:998
PHP   5. PHP_CodeSniffer->processFile() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php:653
PHP   6. PHP_CodeSniffer_Reporting->cacheFileReport() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer.php:1811
PHP   7. PHP_CodeSniffer_Reports_Diff->generateFileReport() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Reporting.php:160
PHP   8. PHP_CodeSniffer_Fixer->fixFile() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Diff.php:68
PHP   9. PHP_CodeSniffer_File->start() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Fixer.php:190
PHP  10. PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff->process() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php:576
PHP  11. str_repeat() /home/es02/.config/composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php:181

Not sure what chunk of the ancient code I was running it against threw this though >.<

@gsherwood
Copy link
Member

I typically can't figure these out unless you happen to have some code I can use to generate the error. Any chance you could run PHPCS again with the -v flag and see what file it was processing when the errors appeared? If possible, getting access to that file would let me replicate and fix the issue.

@gsherwood
Copy link
Member

Closing due to lack of feedback. If you manage to find a code sample, please post it here and I'll look into it again.

@t-richards
Copy link

t-richards commented Apr 28, 2017

@gsherwood I've created a repo with a minimal(-ish) working example -- running phpcbf against it will reproduce this issue.

@gsherwood gsherwood reopened this Apr 30, 2017
@gsherwood gsherwood changed the title Stacktrace on ScopeClosingBraceSniff PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML May 1, 2017
gsherwood added a commit that referenced this issue May 1, 2017
@gsherwood
Copy link
Member

Thanks a lot for putting that together. I was able to replicate and fix the problem easily.

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

No branches or pull requests

3 participants