@@ -474,7 +474,7 @@ public function validate(array $stack = [], array $skip = [], string $ref = '',
474474 } elseif (Generator::isDefault ($ item ->{$ keyField })) {
475475 $ this ->_context ->logger ->error ($ item ->identity () . ' is missing key-field: " ' . $ keyField . '" in ' . $ item ->_context );
476476 } elseif (isset ($ keys [$ item ->{$ keyField }])) {
477- $ this ->_context ->logger ->error ('Multiple ' . $ item ->_identity ([]) . ' with the same ' . $ keyField . '=" ' . $ item ->{$ keyField } . "\": \n " . $ item ->_context . "\n " . $ keys [$ item ->{$ keyField }]->_context );
477+ $ this ->_context ->logger ->error ('Multiple ' . $ item ->identity ([]) . ' with the same ' . $ keyField . '=" ' . $ item ->{$ keyField } . "\": \n " . $ item ->_context . "\n " . $ keys [$ item ->{$ keyField }]->_context );
478478 } else {
479479 $ keys [$ item ->{$ keyField }] = $ item ;
480480 }
@@ -583,24 +583,37 @@ private static function _validate($fields, array $stack, array $skip, string $ba
583583 }
584584
585585 /**
586- * Return a identity for easy debugging.
587- * Example: "@OA\Get(path="/pets")".
586+ * Return a simple string representation of the annotation.
587+ *
588+ * @param array|null $properties the properties to include in the string representation
589+ * @example "@OA\Response(response=200)"
588590 */
589- public function identity (): string
591+ public function identity (? array $ properties = null ): string
590592 {
591593 $ class = static ::class;
592- $ properties = [];
593- /** @var class-string<AbstractAnnotation> $parent */
594- foreach (static ::$ _parents as $ parent ) {
595- foreach ($ parent ::$ _nested as $ annotationClass => $ entry ) {
596- if ($ annotationClass === $ class && is_array ($ entry ) && !Generator::isDefault ($ this ->{$ entry [1 ]})) {
597- $ properties [] = $ entry [1 ];
598- break 2 ;
594+
595+ if (null === $ properties ) {
596+ $ properties = [];
597+ /** @var class-string<AbstractAnnotation> $parent */
598+ foreach (static ::$ _parents as $ parent ) {
599+ foreach ($ parent ::$ _nested as $ annotationClass => $ entry ) {
600+ if ($ annotationClass === $ class && is_array ($ entry ) && !Generator::isDefault ($ this ->{$ entry [1 ]})) {
601+ $ properties [] = $ entry [1 ];
602+ break 2 ;
603+ }
599604 }
600605 }
601606 }
602607
603- return $ this ->_identity ($ properties );
608+ $ details = [];
609+ foreach ($ properties as $ property ) {
610+ $ value = $ this ->{$ property };
611+ if ($ value !== null && !Generator::isDefault ($ value )) {
612+ $ details [] = $ property . '= ' . (is_string ($ value ) ? '" ' . $ value . '" ' : $ value );
613+ }
614+ }
615+
616+ return static ::shorten (static ::class) . '( ' . implode (', ' , $ details ) . ') ' ;
604617 }
605618
606619 /**
@@ -650,22 +663,6 @@ public function isRoot(string $rootClass): bool
650663 return static ::class === $ rootClass || $ this ->getRoot () === $ rootClass ;
651664 }
652665
653- /**
654- * Helper for generating the identity().
655- */
656- protected function _identity (array $ properties ): string
657- {
658- $ fields = [];
659- foreach ($ properties as $ property ) {
660- $ value = $ this ->{$ property };
661- if ($ value !== null && !Generator::isDefault ($ value )) {
662- $ fields [] = $ property . '= ' . (is_string ($ value ) ? '" ' . $ value . '" ' : $ value );
663- }
664- }
665-
666- return static ::shorten (static ::class) . '( ' . implode (', ' , $ fields ) . ') ' ;
667- }
668-
669666 /**
670667 * Validates the matching of the property value to a annotation type.
671668 *
0 commit comments