Commit ee3ddb3
committed
Member variables and methods should not require DocBlock when properly typed
https://developer.adobe.com/commerce/php/coding-standards/docblock/
> Include all necessary information without duplication.
Example 1:
```
private ?ObjectManagerInterface $objectManager;
```
should not require a comment
```
/** @var ObjectManagerInterface|null $objectManager */
```
because all of that information is duplicated. (Though the nullable is actually harder to read in DocBlock standard.)
Example 2:
```
public function getWeakMap() : WeakMap
{
return $this->weakMap;
}
```
This method is expressive. It is obvious what it does. It is strictly typed. There is no reason that it should need a DocBlock.
This change no longer requires DocBlock in these cases:
1: member variables that have defined types
2: methods where all parameters have defined types AND method has defined return type (__construct and __destruct won't require return type, since it isn't allowed)1 parent 99e3ae2 commit ee3ddb3
File tree
2 files changed
+23
-0
lines changed- Magento2/Sniffs
- Annotation
- Commenting
2 files changed
+23
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
571 | 590 | | |
572 | 591 | | |
573 | 592 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
0 commit comments