diff --git a/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php b/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php index 462d012..54b9181 100644 --- a/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php +++ b/SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php @@ -37,12 +37,14 @@ public function process(File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $current = $stackPtr; $previousLine = $tokens[$stackPtr]['line'] - 1; - $prevLineTokens = array(); + $prevLineTokens = array(); while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) { if ($tokens[$current]['line'] === $previousLine && 'T_WHITESPACE' !== $tokens[$current]['type'] && 'T_COMMENT' !== $tokens[$current]['type'] + && 'T_DOC_COMMENT_STRING' !== $tokens[$current]['type'] + && 'T_DOC_COMMENT_OPEN_TAG' !== $tokens[$current]['type'] && 'T_DOC_COMMENT_CLOSE_TAG' !== $tokens[$current]['type'] && 'T_DOC_COMMENT_WHITESPACE' !== $tokens[$current]['type'] ) { @@ -62,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr) $fix = $phpcsFile->addFixableError( 'Missing blank line before return statement', $stackPtr, - 'MissedBlankLineBeforeRetrun' + 'MissedBlankLineBeforeReturn' ); if (true === $fix) { diff --git a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc index 90dd845..eb803bf 100644 --- a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc +++ b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc @@ -31,6 +31,12 @@ function validFunctionReturnFive() return; } +function validFunctionReturnSix() +{ + /** comment */ + return; +} + function invalidFunctionReturnOne() { echo ""; diff --git a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed index a581405..3cd4606 100644 --- a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed +++ b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed @@ -31,6 +31,12 @@ function validFunctionReturnFive() return; } +function validFunctionReturnSix() +{ + /** comment */ + return; +} + function invalidFunctionReturnOne() { echo ""; diff --git a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php index 4e70da5..48bc1bb 100644 --- a/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php +++ b/SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php @@ -22,7 +22,7 @@ class BlankLineBeforeReturnUnitTest extends AbstractSniffUnitTest public function getErrorList() { return array( - 37 => 1, + 43 => 1, ); } diff --git a/docs/installation.md b/docs/installation.md index 8d79559..602b594 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -5,7 +5,7 @@ This standard can be installed with the [Composer](https://getcomposer.org/) dep 1. Add the coding standard as a dependency of your project ``` -composer require --dev vincentlanglet/symfony3-custom-coding-standard +composer require --dev vincentlanglet/symfony-custom-coding-standard ``` 2. Add the coding standard to the PHP_CodeSniffer install path @@ -14,7 +14,7 @@ The path is relative to the php_codesniffer install path. This is important to make it work both in your vagrant, local machine and PHPStorm ``` -bin/phpcs --config-set installed_paths ../../vincentlanglet/symfony3-custom-coding-standard +bin/phpcs --config-set installed_paths ../../vincentlanglet/symfony-custom-coding-standard ``` 3. Check the installed coding standards