nvlad / yii2support

Yii2 Support for PhpStorm / IntelliJ IDEA
https://plugins.jetbrains.com/idea/plugin/9388-yii2-support
Other
295 stars 54 forks source link

Class marked as "not used" when name is used in array key #241

Open rhertogh opened 4 years ago

rhertogh commented 4 years ago

Originally posted at https://youtrack.jetbrains.com/issue/WI-50947

What steps will reproduce the problem?

When a class name is used as a string as a key inside another array the class is marked as not used image

But only if this construction is used before "regular" usages image

The error only occurs in this exact case, when for example the array is not nested in another array everything works fine: image

Aslo when the class name is not used as a key of an existing array the class is correctly marked as used image

Running "Code > Inspect Code" shows an incorrect "Import 'common\models\sql\KnowledgeType' is never used" warning (the other 2 warnings are expected). image

The biggest problem is that since the import is not recognized as being used, when the "optimize imports" function runs it removes the import statement.

What is the expected result?

Class is marked as "used"

What do you get instead?

Class is marked as "unused"

Additional info

Q A
IDE Name PhpStorm 2019.3.2
IDE Version #PS-193.6015.48
Plugin version 0.10.57.23
Yii App Template n.a.