Using proprietary classes in code?

In a relatively recent update to Inttellij (or I hadn't noticed before), I've noticed certain code hints suggest things like tagging a function "pure" or  using "ArrayShape" , and if I accept these suggestions I get the code additions with these added libraries:

use JetBrains\PhpStorm\ArrayShape;
use JetBrains\PhpStorm\Pure;

While seemingly helpful, I'm hesitant on adding proprietary Intellij libraries to my code. What is the consensus of using these? 


Hi there,

Those are not libraries. Those are just PHP attributes used by the IDE for more advanced code completion and analysis.


Hmmm, well the definition of those attributes aren't supplied by a library?
So what should happen if my code is loaded in a different ide with these included attributes?


It should be possible to install them via Composer as a dev dependency:

composer require --dev jetbrains/phpstorm-attributes

I assume this was done when I accepted the hint to use these. I just wasn't aware that they came from jetbrains until after the fact. Nbd, just curious.


I assume this was done when I accepted the hint to use these.

Not really.

Since these are attributes made by JetBrains, they come bundled in PhpStorm together with other stub files. PhpStorm knows what they are and how to handle them.

For other environments (other static analysis tools/IDEs) you would need to use that command to get them into your composer.json (as stated in, Installation section).


Please sign in to leave a comment.