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

Avoid using undefined variables with static array in trait #991

Open
tebeso opened this issue Nov 30, 2022 · 0 comments
Open

Avoid using undefined variables with static array in trait #991

tebeso opened this issue Nov 30, 2022 · 0 comments

Comments

@tebeso
Copy link

tebeso commented Nov 30, 2022

  • PHPMD version: 2.13.0
  • PHP Version: 8.1
  • Installation type: composer
  • Operating System / Distribution & Version: Ubuntu 22.04

Current Behavior

<?php
use SomeTrait;

class Example {
   use SomeTrait;

   public function test(){
     $bla = self::$someTraitVar['someKey'];
   }
}
?>
<?php

trait SomeTrait {
   protected static array $someTraitVar = [
      'someKey' => 12345
   ];
}
?>

This will mark self::$someTraitVar['someKey']; within the test method as "Avoid using undefined variables...".

Expected Behavior

Should not be marked as "Avoid using undefined variables...".

Steps To Reproduce:

See example code above

@ravage84 ravage84 added this to the 2.x (unspecific) milestone May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants