Closed jrfnl closed 11 months ago
This PR will conflict with PR #3662 and either one of them will need rebasing if the other gets merged first.
Closing as replaced by https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/62
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release.
As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo).
Description
The
Generic.PHP.LowerCaseType
sniff calls theFile::getMemberProperties()
method to get information about potential properties.That method throws an exception when the
T_VARIABLE
token passed is not a property, but will create anInternal.ParseError.InterfaceHasMemberVar
warning and return an empty array when theT_VARIABLE
passed is an illegal property, i.e. a property in a context in which it is not allowed (interface/enum).As things were, the sniff did not take a potential return value of an empty array into account, which could result in an
Undefined array key "type"
PHP notice.Fixed now.
Includes unit test.
Suggested changelog entry
Generic.PHP.LowerCaseType: fixed potential undefined array index notice
Related issues/external references
N/A
Types of changes