@@ -55,6 +55,7 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
5555 private const ARGS_TWO_WITH_TYPE = 'two with type ' ;
5656 private const ARGS_MANY_IN_USE = "many in use " ;
5757 private const ARGS_MANY_WITH_NAME = "many with name " ;
58+ private const ARGS_MANY_WITH_NAME_WITH_PREFIX = "many with name with prefix " ;
5859 private const ARGS_MANY_IN_TYPE = "many in type " ;
5960 private const ARGS_MANY_WITHOUT_NAME = "many without name " ;
6061 private const ARGS_MANY_WITHOUT_NAME_AND_PREFIX = "many without name and prexif " ;
@@ -246,6 +247,8 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
246247 ],
247248 Property::class => [
248249 Stmt \Class_::class => 'property ' ,
250+ Stmt \Interface_::class => 'property ' ,
251+ Stmt \Trait_::class => 'property ' ,
249252 Stmt \Property::class => 'var ' ,
250253 ],
251254 PropertyRead::class => [
@@ -301,13 +304,13 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
301304
302305 private const ARGUMENTS_PER_ATTRIBUTE = [
303306 Assert::class => [
304- 'all ' => self ::ARGS_MANY_WITH_NAME ,
307+ 'all ' => self ::ARGS_MANY_WITH_NAME_WITH_PREFIX ,
305308 ],
306309 AssertIfFalse::class => [
307- 'all ' => self ::ARGS_MANY_WITH_NAME ,
310+ 'all ' => self ::ARGS_MANY_WITH_NAME_WITH_PREFIX ,
308311 ],
309312 AssertIfTrue::class => [
310- 'all ' => self ::ARGS_MANY_WITH_NAME ,
313+ 'all ' => self ::ARGS_MANY_WITH_NAME_WITH_PREFIX ,
311314 ],
312315 DefineType::class => [
313316 'all ' => self ::ARGS_MANY_IN_TYPE ,
@@ -344,6 +347,8 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
344347 ],
345348 Property::class => [
346349 Stmt \Class_::class => self ::ARGS_MANY_WITH_NAME ,
350+ Stmt \Interface_::class => self ::ARGS_MANY_WITH_NAME ,
351+ Stmt \Trait_::class => self ::ARGS_MANY_WITH_NAME ,
347352 Stmt \Property::class => self ::ARGS_ONE ,
348353 ],
349354 PropertyRead::class => [
@@ -425,9 +430,9 @@ public function enterNode(Node $node)
425430
426431 $ this ->initPositions ();
427432
428- foreach ($ attributeGroups as $ attributeGroup ) {
433+ foreach ($ attributeGroups as $ groupKey => $ attributeGroup ) {
429434 $ attributes = $ attributeGroup ->attrs ;
430- foreach ($ attributes as $ attribute ) {
435+ foreach ($ attributes as $ key => $ attribute ) {
431436 $ attributeName = $ attribute ->name ->toString ();
432437 $ attributeName = self ::SHORT_NAME_TO_FQN [$ attributeName ] ?? $ attributeName ;
433438 if (
@@ -473,7 +478,7 @@ public function enterNode(Node $node)
473478 $ nodeType ,
474479 $ attributeName ,
475480 $ args [0 ],
476- prefix: $ this -> toolType === self ::TOOL_PSALM ? $ this -> toolType : null
481+ prefix: self ::TOOL_PSALM
477482 );
478483 } else {
479484 $ tagsToAdd [] = $ this ->createTag ($ nodeType , $ attributeName );
@@ -492,6 +497,12 @@ public function enterNode(Node $node)
492497 $ tagCreated = true ;
493498 }
494499 break ;
500+ case self ::ARGS_MANY_WITH_NAME_WITH_PREFIX :
501+ foreach ($ args as $ arg ) {
502+ $ tagsToAdd [] = $ this ->createTag ($ nodeType , $ attributeName , $ arg , useName: true , prefix: $ this ->toolType );
503+ $ tagCreated = true ;
504+ }
505+ break ;
495506 case self ::ARGS_MANY_WITHOUT_NAME :
496507 foreach ($ args as $ arg ) {
497508 $ tagsToAdd [] = $ this ->createTag ($ nodeType , $ attributeName , $ arg );
@@ -509,6 +520,7 @@ public function enterNode(Node $node)
509520 if ($ arg ->value instanceof String_) {
510521 $ useValue = $ arg ->value ->value ;
511522 $ useTagsToAdd [$ useValue ] = $ this ->createTag ($ nodeType , $ attributeName , $ arg );
523+ $ tagCreated = true ;
512524 }
513525 }
514526 break ;
@@ -521,10 +533,17 @@ public function enterNode(Node $node)
521533 }
522534 if ($ tagCreated ) {
523535 $ this ->updatePositions ($ attribute );
536+ unset($ attributes [$ key ]);
524537 }
525538 }
526539 }
540+ if ($ attributes === []) {
541+ unset($ attributeGroups [$ groupKey ]);
542+ } else {
543+ $ attributeGroup ->attrs = $ attributes ;
544+ }
527545 }
546+ $ node ->attrGroups = $ attributeGroups ;
528547 if ($ node instanceof Stmt \ClassMethod || $ node instanceof Stmt \Function_) {
529548 $ tagsToAdd = array_merge ($ tagsToAdd , $ this ->getParamTagsFromParams ($ node ));
530549 }
@@ -541,11 +560,11 @@ public function enterNode(Node $node)
541560 private function createTag (
542561 string $ nodeType ,
543562 string $ attributeName ,
544- Arg $ argument = null ,
545- Arg $ of = null ,
563+ ? Arg $ argument = null ,
564+ ? Arg $ of = null ,
546565 bool $ useName = false ,
547- string $ nameToUse = null ,
548- string $ prefix = null ,
566+ ? string $ nameToUse = null ,
567+ ? string $ prefix = null ,
549568 bool $ prefixWithName = false
550569 ): string {
551570 if (array_key_exists ($ nodeType , self ::ANNOTATION_PER_ATTRIBUTE [$ attributeName ])) {
0 commit comments