Skip to content

Commit 9910fd1

Browse files
committed
Add tags list into readme and vendor-specific platforms
1 parent 13203e3 commit 9910fd1

11 files changed

+493
-13
lines changed

Diff for: README.md

+217-9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,216 @@ be installed using the following command in a root of your project:
3030
composer require type-lang/phpdoc
3131
```
3232

33+
## Supported Tags
34+
35+
- [ ] `@abstract` - TODO
36+
- [ ] `@api` - TODO
37+
- [ ] `@author` - TODO
38+
- [ ] `@category` - TODO
39+
- [ ] `@copyright` - TODO
40+
- [ ] `@deprecated` - TODO
41+
- [ ] `@example` - TODO
42+
- [x] `@extends` - Allows to extend templated classes and interfaces
43+
- [ ] `@filesource` - TODO
44+
- [ ] `@final` - TODO
45+
- [ ] `@global` - TODO
46+
- [ ] `@ignore` - TODO
47+
- [x] `@implements` - Allows to extend templated interfaces
48+
- [ ] `@inheritdoc` - TODO
49+
- [x] `@inherits` - An alias of `@extends` tag
50+
- [ ] `@internal` - TODO
51+
- [ ] `@license` - TODO
52+
- [x] `@link` - Indicates a custom relation between the associated _Symbol_ and a website, which is identified by an absolute URI
53+
- [x] `@method` - Allows a class to know which "_magic_" methods are callable
54+
- [ ] `@mixin` - TODO
55+
- [ ] `@no-named-arguments` - TODO
56+
- [ ] `@package` - TODO
57+
- [ ] `@override` - TODO
58+
- [x] `@param` - Used to document a single argument of a function or method
59+
- [ ] `@param-closure-this` - TODO
60+
- [ ] `@param-immediately-invoked-callable` - TODO
61+
- [ ] `@param-later-invoked-callable` - TODO
62+
- [ ] `@param-out` - TODO
63+
- [x] `@property` - Used to declare which "_magic_" properties are supported
64+
- [x] `@property-read` - Used to declare which "_magic_" properties are supported for reading
65+
- [x] `@property-write` - Used to declare which "_magic_" properties are supported for writing
66+
- [ ] `@pure-unless-callable-is-impure` - TODO
67+
- [ ] `@readonly` - TODO
68+
- [ ] `@require-extends` - TODO
69+
- [ ] `@require-implements` - TODO
70+
- [x] `@return` - Used to document the return value of functions or methods
71+
- [x] `@returns` - An alias of `@return` tag
72+
- [ ] `@seal-methods` - TODO
73+
- [ ] `@seal-properties` - TODO
74+
- [x] `@see` - Indicates a reference from the associated _Symbol(s)_ to a website or other _Symbol(s)_
75+
- [ ] `@since` - TODO
76+
- [ ] `@source` - TODO
77+
- [ ] `@subpackage` - TODO
78+
- [ ] `@suppress` - TODO
79+
- [x] `@template` - Allows classes (and class-like entries), functions and methods to declare a generic type parameter
80+
- [x] `@template-contravariant` - Allows classes (and class-like entries), functions and methods to declare a generic contravariant type parameter
81+
- [x] `@template-covariant` - Allows classes (and class-like entries), functions and methods to declare a generic covariant type parameter
82+
- [x] `@template-extends` - An alias of `@extends` tag
83+
- [x] `@template-implements` - An alias of `@implements` tag
84+
- [x] `@template-use` - Allows to extend templated traits
85+
- [x] `@throw` - An alias of `@throws` tag
86+
- [x] `@throws` - Used to indicate whether _Symbol_ throw a specific type of `\Throwable` (exception or error)
87+
- [ ] `@todo` - TODO
88+
- [ ] `@unused-param` - TODO
89+
- [x] `@use` - An alias of `@template-use` tag
90+
- [ ] `@used-by` - TODO
91+
- [ ] `@uses` - TODO
92+
- [x] `@var` - Document the _Type_ of the following _Symbol_
93+
- [ ] `@version` - TODO
94+
95+
### Psalm Tags
96+
97+
- [ ] `@psalm-allow-private-mutation` - TODO
98+
- [ ] `@psalm-api` - TODO
99+
- [ ] `@psalm-assert` - TODO
100+
- [ ] `@psalm-assert-if-false` - TODO
101+
- [ ] `@psalm-assert-if-true` - TODO
102+
- [ ] `@psalm-assert-untainted` - TODO
103+
- [ ] `@psalm-check-type` - TODO
104+
- [ ] `@psalm-check-type-exact` - TODO
105+
- [ ] `@psalm-consistent-constructor` - TODO
106+
- [ ] `@psalm-consistent-templates` - TODO
107+
- [ ] `@psalm-external-mutation-free` - TODO
108+
- [x] `@psalm-extends` - Vendor-specific `@extends` alias
109+
- [ ] `@psalm-flow` - TODO
110+
- [ ] `@psalm-if-this-is` - TODO
111+
- [ ] `@psalm-ignore-falsable-return` - TODO
112+
- [ ] `@psalm-ignore-nullable-return` - TODO
113+
- [ ] `@psalm-ignore-var` - TODO
114+
- [ ] `@psalm-ignore-variable-method` - TODO
115+
- [ ] `@psalm-ignore-variable-property` - TODO
116+
- [ ] `@psalm-immutable` - TODO
117+
- [x] `@psalm-implements` - Vendor-specific `@implements` alias
118+
- [ ] `@psalm-import-type` - TODO
119+
- [ ] `@psalm-inheritors` - TODO
120+
- [ ] `@psalm-internal` - TODO
121+
- [x] `@psalm-method` - Vendor-specific `@method` alias
122+
- [ ] `@psalm-mutation-free` - TODO
123+
- [ ] `@psalm-no-seal-methods` - TODO
124+
- [ ] `@psalm-no-seal-properties` - TODO
125+
- [ ] `@psalm-override-method-visibility` - TODO
126+
- [ ] `@psalm-override-property-visibility` - TODO
127+
- [x] `@psalm-param` - Vendor-specific `@param` alias
128+
- [ ] `@psalm-param-out` - TODO
129+
- [x] `@psalm-property` - Vendor-specific `@property` alias
130+
- [x] `@psalm-property-read` - Vendor-specific `@property-read` alias
131+
- [x] `@psalm-property-write` - Vendor-specific `@property-write` alias
132+
- [ ] `@psalm-pure` - TODO
133+
- [ ] `@psalm-readonly` - TODO
134+
- [ ] `@psalm-readonly-allow-private-mutation` - TODO
135+
- [ ] `@psalm-require-extends` - TODO
136+
- [ ] `@psalm-require-implements` - TODO
137+
- [x] `@psalm-return` - Vendor-specific `@return` alias
138+
- [ ] `@psalm-scope-this` - TODO
139+
- [ ] `@psalm-seal-methods` - TODO
140+
- [ ] `@psalm-seal-properties` - TODO
141+
- [ ] `@psalm-self-out` - TODO
142+
- [ ] `@psalm-stub-override` - TODO
143+
- [ ] `@psalm-suppress` - TODO
144+
- [ ] `@psalm-taint-escape` - TODO
145+
- [ ] `@psalm-taint-sink` - TODO
146+
- [ ] `@psalm-taint-source` - TODO
147+
- [ ] `@psalm-taint-specialize` - TODO
148+
- [ ] `@psalm-taint-unescape` - TODO
149+
- [x] `@psalm-template` - Vendor-specific `@template` alias
150+
- [x] `@psalm-template-contravariant` - Vendor-specific `@template-contravariant` alias
151+
- [x] `@psalm-template-covariant` - Vendor-specific `@template-covariant` alias
152+
- [ ] `@psalm-this-out` - TODO
153+
- [ ] `@psalm-trace` - TODO
154+
- [ ] `@psalm-type` - TODO
155+
- [x] `@psalm-use` - Vendor-specific `@use` alias
156+
- [x] `@psalm-var` - Vendor-specific `@var` alias
157+
- [ ] `@psalm-variadic` - TODO
158+
- [ ] `@psalm-yield` - TODO
159+
160+
### PHPStan Tags
161+
162+
- [ ] `@phpstan-allow-private-mutation` - TODO
163+
- [ ] `@phpstan-assert` - TODO
164+
- [ ] `@phpstan-assert-if-false` - TODO
165+
- [ ] `@phpstan-assert-if-true` - TODO
166+
- [ ] `@phpstan-consistent-constructor` - TODO
167+
- [ ] `@phpstan-extends` - TODO
168+
- [ ] `@phpstan-ignore` - TODO
169+
- [ ] `@phpstan-ignore-line` - TODO
170+
- [ ] `@phpstan-ignore-next-line` - TODO
171+
- [ ] `@phpstan-immutable` - TODO
172+
- [ ] `@phpstan-implements` - TODO
173+
- [ ] `@phpstan-import-type` - TODO
174+
- [ ] `@phpstan-impure` - TODO
175+
- [x] `@phpstan-method` - Vendor-specific `@method` alias
176+
- [x] `@phpstan-param` - Vendor-specific `@param` alias
177+
- [ ] `@phpstan-param-closure-this` - TODO
178+
- [ ] `@phpstan-param-immediately-invoked-callable` - TODO
179+
- [ ] `@phpstan-param-later-invoked-callable` - TODO
180+
- [ ] `@phpstan-param-out` - TODO
181+
- [ ] `@phpstan-property` - Vendor-specific `@property` alias
182+
- [ ] `@phpstan-property-read` - Vendor-specific `@property-read` alias
183+
- [ ] `@phpstan-property-write` - Vendor-specific `@property-write` alias
184+
- [ ] `@phpstan-pure` - TODO
185+
- [ ] `@phpstan-pure-unless-callable-is-impure` - TODO
186+
- [ ] `@phpstan-readonly` - TODO
187+
- [ ] `@phpstan-readonly-allow-private-mutation` - TODO
188+
- [ ] `@phpstan-require-extends` - TODO
189+
- [ ] `@phpstan-require-implements` - TODO
190+
- [ ] `@phpstan-return` - Vendor-specific `@return` alias
191+
- [ ] `@phpstan-self-out` - TODO
192+
- [x] `@phpstan-template` - Vendor-specific `@template` alias
193+
- [x] `@phpstan-template-contravariant` - Vendor-specific `@template-contravariant` alias
194+
- [x] `@phpstan-template-covariant` - Vendor-specific `@template-covariant` alias
195+
- [ ] `@phpstan-this-out` - TODO
196+
- [x] `@phpstan-throws` - Vendor-specific `@throws` alias
197+
- [ ] `@phpstan-type` - TODO
198+
- [ ] `@phpstan-use` - TODO
199+
- [x] `@phpstan-var` - Vendor-specific `@var` alias
200+
201+
### Phan Tags
202+
203+
- [ ] `@phan-abstract` - TODO
204+
- [ ] `@phan-assert` - TODO
205+
- [ ] `@phan-assert-false-condition` - TODO
206+
- [ ] `@phan-assert-if-false` - TODO
207+
- [ ] `@phan-assert-if-true` - TODO
208+
- [ ] `@phan-assert-true-condition` - TODO
209+
- [ ] `@phan-closure-scope` - TODO
210+
- [ ] `@phan-constructor-used-for-side-effects` - TODO
211+
- [x] `@phan-extends` - Vendor-specific `@extends` alias
212+
- [ ] `@phan-file-suppress` - TODO
213+
- [ ] `@phan-forbid-undeclared-magic-methods` - TODO
214+
- [ ] `@phan-forbid-undeclared-magic-properties` - TODO
215+
- [ ] `@phan-hardcode-return-type` - TODO
216+
- [ ] `@phan-immutable` - TODO
217+
- [x] `@phan-inherits` - Vendor-specific `@extends` alias
218+
- [x] `@phan-method` - Vendor-specific `@method` alias
219+
- [ ] `@phan-mixin` - TODO
220+
- [ ] `@phan-output-reference` - TODO
221+
- [ ] `@phan-override` - TODO
222+
- [x] `@phan-param` - Vendor-specific `@param` alias
223+
- [x] `@phan-property` - Vendor-specific `@property` alias
224+
- [x] `@phan-property-read` - Vendor-specific `@property-read` alias
225+
- [x] `@phan-property-write` - Vendor-specific `@property-write` alias
226+
- [ ] `@phan-pure` - TODO
227+
- [ ] `@phan-read-only` - TODO
228+
- [ ] `@phan-real-return` - TODO
229+
- [x] `@phan-return` - Vendor-specific `@return` alias
230+
- [ ] `@phan-side-effect-free` - TODO
231+
- [ ] `@phan-suppress-current-line` - TODO
232+
- [ ] `@phan-suppress-next-line` - TODO
233+
- [ ] `@phan-suppress-next-next-line` - TODO
234+
- [ ] `@phan-suppress-previous-line` - TODO
235+
- [x] `@phan-template` - Vendor-specific `@template` alias
236+
- [ ] `@phan-transient` - TODO
237+
- [ ] `@phan-type` - TODO
238+
- [ ] `@phan-unused-param` - TODO
239+
- [x] `@phan-var` - Vendor-specific `@var` alias
240+
- [ ] `@phan-write-only` - TODO
241+
- [ ] `@phanclosurescope` - TODO
242+
33243
## Quick Start
34244

35245
```php
@@ -56,19 +266,17 @@ TypeLang\PHPDoc\DocBlock\DocBlock {
56266
0 => TypeLang\PHPDoc\DocBlock\Description\Description {
57267
#value: "Example description "
58268
}
59-
1 => TypeLang\PHPDoc\DocBlock\Tag\Tag {
60-
+description: TypeLang\PHPDoc\DocBlock\Description\Description {
61-
#value: "some"
62-
}
269+
1 => TypeLang\PHPDoc\DocBlock\Tag\SeeTag\SeeTag {
270+
+description: null
63271
+name: "see"
272+
+ref: TypeLang\PHPDoc\DocBlock\Tag\Shared\Reference\TypeSymbolReference {
273+
+type: TypeLang\Parser\Node\Stmt\NamedTypeNode { … }
274+
}
64275
}
65276
2 => TypeLang\PHPDoc\DocBlock\Description\Description {
66277
#value: " and blah-blah-blah.\n"
67278
}
68279
]
69-
+tags: array:1 [
70-
0 => TypeLang\PHPDoc\DocBlock\Tag\Tag {}
71-
]
72280
}
73281
+tags: array:3 [
74282
0 => TypeLang\PHPDoc\DocBlock\Tag\Tag {
@@ -80,12 +288,12 @@ TypeLang\PHPDoc\DocBlock\DocBlock {
80288
1 => TypeLang\PHPDoc\DocBlock\Tag\ReturnTag\ReturnTag {
81289
+description: null
82290
+name: "return"
83-
+type: TypeLang\Parser\Node\Stmt\NamedTypeNode { ... }
291+
+type: TypeLang\Parser\Node\Stmt\NamedTypeNode { }
84292
}
85293
2 => TypeLang\PHPDoc\DocBlock\Tag\ThrowsTag\ThrowsTag {
86294
+description: null
87295
+name: "throws"
88-
+type: TypeLang\Parser\Node\Stmt\NamedTypeNode { ... }
296+
+type: TypeLang\Parser\Node\Stmt\NamedTypeNode { }
89297
}
90298
]
91299
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\TemplateExtendsTag;
6+
7+
/**
8+
* ```
9+
*
10+
* * @template-use <Type> [<description>]
11+
*
12+
* * @use <Type> [<description>]
13+
* ```
14+
*/
15+
class TemplateUseTag extends TemplateInheritanceTag {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\TemplateExtendsTag;
6+
7+
use TypeLang\Parser\Parser as TypesParser;
8+
use TypeLang\Parser\ParserInterface as TypesParserInterface;
9+
use TypeLang\PHPDoc\DocBlock\Tag\Factory\TagFactoryInterface;
10+
use TypeLang\PHPDoc\Parser\Description\DescriptionParserInterface;
11+
12+
/**
13+
* This class is responsible for creating "`@use`"
14+
* or "`@template-use`" tags.
15+
*
16+
* See {@see TemplateUseTag} for details about this tag.
17+
*/
18+
final class TemplateUseTagFactory implements TagFactoryInterface
19+
{
20+
private readonly TemplateExtendsTagFactory $factory;
21+
22+
public function __construct(
23+
TypesParserInterface $parser = new TypesParser(tolerant: true),
24+
) {
25+
$this->factory = new TemplateExtendsTagFactory($parser);
26+
}
27+
28+
public function create(string $tag, string $content, DescriptionParserInterface $descriptions): TemplateUseTag
29+
{
30+
$result = $this->factory->create($tag, $content, $descriptions);
31+
32+
return new TemplateUseTag(
33+
name: $result->name,
34+
type: $result->type,
35+
description: $result->description,
36+
);
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\TemplateTag;
6+
7+
final class TemplateContravariantTag extends TemplateTag {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TypeLang\PHPDoc\DocBlock\Tag\TemplateTag;
6+
7+
use TypeLang\Parser\Parser as TypesParser;
8+
use TypeLang\Parser\ParserInterface as TypesParserInterface;
9+
use TypeLang\PHPDoc\DocBlock\Tag\Factory\TagFactoryInterface;
10+
use TypeLang\PHPDoc\Parser\Description\DescriptionParserInterface;
11+
12+
/**
13+
* This class is responsible for creating "`@template-contravariant`" tags.
14+
*
15+
* See {@see TemplateContravariantTag} for details about this tag.
16+
*/
17+
final class TemplateContravariantTagFactory implements TagFactoryInterface
18+
{
19+
private readonly TemplateTagFactory $factory;
20+
21+
public function __construct(
22+
TypesParserInterface $parser = new TypesParser(tolerant: true),
23+
) {
24+
$this->factory = new TemplateTagFactory($parser);
25+
}
26+
27+
public function create(string $tag, string $content, DescriptionParserInterface $descriptions): TemplateContravariantTag
28+
{
29+
$result = $this->factory->create($tag, $content, $descriptions);
30+
31+
return new TemplateContravariantTag(
32+
name: $result->name,
33+
template: $result->template,
34+
type: $result->type,
35+
description: $result->description,
36+
);
37+
}
38+
}

Diff for: src/Parser.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@
1818
use TypeLang\PHPDoc\Parser\SourceMap;
1919
use TypeLang\PHPDoc\Parser\Tag\RegexTagParser;
2020
use TypeLang\PHPDoc\Parser\Tag\TagParserInterface;
21+
use TypeLang\PHPDoc\Platform\CompoundPlatform;
22+
use TypeLang\PHPDoc\Platform\FallbacksPlatform;
23+
use TypeLang\PHPDoc\Platform\PhanPlatform;
24+
use TypeLang\PHPDoc\Platform\PHPStanPlatform;
2125
use TypeLang\PHPDoc\Platform\PlatformInterface;
26+
use TypeLang\PHPDoc\Platform\PsalmPlatform;
2227
use TypeLang\PHPDoc\Platform\StandardPlatform;
2328

2429
class Parser implements ParserInterface
@@ -32,7 +37,13 @@ class Parser implements ParserInterface
3237
private readonly MutableTagFactoryInterface $factories;
3338

3439
public function __construct(
35-
public readonly PlatformInterface $platform = new StandardPlatform(),
40+
public readonly PlatformInterface $platform = new CompoundPlatform([
41+
new StandardPlatform(),
42+
new PsalmPlatform(),
43+
new PHPStanPlatform(),
44+
new PhanPlatform(),
45+
new FallbacksPlatform(),
46+
]),
3647
) {
3748
$this->factories = new TagFactory($platform->getTags());
3849
$this->tags = $this->createTagParser($this->factories);

0 commit comments

Comments
 (0)