File tree 5 files changed +74
-2
lines changed
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
33
33
## Supported Tags
34
34
35
35
- [x] ` @abstract ` - Declare any _ Symbol_ as abstract
36
- - [ ] ` @api ` - TODO
36
+ - [x ] ` @api ` - Highlight _ Symbol _ as being part of the public API
37
37
- [ ] ` @author ` - TODO
38
38
- [ ] ` @category ` - TODO
39
39
- [ ] ` @copyright ` - TODO
@@ -103,7 +103,7 @@ composer require type-lang/phpdoc
103
103
### Psalm Tags
104
104
105
105
- [ ] ` @psalm-allow-private-mutation ` - TODO
106
- - [ ] ` @psalm-api ` - TODO
106
+ - [x ] ` @psalm-api ` - Vendor-specific ` @api ` alias
107
107
- [ ] ` @psalm-assert ` - TODO
108
108
- [ ] ` @psalm-assert-if-false ` - TODO
109
109
- [ ] ` @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 5
5
namespace TypeLang \PHPDoc \Platform ;
6
6
7
7
use TypeLang \Parser \ParserInterface as TypesParserInterface ;
8
+ use TypeLang \PHPDoc \DocBlock \Tag \ApiTag \ApiTagFactory ;
8
9
use TypeLang \PHPDoc \DocBlock \Tag \MethodTag \MethodTagFactory ;
9
10
use TypeLang \PHPDoc \DocBlock \Tag \ParamTag \ParamTagFactory ;
10
11
use TypeLang \PHPDoc \DocBlock \Tag \PropertyTag \PropertyReadTagFactory ;
@@ -27,6 +28,7 @@ public function getName(): string
27
28
28
29
protected function load (TypesParserInterface $ types ): iterable
29
30
{
31
+ yield 'psalm-api ' => new ApiTagFactory ();
30
32
yield 'psalm-method ' => new MethodTagFactory ($ types );
31
33
yield 'psalm-param ' => new ParamTagFactory ($ types );
32
34
yield 'psalm-property ' => new PropertyTagFactory ($ types );
Original file line number Diff line number Diff line change 6
6
7
7
use TypeLang \Parser \ParserInterface as TypesParserInterface ;
8
8
use TypeLang \PHPDoc \DocBlock \Tag \AbstractTag \AbstractTagFactory ;
9
+ use TypeLang \PHPDoc \DocBlock \Tag \ApiTag \ApiTagFactory ;
9
10
use TypeLang \PHPDoc \DocBlock \Tag \Factory \TagFactoryInterface ;
10
11
use TypeLang \PHPDoc \DocBlock \Tag \FinalTag \FinalTagFactory ;
11
12
use TypeLang \PHPDoc \DocBlock \Tag \IgnoreTag \IgnoreTagFactory ;
@@ -38,6 +39,7 @@ public function getName(): string
38
39
protected function load (TypesParserInterface $ types ): iterable
39
40
{
40
41
yield 'abstract ' => new AbstractTagFactory ();
42
+ yield 'api ' => new ApiTagFactory ();
41
43
yield 'extends ' => new TemplateExtendsTagFactory ($ types );
42
44
yield 'final ' => new FinalTagFactory ();
43
45
yield 'implements ' => new TemplateImplementsTagFactory ($ types );
You can’t perform that action at this time.
0 commit comments