You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bbaf88a
Browse filesBrowse the repository at this point in the historyBrowse files
Allow configuring custom PHPDoc tags that reference classes
In our project we use a custom PHPDoc tag `@throwable-from` paired with a
PHPStan rule that validates the referenced class and method exist. For example:
```php
/**
* @throwable-from NotificationHandler::createPayload
* @throwable-from UserSpecificPayloadNotificationHandler::createPayloadForUser
*/
final class MessageShouldBeIgnoredException extends Exception
```
Rector's unused import removal does not recognize class references in custom
PHPDoc tags and removes the corresponding use statements. The class resolver
in PhpDocTagGenericUsesDecorator was hardcoded to only `@uses`, `@used-by`,
and `@see`.
This adds a configurable list of additional PHPDoc tag names that should be
treated as containing class references, so their imports are preserved:
```php
RectorConfig::configure()
->withPhpDocTagsWithClassReference(['@throwable-from']);
```
0 commit comments