Skip to content

Commit 1dc8017

Browse files
committed
add example of multiline property @var, to highlight criteria about Type
1 parent 4fd83b2 commit 1dc8017

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

proposed/phpdoc-tags.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,9 @@ Each Constant or Property definition or Variable where the type is ambiguous
960960
or unknown SHOULD be preceded by a DocBlock containing the @var tag. Any
961961
other variable MAY be preceded with a DocBlock containing the @var tag.
962962

963-
The @var tag SHOULD contain the name of the element it documents. An exception
964-
to this is when property declarations only refer to a single property. In this
965-
case the name of the property MAY be omitted.
963+
The @var tag MUST contain the name of the element it documents, unless this
964+
property declaration only refers to a single property. In this case the name of
965+
the property MAY be omitted.
966966

967967
`element_name` is used when compound statements are used to define a series of Constants
968968
or Properties. Such a compound statement can only have one DocBlock while several
@@ -1000,15 +1000,28 @@ Another example is to document the variable in a foreach explicitly; many IDEs
10001000
use this information to help you with auto-completion:
10011001

10021002
```php
1003-
/* @var \Sqlite3 $sqlite */
1003+
/** @var \Sqlite3 $sqlite */
10041004
foreach ($connections as $sqlite) {
10051005
// there should be no docblock here
10061006
$sqlite->open('/my/database/path');
10071007
<...>
10081008
}
10091009
```
10101010

1011-
Even compound statements may be documented:
1011+
Even compound statements may be documented... these two property blocks are
1012+
equivalent:
1013+
1014+
```php
1015+
class Foo
1016+
{
1017+
/**
1018+
* @var string $name Should contain a description
1019+
* @var string $description Should contain a description
1020+
*/
1021+
protected $name, $description;
1022+
1023+
}
1024+
```
10121025

10131026
```php
10141027
class Foo

0 commit comments

Comments
 (0)