From e2b0b2fdbf9b8b8c83dfa670cd51f215a7589330 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 12 Dec 2017 22:38:08 +0530 Subject: [PATCH 1/2] Add test inline docComment above single return statement. --- .../Formatting/BlankLineBeforeReturnUnitTest.inc | 11 +++++++++++ .../BlankLineBeforeReturnUnitTest.inc.fixed | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc b/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc index 1630f2de..c5c3725c 100644 --- a/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc +++ b/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc @@ -91,3 +91,14 @@ function validFunctionReturnSix() return false; } } + +/** + * [validFunctionReturnSeven description] + * + * @return null + */ +function validFunctionReturnSeven() +{ + /** @var Foo $foo */ + return null; +} diff --git a/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed b/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed index 3ba80038..cb38504f 100644 --- a/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed +++ b/CakePHP/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed @@ -93,3 +93,14 @@ function validFunctionReturnSix() return false; } } + +/** + * [validFunctionReturnSeven description] + * + * @return null + */ +function validFunctionReturnSeven() +{ + /** @var Foo $foo */ + return null; +} From a7d0749bdd46435485a7dcd38696e79a02ed517b Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 12 Dec 2017 23:26:03 +0530 Subject: [PATCH 2/2] Update BlankLineBeforeReturnSniff. It now doesn't complain about inline docComment above return statement. --- CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php b/CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php index 52a9c1f5..7fe7e31c 100644 --- a/CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php +++ b/CakePHP/Sniffs/Formatting/BlankLineBeforeReturnSniff.php @@ -45,6 +45,9 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[$current]['line'] == $previousLine && $tokens[$current]['type'] !== 'T_WHITESPACE' && $tokens[$current]['type'] !== 'T_COMMENT' + && $tokens[$current]['type'] !== 'T_DOC_COMMENT_OPEN_TAG' + && $tokens[$current]['type'] !== 'T_DOC_COMMENT_TAG' + && $tokens[$current]['type'] !== 'T_DOC_COMMENT_STRING' && $tokens[$current]['type'] !== 'T_DOC_COMMENT_CLOSE_TAG' && $tokens[$current]['type'] !== 'T_DOC_COMMENT_WHITESPACE' ) {