Closed sandermarechal closed 2 months ago
So, anything starting with @ that is followed by an imported or fully qualified classname
This usage is entirely new to me. I’d like to keep support focused on documented syntax (standard php doc) And commonly used extensions (phpstan/psalm/etc).
Can you tell me more about this usage, or point me to any documentation, tooling or more examples?
As I recall, it’s hard (maybe not possible?) to limit tags (eg @.***) only to dynamic types that have been imported (eg
use Route`).
This usage is called "PHP annotations" and is extremely common though it is slowly being phased out in new projects since PHP 8 has attributes now. Some examples:
There are many, many more. Almost all these depend on https://packagist.org/packages/doctrine/annotations as a generic annotations parser. As you can see on that page, over 2000 other packages depend (directly) on this one.
The simple solution may be to simply highlight anything that has the format of @SomeString
or @SomeString()
(matching brackets). The Doctrine annotations parser will throw an exception for any @
tag that is not a known phpdoc/psalm/phpstan/phpunit tag and not a valid classname.
Gotcha. Thank you for the info and context. I don’t plan on implementing support for this myself, but I would merge a suitable PR that does.
I don’t plan on implementing support for this myself, but I would merge a suitable PR that does.
Closing for now, but this statement is still true! 😄
Is it possible to add support for docblock annotations? For example:
So, anything starting with @ that is followed by an imported or fully qualified classname should be highlighed. And parameters passed to that annotation as well, much like the standard PHP 8 attributes highlight.
Is that possible?