magento2-phpstorm-plugin icon indicating copy to clipboard operation
magento2-phpstorm-plugin copied to clipboard

Constants are marked as unused elements

Open DmitryFurs opened this issue 2 years ago • 1 comments

Describe the bug

Constants are marked as unused elements if they are used only in di.xml. During refactoring, such constants may be deleted, since the developer may forget to check the actual use of such constants, and even more so if there are many of them. The developer can simply trust the IDE and think that the constant is not really used anywhere and get rid of it.

To Reproduce

  1. Create any class with a public constant
  2. Use this constant in di.xml as an argument with xsi:type="const"
  3. Go back to your class
  4. And check that the constant is grayed out and marked as Unused element

Expected behavior

The constant must be marked as a used element and have the appropriate color

Screenshots

image

The constant BASE is highlighted in purple and marked as used, actually used in php code and in di.xml, Inlay Hints says that it is used in 5 different places.

The constant BASE_LABEL is highlighted in gray and marked as unused, actually used only in di.xml, Inlay Hints says that it is used in 1 place.

Please complete the following information:

  • OS: MacOS
  • PhpStorm version: 2023.1.2
  • Plugin Version: 5.1.1

Additional context

If you activate Inlay Hints, the number of uses for this constant will be greater than 0, and when you click on 1 usage, the transition to di.xml on the line where this constant is actually used.

image

DmitryFurs avatar May 19 '23 06:05 DmitryFurs