slevomat / coding-standard

Slevomat Coding Standard for PHP_CodeSniffer provides many useful sniffs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PHP notice undefined array key AbstractPropertyConstantAndEnumCaseSpacing

kkmuffme opened this issue · comments

Slevomat 8.14.1
Issue happened when running phpcbf

PHP Error for

Undefined array key "" in

https://github.com/slevomat/coding-standard/blob/master/SlevomatCodingStandard/Sniffs/Classes/AbstractPropertyConstantAndEnumCaseSpacing.php#L87C93-L87C106

Looks like $classPointer is falsy in some cases.

Partial trace

#0 /path/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/AbstractPropertyConstantAndEnumCaseSpacing.php (87): PHP_CodeSniffer\Runner->handleErrors( $code = 2, $message = Undefined array key "", $file = /path/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/AbstractPropertyConstantAndEnumCaseSpacing.php, $line = 87 )
#1 /path/vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Classes/PropertySpacingSniff.php (63): SlevomatCodingStandard\Sniffs\Classes\AbstractPropertyConstantAndEnumCaseSpacing->process( $phpcsFile = PHP_CodeSniffer\Files\LocalFile Object, $pointer = 74 )
#2 /path/vendor/squizlabs/php_codesniffer/src/Files/File.php (498): SlevomatCodingStandard\Sniffs\Classes\PropertySpacingSniff->process( $phpcsFile = PHP_CodeSniffer\Files\LocalFile Object, $pointer = 72 )

I don't have any code samples to reproduce or any further details unfortunately, but just adding an isset before and handling it is enough to fix it

It's not possible to fix it without code sample.

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.