Skip to content

Commit aa2fd14

Browse files
committed
Add psalm flow tag
1 parent 1d70f07 commit aa2fd14

10 files changed

Lines changed: 107 additions & 84 deletions

Writerside/tl.tree

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@
145145
<toc-element topic="psalm-assert-if-false-tag.md" />
146146
<toc-element topic="psalm-assert-if-true-tag.md" />
147147
<toc-element topic="psalm-assert-untainted-tag.md" />
148-
<toc-element topic="psalm-check-type-tag.md" wip="true" />
149-
<toc-element topic="psalm-check-type-exact-tag.md" wip="true" />
148+
<toc-element topic="psalm-check-type-tag.md" />
149+
<toc-element topic="psalm-check-type-exact-tag.md" />
150150
<toc-element topic="psalm-consistent-constructor-tag.md" />
151151
<toc-element topic="psalm-consistent-templates-tag.md" />
152152
<toc-element topic="psalm-external-mutation-free-tag.md" />
153153
<toc-element topic="psalm-extends-tag.md" />
154-
<toc-element topic="psalm-flow-tag.md" wip="true" />
154+
<toc-element topic="psalm-flow-tag.md" />
155155
<toc-element topic="psalm-if-this-is-tag.md" />
156156
<toc-element topic="psalm-ignore-falsable-return-tag.md" />
157157
<toc-element topic="psalm-ignore-nullable-return-tag.md" />
@@ -160,7 +160,7 @@
160160
<toc-element topic="psalm-ignore-variable-property-tag.md" />
161161
<toc-element topic="psalm-immutable-tag.md" />
162162
<toc-element topic="psalm-implements-tag.md" />
163-
<toc-element topic="psalm-import-type-tag.md" wip="true" />
163+
<toc-element topic="psalm-import-type-tag.md" />
164164
<toc-element topic="psalm-inheritors-tag.md" />
165165
<toc-element topic="psalm-internal-tag.md" />
166166
<toc-element topic="psalm-method-tag.md" />
@@ -187,7 +187,7 @@
187187
<toc-element topic="psalm-stub-override-tag.md" />
188188
<toc-element topic="psalm-suppress-tag.md" />
189189
<toc-element topic="psalm-taint-escape-tag.md" />
190-
<toc-element topic="psalm-taint-sink-tag.md" wip="true" />
190+
<toc-element topic="psalm-taint-sink-tag.md" />
191191
<toc-element topic="psalm-taint-source-tag.md" />
192192
<toc-element topic="psalm-taint-specialize-tag.md" />
193193
<toc-element topic="psalm-taint-unescape-tag.md" />
@@ -196,7 +196,7 @@
196196
<toc-element topic="psalm-template-covariant-tag.md" />
197197
<toc-element topic="psalm-this-out-tag.md" />
198198
<toc-element topic="psalm-trace-tag.md" />
199-
<toc-element topic="psalm-type-tag.md" wip="true" />
199+
<toc-element topic="psalm-type-tag.md" />
200200
<toc-element topic="psalm-use-tag.md" />
201201
<toc-element topic="psalm-var-tag.md" />
202202
<toc-element topic="psalm-variadic-tag.md" />
@@ -214,7 +214,7 @@
214214
<toc-element topic="phpstan-ignore-next-line-tag.md" />
215215
<toc-element topic="phpstan-immutable-tag.md" />
216216
<toc-element topic="phpstan-implements-tag.md" />
217-
<toc-element topic="phpstan-import-type-tag.md" wip="true" />
217+
<toc-element topic="phpstan-import-type-tag.md" />
218218
<toc-element topic="phpstan-impure-tag.md" />
219219
<toc-element topic="phpstan-method-tag.md" />
220220
<toc-element topic="phpstan-param-tag.md" />
@@ -238,7 +238,7 @@
238238
<toc-element topic="phpstan-template-covariant-tag.md" />
239239
<toc-element topic="phpstan-this-out-tag.md" />
240240
<toc-element topic="phpstan-throws-tag.md" />
241-
<toc-element topic="phpstan-type-tag.md" wip="true" />
241+
<toc-element topic="phpstan-type-tag.md" />
242242
<toc-element topic="phpstan-use-tag.md" />
243243
<toc-element topic="phpstan-var-tag.md" />
244244
<toc-element topic="phpstan-yield-tag.md" />
@@ -278,7 +278,7 @@
278278
<toc-element topic="phan-suppress-previous-line-tag.md" />
279279
<toc-element topic="phan-template-tag.md" />
280280
<toc-element topic="phan-transient-tag.md" />
281-
<toc-element topic="phan-type-tag.md" wip="true" />
281+
<toc-element topic="phan-type-tag.md" />
282282
<toc-element topic="phan-unused-param-tag.md" />
283283
<toc-element topic="phan-var-tag.md" />
284284
<toc-element topic="phan-write-only-tag.md" />
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
# @phan-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@phan-type` tag declares a local alias for a complex type.
76

