PHP Class properties not recognized
As of newest PhpSorm update 2021.2, class properties with phpdoc @property comments are not recognized. Usually class properties are colored in different color.
Maybe it is because now IDE thinks it is two different properties?


Please sign in to leave a comment.
Hi there,
PHPDoc's @property tag is meant for magic (not real / dynamic) fields only (that are getting accessed via __get() / __set() methods)
If you need to typehint your $bar real property then do it using appropriate @var tag: https://github.com/phpDocumentor/fig-standards/blob/master/proposed/phpdoc-tags.md#517-var
P.S. Yes, it's a fix since 2021.2 version.
Thanks,
So it seems, that I used @property tag incorrectly. It was handy that IDE changed attribute name color and was really easy to spot incorrect attribute names.
The IDE already tells you about wrong / non-existing properties:
It will highlight such place with the notice (see the screenshot below).
You can increase the visibility by changing the severity of that inspection to a more noticeable warning (or even an error) level if needed. The style / how noticeable it is depends on your Color Scheme / Theme used.
BTW: If https://wiki.php.net/rfc/deprecate_dynamic_properties will be accepted then PHP 8.2+ will throw warnings during runtime on such dynamic property access (without __get/__set in place).
Thanks, I will change inspection severity to error.