You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: PhpCollective/Sniffs/Commenting/DocBlockReturnVoidSniff.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ class DocBlockReturnVoidSniff extends AbstractSniff
20
20
{
21
21
use CommentingTrait;
22
22
23
+
publicbool$strict = false;
24
+
23
25
/**
24
26
* @var array<string>
25
27
*/
@@ -75,15 +77,15 @@ public function process(File $phpcsFile, $stackPtr): void
75
77
76
78
// If interface we will at least report it
77
79
if (empty($tokens[$stackPtr]['scope_opener']) || empty($tokens[$stackPtr]['scope_closer'])) {
78
-
if (!$docBlockReturnIndex && !$hasInheritDoc && !$hasReturnType) {
80
+
if (!$docBlockReturnIndex && !$hasInheritDoc && (!$hasReturnType || $this->strict)) {
79
81
$phpcsFile->addError('Method does not have a return statement in doc block: ' . $tokens[$nextIndex]['content'], $nextIndex, 'ReturnMissingInInterface');
80
82
}
81
83
82
84
return;
83
85
}
84
86
85
87
// If inheritDoc is present assume the parent contains it
86
-
if (!$docBlockReturnIndex && ($hasInheritDoc || $this->hasReturnType($phpcsFile, $stackPtr))) {
88
+
if (!$docBlockReturnIndex && ($hasInheritDoc || $hasReturnType && !$this->strict)) {
0 commit comments