parent::$staticPropertyName reports $staticPropertyName as undefined.

Created on 10 May 2017, almost 8 years ago
Updated 21 April 2024, 12 months ago

Accessing protected (and presumably public) static variables defined in a parent class, accessed using parent::$staticPropertyName cause a DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable warning to be issued.

It appears that DrupalPractice_Sniffs_CodeAnalysis_VariableAnalysisSniff::checkForStaticMember() neglects to allow variables where $phpcsFile->getTokens()[$stackPtr - 2]['code'] === T_PARENT to be recognized as static variables in the vicinity of coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php:1483.

Adding:
1484: && ($tokens[$classNamePtr]['code'] !== T_PARENT)
seems to resolve the issue.

πŸ› Bug report
Status

Closed: outdated

Version

2.12

Component

Coder Sniffer

Created by

πŸ‡ΊπŸ‡ΈUnited States linux_dr@yahoo.com

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΉAustria klausi πŸ‡¦πŸ‡Ή Vienna

    VariableAnalysisSniff is now used from sirbrillig/phpcs-variable-analysis and I assume this is fixed.

    Let me know if not!

Production build 0.71.5 2024