Skip to content

Commit ad7d035

Browse files
committed
Add immutable and not-deprecated tags
1 parent 5a01925 commit ad7d035

12 files changed

Lines changed: 467 additions & 33 deletions

Writerside/tl.tree

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@
6363
</toc-element>
6464

6565
<toc-element topic="phpdoc.md" toc-title="PHPDoc Parser">
66-
<toc-element toc-title="Standard Tags">
66+
<toc-element toc-title="Standard Tags" topic="standard-tags.md">
6767
<toc-element topic="abstract-tag.md" />
6868
<toc-element topic="api-tag.md" />
6969
<toc-element topic="deprecated-tag.md" />
7070
<toc-element topic="extends-tag.md" />
7171
<toc-element topic="final-tag.md" />
72-
<toc-element topic="immutable-tag.md" wip="true" />
72+
<toc-element topic="immutable-tag.md" />
7373
<toc-element topic="implements-tag.md" />
7474
<toc-element topic="inherits-tag.md" />
7575
<toc-element topic="internal-tag.md" />
@@ -96,14 +96,12 @@
9696
<toc-element topic="template-use-tag.md" />
9797
<toc-element topic="throws-tag.md" />
9898
<toc-element topic="throw-tag.md" />
99-
<toc-element topic="todo-tag.md" />
10099
<toc-element topic="use-tag.md" />
101100
<toc-element topic="var-tag.md" />
102-
<toc-element topic="version-tag.md" />
103101
</toc-element>
104-
<toc-element toc-title="Advanced Tags">
102+
<toc-element toc-title="Advanced Tags" topic="advanced-tags.md">
105103
<toc-element topic="no-named-arguments-tag.md" />
106-
<toc-element topic="not-deprecated-tag.md" wip="true" />
104+
<toc-element topic="not-deprecated-tag.md" />
107105
<toc-element topic="param-closure-this-tag.md" />
108106
<toc-element topic="param-immediately-invoked-callable-tag.md" />
109107
<toc-element topic="param-later-invoked-callable-tag.md" />
@@ -114,7 +112,7 @@
114112
<toc-element topic="suppress-tag.md" />
115113
<toc-element topic="unused-param-tag.md" />
116114
</toc-element>
117-
<toc-element toc-title="phpDocumentor">
115+
<toc-element toc-title="phpDocumentor" topic="phpdocumentor-tags.md">
118116
<toc-element topic="access-tag.md" />
119117
<toc-element topic="author-tag.md" />
120118
<toc-element topic="category-tag.md" />
@@ -134,11 +132,13 @@
134132
<toc-element topic="staticvar-tag.md" />
135133
<toc-element topic="subpackage-tag.md" />
136134
<toc-element topic="toc-tag.md" wip="true" />
135+
<toc-element topic="todo-tag.md" />
137136
<toc-element topic="tutorial-tag.md" wip="true" />
138137
<toc-element topic="used-by-tag.md" />
139138
<toc-element topic="uses-tag.md" />
139+
<toc-element topic="version-tag.md" />
140140
</toc-element>
141-
<toc-element toc-title="Psalm">
141+
<toc-element toc-title="Psalm" topic="psalm-tags.md">
142142
<toc-element topic="psalm-allow-private-mutation-tag.md" wip="true" />
143143
<toc-element topic="psalm-api-tag.md" wip="true" />
144144
<toc-element topic="psalm-assert-tag.md" wip="true" />
@@ -202,7 +202,7 @@
202202
<toc-element topic="psalm-variadic-tag.md" wip="true" />
203203
<toc-element topic="psalm-yield-tag.md" wip="true" />
204204
</toc-element>
205-
<toc-element toc-title="PHPStan">
205+
<toc-element toc-title="PHPStan" topic="phpstan-tags.md">
206206
<toc-element topic="phpstan-allow-private-mutation-tag.md" wip="true" />
207207
<toc-element topic="phpstan-assert-tag.md" wip="true" />
208208
<toc-element topic="phpstan-assert-if-false-tag.md" wip="true" />
@@ -243,7 +243,7 @@
243243
<toc-element topic="phpstan-var-tag.md" wip="true" />
244244
<toc-element topic="phpstan-yield-tag.md" wip="true" />
245245
</toc-element>
246-
<toc-element toc-title="Phan">
246+
<toc-element toc-title="Phan" topic="phan-tags.md">
247247
<toc-element topic="phan-abstract-tag.md" wip="true" />
248248
<toc-element topic="phan-assert-tag.md" wip="true" />
249249
<toc-element topic="phan-assert-false-condition-tag.md" wip="true" />
@@ -284,14 +284,14 @@
284284
<toc-element topic="phan-write-only-tag.md" wip="true" />
285285
<toc-element topic="phanclosurescope-tag.md" wip="true" />
286286
</toc-element>
287-
<toc-element toc-title="PhpStorm">
287+
<toc-element toc-title="PhpStorm" topic="phpstorm-tags.md">
288288
<toc-element topic="noinspection-tag.md" wip="true" />
289289
<toc-element topic="language-tag.md" wip="true" />
290290
<toc-element topic="expected-exception-tag.md" wip="true" />
291291
<toc-element topic="formatter-off-tag.md" wip="true" />
292292
<toc-element topic="formatter-on-tag.md" wip="true" />
293293
</toc-element>
294-
<toc-element toc-title="PHP CodeSniffer">
294+
<toc-element toc-title="PHP CodeSniffer" topic="phpcs-tags.md">
295295
<toc-element topic="phpcs-suppress-tag.md" wip="true" />
296296
<toc-element topic="coding-standards-ignore-start-tag.md" wip="true" />
297297
<toc-element topic="coding-standards-ignore-end-tag.md" wip="true" />
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Advanced Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **Advanced Tags** are a small set of tags that were originally
7+
introduced by individual static analyzers — chiefly Psalm and PHPStan — to
8+
express things the classic phpDocumentor vocabulary never covered: purity,
9+
by-reference output parameters, how a closure is invoked, whether a class
10+
may grow magic members. Over time these spellings became common enough that
11+
both analyzers came to accept them **without a vendor prefix**, and that is
12+
exactly how they are grouped here.
13+
14+
In other words, this is the vendor-neutral middle ground: less universal
15+
than the [Standard Tags](standard-tags.md), but no longer tied to a single
16+
tool's `@psalm-*` or `@phpstan-*` namespace either. You write
17+
`@param-out`, not `@psalm-param-out`; `@pure-unless-callable-is-impure`, not
18+
its prefixed form.
19+
20+
## What Belongs Here
21+
22+
* **Purity and side effects**
23+
[@pure-unless-callable-is-impure](pure-unless-callable-is-impure-tag.md),
24+
which marks a function pure except when a callable it is handed is itself
25+
impure.
26+
* **By-reference output**[@param-out](param-out-tag.md), describing the
27+
type a parameter *holds after* the call rather than the type it accepts.
28+
* **How a callable is invoked**
29+
[@param-closure-this](param-closure-this-tag.md) binds the `$this` a
30+
closure parameter runs against, while
31+
[@param-immediately-invoked-callable](param-immediately-invoked-callable-tag.md)
32+
and
33+
[@param-later-invoked-callable](param-later-invoked-callable-tag.md)
34+
distinguish a callback called before the function returns from one stored
35+
for later.
36+
* **Sealing magic members**[@seal-methods](seal-methods-tag.md) and
37+
[@seal-properties](seal-properties-tag.md) forbid a class from resolving
38+
any magic member not explicitly declared.
39+
* **Diagnostics**[@suppress](suppress-tag.md) silences named issues on an
40+
element, and [@unused-param](unused-param-tag.md) marks a parameter kept
41+
only for signature compatibility.
42+
* **Calling conventions**
43+
[@no-named-arguments](no-named-arguments-tag.md) declares that a function
44+
must not be called with named arguments, and
45+
[@not-deprecated](not-deprecated-tag.md) asserts an element is explicitly
46+
*not* deprecated despite what surrounding code might suggest.
47+
48+
<note>
49+
Each of these tags still has a prefixed twin under a specific analyzer —
50+
<code>@psalm-param-out</code>, <code>@phpstan-pure</code>, and so on — listed
51+
under that analyzer's own group in the sidebar. The bare spellings collected
52+
here are the ones both major analyzers agree to read without a prefix.
53+
</note>
54+
55+
Like the standard set, every tag in this group is fully recognized: it
56+
parses into a dedicated, typed object, with any type it carries read through
57+
the same [TypeLang grammar](introduction.md) used everywhere else. Open any
58+
entry in the sidebar for its grammar, resulting object, and examples.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Phan Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **Phan Tags** are the annotations that belong to
7+
[Phan](https://github.com/phan/phan)'s own vocabulary, written under its
8+
`@phan-*` vendor prefix. Phan uses the prefix much as Psalm and PHPStan do:
9+
to add analyzer-specific capabilities — line-scoped suppression, real vs.
10+
documented return types, magic-member policing — and to offer a Phan-scoped
11+
override of a tag that also exists in the shared convention.
12+
13+
A prefixed tag that mirrors one documented elsewhere — `@phan-param` beside
14+
[@param](param-tag.md), `@phan-return` beside [@return](return-tag.md)
15+
means the same thing as the plain spelling; the prefix only marks it as the
16+
one Phan should trust.
17+
18+
## What This Group Covers
19+
20+
* **Assertions**`@phan-assert`, `@phan-assert-true-condition`,
21+
`@phan-assert-false-condition`, `@phan-assert-if-true`,
22+
`@phan-assert-if-false`.
23+
* **Line-scoped suppression**`@phan-suppress-current-line`,
24+
`@phan-suppress-next-line`, `@phan-suppress-next-next-line`,
25+
`@phan-suppress-previous-line`, and the file-wide `@phan-file-suppress`.
26+
* **Return types**`@phan-real-return`, `@phan-hardcode-return-type`,
27+
distinguishing the type Phan should infer from the one it should report.
28+
* **Magic-member policy**`@phan-forbid-undeclared-magic-methods`,
29+
`@phan-forbid-undeclared-magic-properties`,
30+
`@phan-read-only`, `@phan-write-only`.
31+
* **Purity and immutability**`@phan-pure`, `@phan-side-effect-free`,
32+
`@phan-immutable`, `@phan-constructor-used-for-side-effects`.
33+
* **Prefixed overrides**`@phan-var`, `@phan-param`, `@phan-return`,
34+
`@phan-property`, `@phan-method`, `@phan-template`, `@phan-mixin`,
35+
`@phan-extends`, and the rest, each shadowing its unprefixed counterpart
36+
for Phan specifically.
37+
38+
<warning>
39+
The tags in this group are listed for reference only. They are catalogued so
40+
the vocabulary is documented in one place, but are <b>not yet recognized</b>
41+
by the parser — a docblock containing one currently falls back to a plain
42+
<a href="phpdoc.md#tag">Tag</a>. Their pages are marked work-in-progress in
43+
the sidebar.
44+
</warning>
45+
46+
For the authoritative definitions, see
47+
[Phan's annotating-your-source-code guide](https://github.com/phan/phan/wiki/Annotating-Your-Source-Code).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PHP CodeSniffer Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **PHP CodeSniffer Tags** are the annotations
7+
[PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer)
8+
recognizes to turn its own rules on and off inside a file. Unlike every other
9+
group in this section, these tags have nothing to do with types or
10+
documentation at all — they are coding-standard directives, telling the
11+
sniffer to skip a line, a block, or a whole file when checking style.
12+
13+
They come in two spellings: the modern `@phpcs:` form and the older
14+
`@codingStandardsIgnore*` family kept for backward compatibility with rules
15+
written against earlier PHP_CodeSniffer releases.
16+
17+
## What This Group Covers
18+
19+
* **Scoped suppression (modern)**[@phpcs:suppress](phpcs-suppress-tag.md),
20+
disabling one or more named sniffs for the following statement.
21+
* **Region suppression (legacy)**
22+
[@codingStandardsIgnoreStart](coding-standards-ignore-start-tag.md) and
23+
[@codingStandardsIgnoreEnd](coding-standards-ignore-end-tag.md) bracket a
24+
block the sniffer should skip, while
25+
[@codingStandardsIgnoreLine](coding-standards-ignore-line-tag.md) skips a
26+
single line and
27+
[@codingStandardsIgnoreFile](coding-standards-ignore-file-tag.md) exempts
28+
the entire file.
29+
* **General marker**
30+
[@codingStandards](coding-standards-tag.md), the bare root of that legacy
31+
family.
32+
33+
<warning>
34+
The tags in this group are listed for reference only. They are catalogued so
35+
the vocabulary is documented in one place, but are <b>not yet recognized</b>
36+
by the parser — a docblock containing one currently falls back to a plain
37+
<a href="phpdoc.md#tag">Tag</a>. Their pages are marked work-in-progress in
38+
the sidebar.
39+
</warning>
40+
41+
For the authoritative behavior, see
42+
[PHP_CodeSniffer's wiki on ignoring code](https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file).
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# phpDocumentor Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **phpDocumentor Tags** are the tags that originate with
7+
[phpDocumentor](https://www.phpdoc.org) itself — the documentation
8+
generator that defined the original PHPDoc convention long before the
9+
current generation of static analyzers existed. Where the
10+
[Standard](standard-tags.md) and [Advanced](advanced-tags.md) groups collect
11+
tags about *types*, this group collects tags about *documentation*:
12+
authorship, licensing, packaging, cross-references, and the prose that ends
13+
up in a generated API manual.
14+
15+
Many of these predate modern type analysis and carry no type information at
16+
all — they annotate the human-facing documentation rather than constrain the
17+
code. They are grouped here by provenance, and a fair number are legacy
18+
entries from phpDocumentor 1.x kept for compatibility with older docblocks.
19+
20+
## What Belongs Here
21+
22+
* **Authorship and legal**[@author](author-tag.md),
23+
[@copyright](copyright-tag.md), [@license](license-tag.md).
24+
* **Packaging and structure**[@package](package-tag.md),
25+
[@subpackage](subpackage-tag.md), [@category](category-tag.md),
26+
[@name](name-tag.md), [@global](global-tag.md),
27+
[@staticvar](staticvar-tag.md), and the plain [@static](static-tag.md).
28+
* **Cross-references**[@uses](uses-tag.md) and its reverse
29+
[@used-by](used-by-tag.md).
30+
* **Versioning and lifecycle**[@version](version-tag.md) records an
31+
element's own version, [@since](since-tag.md) the version it first
32+
appeared in, and [@todo](todo-tag.md) notes work still to be done.
33+
* **Documentation control**[@inheritdoc](inheritdoc-tag.md) pulls
34+
documentation down from a parent, [@ignore](ignore-tag.md) hides an
35+
element from the generated output, and [@access](access-tag.md) is the
36+
legacy way of recording visibility.
37+
* **Examples and sources**[@example](example-tag.md),
38+
[@source](source-tag.md), and [@filesource](filesource-tag.md) embed or
39+
point to code in the rendered documentation.
40+
41+
<note>
42+
Several of these tags — <a href="access-tag.md">@access</a>,
43+
<a href="staticvar-tag.md">@staticvar</a>, <a href="name-tag.md">@name</a> —
44+
belong to the classic phpDocumentor 1.x vocabulary and have been dropped from
45+
phpDocumentor 3's current reference. They are still parsed here so that
46+
docblocks written against the older toolchain keep working.
47+
</note>
48+
49+
The implemented tags in this group each parse into a dedicated object; a few
50+
entries (such as [@id](id-tag.md), [@toc](toc-tag.md), and
51+
[@tutorial](tutorial-tag.md)) are still marked work-in-progress. Open any
52+
entry in the sidebar for its exact grammar and behavior.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# PHPStan Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **PHPStan Tags** are the annotations that belong to
7+
[PHPStan](https://phpstan.org)'s own vocabulary, written under its
8+
`@phpstan-*` vendor prefix. As with Psalm, the prefix serves two roles: it
9+
introduces PHPStan-specific features — assertions, its `@phpstan-ignore`
10+
family of diagnostic suppressors, type aliases — and it provides a
11+
PHPStan-scoped override of a tag that also exists unprefixed, letting a
12+
project refine a type *for PHPStan only*.
13+
14+
A prefixed tag that mirrors one documented elsewhere — `@phpstan-param`
15+
beside [@param](param-tag.md), `@phpstan-return` beside
16+
[@return](return-tag.md) — carries the same meaning as the plain spelling;
17+
the prefix simply tells PHPStan to prefer this line when it and another tool
18+
disagree.
19+
20+
## What This Group Covers
21+
22+
* **Assertions**`@phpstan-assert`, `@phpstan-assert-if-true`,
23+
`@phpstan-assert-if-false`.
24+
* **Diagnostic suppression** — the `@phpstan-ignore` family
25+
(`@phpstan-ignore`, `@phpstan-ignore-line`, `@phpstan-ignore-next-line`).
26+
* **Purity and immutability**`@phpstan-pure`, `@phpstan-impure`,
27+
`@phpstan-immutable`, `@phpstan-readonly`,
28+
`@phpstan-pure-unless-callable-is-impure`.
29+
* **Type aliases and generics**`@phpstan-type`, `@phpstan-import-type`,
30+
`@phpstan-template` (with its covariant and contravariant forms).
31+
* **Prefixed overrides**`@phpstan-param`, `@phpstan-return`,
32+
`@phpstan-var`, `@phpstan-property`, `@phpstan-method`,
33+
`@phpstan-param-out`, `@phpstan-self-out`, and the rest, each shadowing
34+
its unprefixed counterpart for PHPStan specifically.
35+
36+
<note>
37+
Many capabilities PHPStan shares with Psalm are recognized here without a
38+
prefix — see <a href="advanced-tags.md">Advanced Tags</a> for the
39+
vendor-neutral spellings such as
40+
<a href="param-out-tag.md">@param-out</a> and
41+
<a href="pure-unless-callable-is-impure-tag.md">@pure-unless-callable-is-impure</a>.
42+
</note>
43+
44+
<warning>
45+
The tags in this group are listed for reference only. They are catalogued so
46+
the vocabulary is documented in one place, but are <b>not yet recognized</b>
47+
by the parser — a docblock containing one currently falls back to a plain
48+
<a href="phpdoc.md#tag">Tag</a>. Their pages are marked work-in-progress in
49+
the sidebar.
50+
</warning>
51+
52+
For the authoritative definitions, see
53+
[PHPStan's PHPDoc reference](https://phpstan.org/writing-php-code/phpdocs-basics).
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# PhpStorm Tags
2+
3+
<primary-label ref="phpdoc-component"/>
4+
<show-structure for="chapter" depth="2"/>
5+
6+
The **PhpStorm Tags** are the annotations that
7+
[PhpStorm](https://www.jetbrains.com/phpstorm/) understands as directives to
8+
the IDE itself rather than to a command-line analyzer. They do not describe
9+
types or generate documentation; they change how the editor treats the
10+
surrounding code — suppressing an inspection, injecting a language into a
11+
string, marking a call as one that is expected to throw.
12+
13+
Because they steer editor behavior, these tags have no vendor prefix in the
14+
`@psalm-*` sense: they are spelled as ordinary tags (`@noinspection`,
15+
`@language`) that happen to be meaningful only inside JetBrains tooling.
16+
17+
## What This Group Covers
18+
19+
* **Inspection control**[@noinspection](noinspection-tag.md), which
20+
silences one or more named IDE inspections for the element that follows.
21+
* **Language injection**[@language](language-tag.md), telling the editor
22+
that a string or heredoc contains another language (SQL, JSON, regexp)
23+
so it can be highlighted and analyzed accordingly.
24+
* **Test expectations**
25+
[@expected-exception](expected-exception-tag.md), recording the exception
26+
a test is expected to raise.
27+
* **Formatter control**[@formatter:off](formatter-off-tag.md) and
28+
[@formatter:on](formatter-on-tag.md), bracketing a region the reformatter
29+
should leave untouched.
30+
31+
<warning>
32+
The tags in this group are listed for reference only. They are catalogued so
33+
the vocabulary is documented in one place, but are <b>not yet recognized</b>
34+
by the parser — a docblock containing one currently falls back to a plain
35+
<a href="phpdoc.md#tag">Tag</a>. Their pages are marked work-in-progress in
36+
the sidebar.
37+
</warning>
38+
39+
For the authoritative behavior, see
40+
[PhpStorm's documentation on suppressing inspections](https://www.jetbrains.com/help/phpstorm/disabling-and-enabling-inspections.html)
41+
and its
42+
[language injection guide](https://www.jetbrains.com/help/phpstorm/using-language-injections.html).

0 commit comments

Comments
 (0)