Skip to content

Commit

Permalink
Fixed problem when checking functions with nullable return type (ref s…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Aug 26, 2019
1 parent 44594bc commit 9b7beec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function process(File $phpcsFile, $stackPtr)
}

$returnType = $methodProperties['return_type_token'];
if ($methodProperties['nullable_return_type'] === true) {
$returnType = $phpcsFile->findPrevious(T_NULLABLE, ($returnType - 1));
}

if ($tokens[($returnType - 1)]['code'] !== T_WHITESPACE
|| $tokens[($returnType - 1)]['content'] !== ' '
|| $tokens[($returnType - 2)]['code'] !== T_COLON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ public function functionName(int $arg1, $arg2) /* can't fix */ : string {}
public function functionName(int $arg1, $arg2) /* can't fix */
: // phpcs:ignore Standard.Category.Sniff
string {}

function functionName(?string $arg1, ?int &$arg2): ?string {}
function functionName(?string $arg1, ?int &$arg2):?string {}
function functionName(?string $arg1, ?int &$arg2): ?string {}
function functionName(?string $arg1, ?int &$arg2):
?string {}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ public function functionName(int $arg1, $arg2) /* can't fix */ : string {}
public function functionName(int $arg1, $arg2) /* can't fix */
: // phpcs:ignore Standard.Category.Sniff
string {}

function functionName(?string $arg1, ?int &$arg2): ?string {}
function functionName(?string $arg1, ?int &$arg2): ?string {}
function functionName(?string $arg1, ?int &$arg2): ?string {}
function functionName(?string $arg1, ?int &$arg2): ?string {}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ protected function getErrorList()
52 => 1,
55 => 1,
56 => 1,
59 => 1,
60 => 1,
62 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 9b7beec

Please sign in to comment.