Skip to content

Commit c9875ea

Browse files
committed
Improved ReturnTypeDeclarationSniff
Errors are checked for hook callbacks as well, warnings are not
1 parent 9803322 commit c9875ea

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Inpsyde/Sniffs/CodeQuality/ReturnTypeDeclarationSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ public function register()
4141
*/
4242
public function process(File $file, $position)
4343
{
44-
if (Helpers::isHookClosure($file, $position) || Helpers::isHookFunction($file, $position)) {
45-
return;
46-
}
47-
4844
list($functionStart, $functionEnd) = Helpers::functionBoundaries($file, $position);
4945
if (!$functionStart < 0 || $functionEnd <= 0) {
5046
return;
@@ -100,17 +96,21 @@ private function maybeErrors(
10096
return;
10197
}
10298

103-
if ($hasNoReturnType) {
104-
$file->addWarning('Return type is missing', $position, 'NoReturnType');
105-
}
106-
10799
if ($hasVoidReturnType) {
108100
$file->addError(
109101
'Void return type when returning non-void',
110102
$position,
111103
'IncorrectVoidReturnType'
112104
);
113105
}
106+
107+
if (Helpers::isHookClosure($file, $position) || Helpers::isHookFunction($file, $position)) {
108+
return;
109+
}
110+
111+
if ($hasNoReturnType) {
112+
$file->addWarning('Return type is missing', $position, 'NoReturnType');
113+
}
114114
}
115115

116116
/**

0 commit comments

Comments
 (0)