2222use PhpStaticAnalysis \Attributes \PropertyRead ;
2323use PhpStaticAnalysis \Attributes \PropertyWrite ;
2424use PhpStaticAnalysis \Attributes \Returns ;
25+ use PhpStaticAnalysis \Attributes \SelfOut ;
2526use PhpStaticAnalysis \Attributes \Template ;
2627use PhpStaticAnalysis \Attributes \TemplateContravariant ;
2728use PhpStaticAnalysis \Attributes \TemplateCovariant ;
@@ -34,7 +35,8 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
3435{
3536 private const ARGS_NONE = 'none ' ;
3637 private const ARGS_ONE = 'one ' ;
37- private const ARGS_ONE_OPTIONAL = 'one_optional ' ;
38+ private const ARGS_ONE_OPTIONAL = 'one optional ' ;
39+ private const ARGS_ONE_WITH_PREFIX = 'one with prefix ' ;
3840 private const ARGS_TWO_WITH_TYPE = 'two with type ' ;
3941 private const ARGS_MANY_IN_USE = "many in use " ;
4042 private const ARGS_MANY_WITH_NAME = "many with name " ;
@@ -77,6 +79,7 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
7779 Param::class,
7880 ParamOut::class,
7981 Returns::class,
82+ SelfOut::class,
8083 Template::class,
8184 Type::class,
8285 ],
@@ -134,6 +137,7 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
134137 'PropertyRead ' => PropertyRead::class,
135138 'PropertyWrite ' => PropertyWrite::class,
136139 'Returns ' => Returns::class,
140+ 'SelfOut ' => SelfOut::class,
137141 'Template ' => Template::class,
138142 'TemplateContravariant ' => TemplateContravariant::class,
139143 'TemplateCovariant ' => TemplateCovariant::class,
@@ -178,6 +182,9 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
178182 Returns::class => [
179183 'all ' => 'return ' ,
180184 ],
185+ SelfOut::class => [
186+ 'all ' => 'self-out ' ,
187+ ],
181188 Template::class => [
182189 'all ' => 'template ' ,
183190 ],
@@ -239,6 +246,9 @@ class AttributeNodeVisitor extends NodeVisitorAbstract
239246 Returns::class => [
240247 'all ' => self ::ARGS_ONE ,
241248 ],
249+ SelfOut::class => [
250+ 'all ' => self ::ARGS_ONE_WITH_PREFIX ,
251+ ],
242252 Template::class => [
243253 'all ' => self ::ARGS_TWO_WITH_TYPE ,
244254 ],
@@ -318,6 +328,12 @@ public function enterNode(Node $node)
318328 $ tagCreated = true ;
319329 }
320330 break ;
331+ case self ::ARGS_ONE_WITH_PREFIX :
332+ if (isset ($ args [0 ])) {
333+ $ tagsToAdd [] = $ this ->createTag ($ nodeType , $ attributeName , $ args [0 ], prefix: $ this ->toolType );
334+ $ tagCreated = true ;
335+ }
336+ break ;
321337 case self ::ARGS_ONE_OPTIONAL :
322338 if (isset ($ args [0 ])) {
323339 $ tagsToAdd [] = $ this ->createTag (
@@ -393,7 +409,7 @@ private function createTag(
393409 } else {
394410 return '' ;
395411 }
396- if ($ prefix !== null ) {
412+ if ($ prefix !== null && $ prefix !== '' ) {
397413 $ tagName = $ prefix . '- ' . $ tagName ;
398414 }
399415 $ tag = '@ ' . $ tagName ;
0 commit comments