87
```
9-
"@phan-type" <Name> "=" <Type>
8+
"@phan-type" <Name> [ "=" ] <Type>
109
```
1110

12-
<note>
13-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
14-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
15-
suffix folded into the description. See
16-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
17-
need to recognize it yourself.
18-
</note>
11+
Parsing a `@phan-type` tag produces a `TypeAliasTag` instance, carrying the
12+
parsed `$alias` name and its `$type` alongside the `$name` every
13+
[Tag](phpdoc.md#tag) already provides.
14+
15+
```php
16+
final class TypeAliasTag extends Tag {}
17+
```
18+
19+
The same `TypeAliasTag` is produced by [@psalm-type](psalm-type-tag.md) and [@phpstan-type](phpstan-type-tag.md), which restate
20+
the same concept for their respective tools.
1921

2022
Defined by Phan, a static analyzer for PHP; no dedicated
2123
documentation page could be confirmed for this tag.
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# @phpstan-import-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@phpstan-import-type` tag imports a `@phpstan-type` alias declared
76
in another class, defined by PHPStan.
87

9-
<note>
10-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
11-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
12-
suffix folded into the description. See
13-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
14-
need to recognize it yourself.
15-
</note>
8+
```
9+
"@phpstan-import-type" <Name> "from" <Type>
10+
[ "as" <Name> ]
11+
```
12+
13+
Parsing a `@phpstan-import-type` tag produces an `ImportTypeAliasTag` instance,
14+
carrying the imported `$alias`, the `$type` it is imported from, and the
15+
optional local `$as` name alongside the `$name` every [Tag](phpdoc.md#tag)
16+
already provides.
17+
18+
```php
19+
final class ImportTypeAliasTag extends Tag {}
20+
```
21+
22+
The same `ImportTypeAliasTag` is produced by [@psalm-import-type](psalm-import-type-tag.md), which restates
23+
the same concept for Psalm.
1624

1725
Documented by
1826
[PHPStan](https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases).
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
# @phpstan-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@phpstan-type` tag declares a local alias for a complex type,
76
so it can be referenced by name in later `@param`, `@return`, and
87
`@var` tags. It is defined by the static analyzer PHPStan.
98

109
```
11-
"@phpstan-type" <Name> "=" <Type>
10+
"@phpstan-type" <Name> [ "=" ] <Type>
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
Parsing a `@phpstan-type` tag produces a `TypeAliasTag` instance, carrying the
14+
parsed `$alias` name and its `$type` alongside the `$name` every
15+
[Tag](phpdoc.md#tag) already provides.
16+
17+
```php
18+
final class TypeAliasTag extends Tag {}
19+
```
20+
21+
The same `TypeAliasTag` is produced by [@psalm-type](psalm-type-tag.md) and [@phan-type](phan-type-tag.md), which restate
22+
the same concept for their respective tools.
2123

2224
See PHPStan's
2325
[PHPDoc types](https://phpstan.org/writing-php-code/phpdoc-types#local-type-aliases).
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @psalm-check-type-exact
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-check-type-exact` tag asserts that a variable resolves
76
to exactly the given type, disallowing narrower or wider matches.
@@ -12,12 +11,15 @@ It is defined by the static analyzer Psalm, alongside the looser
1211
"@psalm-check-type-exact" <Variable> "=" <Type>
1312
```
1413

15-
<note>
16-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
17-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
18-
suffix folded into the description. See
19-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
20-
need to recognize it yourself.
21-
</note>
14+
Parsing a `@psalm-check-type-exact` tag produces a `PsalmCheckTypeExactTag`
15+
instance, carrying the checked `$variable` and its expected `$type` alongside
16+
the `$name` every [Tag](phpdoc.md#tag) already provides.
17+
18+
```php
19+
final class PsalmCheckTypeExactTag extends CheckTypeTag {}
20+
```
21+
22+
It shares the `CheckTypeTag` base with the looser
23+
[@psalm-check-type](psalm-check-type-tag.md), which allows assignable matches.
2224

2325
See [Psalm's supported annotations](https://psalm.dev/docs/annotating_code/supported_annotations/) page.
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @psalm-check-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-check-type` tag asserts, for debugging purposes, that a
76
variable resolves to a given type. It is defined by the static
@@ -11,12 +10,16 @@ analyzer Psalm.
1110
"@psalm-check-type" <Variable> "=" <Type>
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
Parsing a `@psalm-check-type` tag produces a `PsalmCheckTypeTag` instance,
14+
carrying the checked `$variable` and its expected `$type` alongside the
15+
`$name` every [Tag](phpdoc.md#tag) already provides.
16+
17+
```php
18+
final class PsalmCheckTypeTag extends CheckTypeTag {}
19+
```
20+
21+
It shares the `CheckTypeTag` base with the stricter
22+
[@psalm-check-type-exact](psalm-check-type-exact-tag.md), which demands an
23+
exact type match.
2124

2225
See [Psalm's supported annotations](https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-check-type).
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @psalm-flow
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-flow` tag is part of Psalm's taint-analysis annotations,
76
used to describe how tainted data flows through a function's
@@ -11,12 +10,15 @@ parameters and return value.
1110
"@psalm-flow" <FlowType> [ <Variable> ]
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
The `<FlowType>` is a keyword — one of `TaintSource`, `TaintSink`,
14+
`TaintSpecialize` or `TaintUnescape` — captured into a `FlowType` enum.
15+
16+
Parsing a `@psalm-flow` tag produces a `PsalmFlowTag` instance, carrying the
17+
parsed `$flow` and optional `$variable` alongside the `$name` every
18+
[Tag](phpdoc.md#tag) already provides.
19+
20+
```php
21+
final class PsalmFlowTag extends Tag {}
22+
```
2123

2224
See [Psalm's security analysis annotations](https://psalm.dev/docs/security_analysis/annotations/).
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @psalm-import-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-import-type` tag imports a `@psalm-type` alias declared in
76
another class, optionally binding it to a local alias name.
@@ -11,12 +10,16 @@ another class, optionally binding it to a local alias name.
1110
[ "as" <Name> ]
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
Parsing a `@psalm-import-type` tag produces an `ImportTypeAliasTag` instance,
14+
carrying the imported `$alias`, the `$type` it is imported from, and the
15+
optional local `$as` name alongside the `$name` every [Tag](phpdoc.md#tag)
16+
already provides.
17+
18+
```php
19+
final class ImportTypeAliasTag extends Tag {}
20+
```
21+
22+
The same `ImportTypeAliasTag` is produced by [@phpstan-import-type](phpstan-import-type-tag.md), which restates
23+
the same concept for PHPStan.
2124

2225
Defined by [Psalm's supported annotations reference](https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-import-type).
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# @psalm-taint-sink
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-taint-sink` tag marks an argument as a taint sink for
76
the given taint type. It is part of Psalm's taint-analysis
@@ -11,12 +10,12 @@ annotations.
1110
"@psalm-taint-sink" <Name> <Variable>
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
Parsing a `@psalm-taint-sink` tag produces a `PsalmTaintSinkTag` instance,
14+
carrying the parsed `$taint` type and `$variable` alongside the `$name`
15+
every [Tag](phpdoc.md#tag) already provides.
16+
17+
```php
18+
final class PsalmTaintSinkTag extends Tag {}
19+
```
2120

2221
See [Psalm's security analysis annotations](https://psalm.dev/docs/security_analysis/annotations/#psalm-taint-sink-lttaint-typegt-ltparam-namegt).
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# @psalm-type
22

33
<primary-label ref="phpdoc-component"/>
4-
<secondary-label ref="not-implemented"/>
54

65
The `@psalm-type` tag declares a local alias for a complex type,
76
which can then be reused across the codebase. It is defined by the
87
static analyzer Psalm.
98

109
```
11-
"@psalm-type" <Name> "=" <Type>
10+
"@psalm-type" <Name> [ "=" ] <Type>
1211
```
1312

14-
<note>
15-
Not yet recognized by <code>TypeLang\PhpDoc\DocBlockParser</code> — parsing
16-
a docblock containing this tag returns a plain <code>Tag</code>, its whole
17-
suffix folded into the description. See
18-
<a href="custom-tags.md">Custom Tags</a> for the current workaround if you
19-
need to recognize it yourself.
20-
</note>
13+
Parsing a `@psalm-type` tag produces a `TypeAliasTag` instance, carrying the
14+
parsed `$alias` name and its `$type` alongside the `$name` every
15+
[Tag](phpdoc.md#tag) already provides.
16+
17+
```php
18+
final class TypeAliasTag extends Tag {}
19+
```
20+
21+
The same `TypeAliasTag` is produced by [@phpstan-type](phpstan-type-tag.md) and [@phan-type](phan-type-tag.md), which restate
22+
the same concept for their respective tools.
2123

2224
See [Psalm's supported annotations](https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-type).

0 commit comments

Comments
 (0)