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 PHP Notice in Squiz.WhiteSpace.ScopeKeywordSpacing #160

Conversation

fredden
Copy link
Member

@fredden fredden commented Dec 13, 2023

Description

While looking into #152, I ran the following command:
phpcbf -p . --standard=PSR2 --ignore="*/build/*,*/vendor/*" --basepath=. --extensions=inc --suffix=.conflictcheck

Instead of a useful report, I got a PHP Fatal error:

FFFFFFFFFEFFFFFF..EFFF.FPHP Fatal error:  Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined array key 895 in .../src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php on line 131 in .../src/Runner.php:608
Stack trace:
#0 .../src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php(131): PHP_CodeSniffer\Runner->handleErrors()
#1 .../src/Files/File.php(518): PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\ScopeKeywordSpacingSniff->process()
#2 .../src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process()
#3 .../src/Fixer.php(174): PHP_CodeSniffer\Files\LocalFile->process()
#4 .../src/Reports/Cbf.php(52): PHP_CodeSniffer\Fixer->fixFile()
#5 .../src/Reporter.php(285): PHP_CodeSniffer\Reports\Cbf->generateFileReport()
#6 .../src/Runner.php(691): PHP_CodeSniffer\Reporter->cacheFileReport()
#7 .../src/Runner.php(438): PHP_CodeSniffer\Runner->processFile()
#8 .../src/Runner.php(204): PHP_CodeSniffer\Runner->run()
#9 .../bin/phpcbf(18): PHP_CodeSniffer\Runner->runPHPCBF()
#10 {main}
  thrown in .../src/Runner.php on line 608

This pull request fixes this error, allowing the suggested command to produce a report.
I'm not adding any specific tests for this, as the integration test that will eventually be added as part of #152 will cover this case.

Suggested changelog entry

Related issues/external references

Related to #152

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.

@jrfnl
Copy link
Member

jrfnl commented Dec 13, 2023

This looks like a duplicate of #150 which fixes this more comprehensively.... ?

@fredden
Copy link
Member Author

fredden commented Dec 13, 2023

Yes, #150 does look like a duplicate of this. I did look through the list of open pull requests when opening this, but didn't notice #150 at the time. I don't know why, as its title includes (most of) this sniff's name.

@fredden fredden deleted the php-notice/Squiz.WhiteSpace.ScopeKeywordSpacing branch December 13, 2023 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants