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

Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface #2029

Merged

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented May 25, 2018

[Fixer conflicts series PR]

Encountered this fatal error when running the Squiz standard over the Squiz tests files.

The error can be reproduced on master by running phpcs -p -s ./src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc --standard=Squiz --sniffs=Squiz.Scope.MemberVarScope

Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_specified in /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php on line 33 in /PHPCS/src/Runner.php on line 562

PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_specified in /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php on line 33 in /PHPCS/src/Runner.php on line 562

Call Stack:
    0.0000     349528   1. {main}() \PHP_CodeSniffer\bin\phpcbf:0
    0.0050     511904   2. PHP_CodeSniffer\Runner->runPHPCBF() /PHPCS/bin/phpcbf:18
    0.7440    5897360   3. PHP_CodeSniffer\Runner->run() /PHPCS/src/Runner.php:193
    0.7720    6565784   4. PHP_CodeSniffer\Runner->processFile() /PHPCS/src/Runner.php:394
    1.6731    7023360   5. PHP_CodeSniffer\Reporter->cacheFileReport() /PHPCS/src/Runner.php:611
    1.6731    7041328   6. PHP_CodeSniffer\Reports\Cbf->generateFileReport() /PHPCS/src/Reporter.php:284
    1.6731    7024896   7. PHP_CodeSniffer\Fixer->fixFile() /PHPCS/src/Reports/Cbf.php:48
    1.6981    7048032   8. PHP_CodeSniffer\Files\LocalFile->process() /PHPCS/src/Fixer.php:174
    1.6981    7048032   9. PHP_CodeSniffer\Files\LocalFile->process() /PHPCS/src/Files/LocalFile.php:91
    1.9421    7421832  10. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->process() /PHPCS/src/Files/File.php:490
    1.9421    7421832  11. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->processTokenWithinScope() /PHPCS/src/Sniffs/AbstractScopeSniff.php:138
    1.9421    7422104  12. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->processMemberVar() /PHPCS/src/Sniffs/AbstractVariableSniff.php:145
    1.9421    7422544  13. PHP_CodeSniffer\Runner->handleErrors() /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php:33

Includes unit test to safeguard against this in the future.

…in an interface

[Fixer conflicts series PR]

Encountered this fatal error when running the `Squiz` standard over the `Squiz` tests files.

The error can be reproduced on `master` by running `phpcs -p -s ./src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc --standard=Squiz --sniffs=Squiz.Scope.MemberVarScope`

```
Fatal error: Uncaught PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_specified in /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php on line 33 in /PHPCS/src/Runner.php on line 562

PHP_CodeSniffer\Exceptions\RuntimeException: Undefined index: scope_specified in /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php on line 33 in /PHPCS/src/Runner.php on line 562

Call Stack:
    0.0000     349528   1. {main}() \PHP_CodeSniffer\bin\phpcbf:0
    0.0050     511904   2. PHP_CodeSniffer\Runner->runPHPCBF() /PHPCS/bin/phpcbf:18
    0.7440    5897360   3. PHP_CodeSniffer\Runner->run() /PHPCS/src/Runner.php:193
    0.7720    6565784   4. PHP_CodeSniffer\Runner->processFile() /PHPCS/src/Runner.php:394
    1.6731    7023360   5. PHP_CodeSniffer\Reporter->cacheFileReport() /PHPCS/src/Runner.php:611
    1.6731    7041328   6. PHP_CodeSniffer\Reports\Cbf->generateFileReport() /PHPCS/src/Reporter.php:284
    1.6731    7024896   7. PHP_CodeSniffer\Fixer->fixFile() /PHPCS/src/Reports/Cbf.php:48
    1.6981    7048032   8. PHP_CodeSniffer\Files\LocalFile->process() /PHPCS/src/Fixer.php:174
    1.6981    7048032   9. PHP_CodeSniffer\Files\LocalFile->process() /PHPCS/src/Files/LocalFile.php:91
    1.9421    7421832  10. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->process() /PHPCS/src/Files/File.php:490
    1.9421    7421832  11. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->processTokenWithinScope() /PHPCS/src/Sniffs/AbstractScopeSniff.php:138
    1.9421    7422104  12. PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope\MemberVarScopeSniff->processMemberVar() /PHPCS/src/Sniffs/AbstractVariableSniff.php:145
    1.9421    7422544  13. PHP_CodeSniffer\Runner->handleErrors() /PHPCS/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php:33
```

Includes unit test to safeguard against this in the future.
@gsherwood gsherwood added this to the 3.3.1 milestone Jun 7, 2018
@gsherwood gsherwood changed the title Squiz/MemberVarScope: prevent a fatal error when a property is found in an interface Squiz.Scope.MemberVarScope throws fatal error when a property is found in an interface Jun 7, 2018
@gsherwood gsherwood merged commit a8ee583 into squizlabs:master Jun 7, 2018
gsherwood added a commit that referenced this pull request Jun 7, 2018
@gsherwood
Copy link
Member

Thanks for this fix

@jrfnl jrfnl deleted the feature/squiz-membervarscope-fatal-error branch June 7, 2018 06:41
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