yii2support icon indicating copy to clipboard operation
yii2support copied to clipboard

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

Open rhertogh opened this issue 5 years ago • 0 comments

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.

rhertogh avatar Feb 13 '20 17:02 rhertogh