diff --git a/CakePHP/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/CakePHP/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index ada08066..d9d58f77 100644 --- a/CakePHP/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/CakePHP/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -154,7 +154,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { // Is this a return type declarations? if ($tokens[$nextPtr]['code'] === T_OPEN_CURLY_BRACKET) { $prevPtrReturnType = $phpcsFile->findPrevious(array(T_WHITESPACE, T_INLINE_THEN), ($stackPtr - 1), null, true); - if ($tokens[$prevPtrReturnType]['code'] === T_COLON) { + if (in_array($tokens[$prevPtrReturnType]['code'], array(T_COLON, T_INLINE_ELSE), true)) { return; } } diff --git a/CakePHP/tests/files/return_type_declaration_pass.php b/CakePHP/tests/files/return_type_declaration_pass.php index f6cfaa09..505d3479 100644 --- a/CakePHP/tests/files/return_type_declaration_pass.php +++ b/CakePHP/tests/files/return_type_declaration_pass.php @@ -15,7 +15,17 @@ public function returnTypeVoid() : void { * * @return string|null */ - public unction returnTypeNull() : ?string { + public function returnTypeNull() : ?string { + } + +/** + * A function with param + * + * @param int $firstParam a first param + * @param string $secondParam a second param + * @return int + */ + public function withParam(int $firstParam, string $secondParam) : int { } }