File tree Expand file tree Collapse file tree 5 files changed +74
-2
lines changed Expand file tree Collapse file tree 5 files changed +74
-2
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ composer require type-lang/phpdoc
3333## Supported Tags
3434
3535- [x] ` @abstract ` - Declare any _ Symbol_ as abstract
36- - [ ] ` @api ` - TODO
36+ - [x ] ` @api ` - Highlight _ Symbol _ as being part of the public API
3737- [ ] ` @author ` - TODO
3838- [ ] ` @category ` - TODO
3939- [ ] ` @copyright ` - TODO
@@ -103,7 +103,7 @@ composer require type-lang/phpdoc
103103### Psalm Tags
104104
105105- [ ] ` @psalm-allow-private-mutation ` - TODO
106- - [ ] ` @psalm-api ` - TODO
106+ - [x ] ` @psalm-api ` - Vendor-specific ` @api ` alias
107107- [ ] ` @psalm-assert ` - TODO
108108- [ ] ` @psalm-assert-if-false ` - TODO
109109- [ ] ` @psalm-assert-if-true ` - TODO
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace TypeLang \PHPDoc \DocBlock \Tag \ApiTag ;
6+
7+ use TypeLang \PHPDoc \DocBlock \Tag \Tag ;
8+
9+ /**
10+ * Used to highlight _Symbol_ as being part of the primary
11+ * public API of a package.
12+ *
13+ * The "`@api`" tag may be applied to public _Symbol_ to highlight them
14+ * in generated documentation, pointing the consumer to the primary public
15+ * API components of a library or framework.
16+ *
17+ * When the "`@api`" tag is used, other _Symbol_ with a public
18+ * visibility serve to support the internal structure and
19+ * are not recommended to be used by the consumer.
20+ *
21+ * The exact meaning of _Symbol_ tagged with "`@api`" MAY differ per project.
22+ * It is however RECOMMENDED that all "`@api`" tagged _Symbol_ SHOULD
23+ * NOT change after publication unless the new version
24+ * is tagged as breaking Backwards Compatibility.
25+ *
26+ * See also the `"@internal"` tag, which can be used to hide internal
27+ * _Symbol_ from generated documentation.
28+ *
29+ * ```
30+ * "@api" [<description>]
31+ * ```
32+ */
33+ final class ApiTag extends Tag
34+ {
35+ public function __construct (
36+ string $ name ,
37+ \Stringable |string |null $ description = null ,
38+ ) {
39+ parent ::__construct ($ name , $ description );
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace TypeLang \PHPDoc \DocBlock \Tag \ApiTag ;
6+
7+ use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
8+ use TypeLang \PHPDoc \Parser \Content \Stream ;
9+ use TypeLang \PHPDoc \Parser \Description \DescriptionParserInterface ;
10+
11+ /**
12+ * This class is responsible for creating "`@api`" tags.
13+ *
14+ * See {@see ApiTag} for details about this tag.
15+ */
16+ final class ApiTagFactory implements TagFactoryInterface
17+ {
18+ public function create (string $ tag , string $ content , DescriptionParserInterface $ descriptions ): ApiTag
19+ {
20+ $ stream = new Stream ($ tag , $ content );
21+
22+ return new ApiTag (
23+ name: $ tag ,
24+ description: $ stream ->toOptionalDescription ($ descriptions ),
25+ );
26+ }
27+ }
Original file line number Diff line number Diff line change 55namespace TypeLang \PHPDoc \Platform ;
66
77use TypeLang \Parser \ParserInterface as TypesParserInterface ;
8+ use TypeLang \PHPDoc \DocBlock \Tag \ApiTag \ApiTagFactory ;
89use TypeLang \PHPDoc \DocBlock \Tag \MethodTag \MethodTagFactory ;
910use TypeLang \PHPDoc \DocBlock \Tag \ParamTag \ParamTagFactory ;
1011use TypeLang \PHPDoc \DocBlock \Tag \PropertyTag \PropertyReadTagFactory ;
@@ -27,6 +28,7 @@ public function getName(): string
2728
2829 protected function load (TypesParserInterface $ types ): iterable
2930 {
31+ yield 'psalm-api ' => new ApiTagFactory ();
3032 yield 'psalm-method ' => new MethodTagFactory ($ types );
3133 yield 'psalm-param ' => new ParamTagFactory ($ types );
3234 yield 'psalm-property ' => new PropertyTagFactory ($ types );
Original file line number Diff line number Diff line change 66
77use TypeLang \Parser \ParserInterface as TypesParserInterface ;
88use TypeLang \PHPDoc \DocBlock \Tag \AbstractTag \AbstractTagFactory ;
9+ use TypeLang \PHPDoc \DocBlock \Tag \ApiTag \ApiTagFactory ;
910use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
1011use TypeLang \PHPDoc \DocBlock \Tag \FinalTag \FinalTagFactory ;
1112use TypeLang \PHPDoc \DocBlock \Tag \IgnoreTag \IgnoreTagFactory ;
@@ -38,6 +39,7 @@ public function getName(): string
3839 protected function load (TypesParserInterface $ types ): iterable
3940 {
4041 yield 'abstract ' => new AbstractTagFactory ();
42+ yield 'api ' => new ApiTagFactory ();
4143 yield 'extends ' => new TemplateExtendsTagFactory ($ types );
4244 yield 'final ' => new FinalTagFactory ();
4345 yield 'implements ' => new TemplateImplementsTagFactory ($ types );
You can’t perform that action at this time.
0 commit comments