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

Generic/LowerCaseType: fix potential PHP notice #3833

Closed
wants to merge 1 commit into from

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented May 22, 2023

Description

The Generic.PHP.LowerCaseType sniff calls the File::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 an Internal.ParseError.InterfaceHasMemberVar warning and return an empty array when the T_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

  • 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

The `Generic.PHP.LowerCaseType` sniff calls the `File::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 an `Internal.ParseError.InterfaceHasMemberVar` warning and return an empty array when the `T_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.
@jrfnl
Copy link
Contributor Author

jrfnl commented May 22, 2023

This PR will conflict with PR #3662 and either one of them will need rebasing if the other gets merged first.

@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 2, 2023

Closing as replaced by PHPCSStandards/PHP_CodeSniffer#62

@jrfnl jrfnl closed this Dec 2, 2023
@jrfnl jrfnl deleted the feature/generic-lowercasetype-fix-php-notice branch December 2, 2023 02:24
@jrfnl
Copy link
Contributor Author

jrfnl commented Dec 8, 2023

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).

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.

1 participant