Skip to content

Commit 918432d

Browse files
Merge pull request #40 from VincentLanglet/fixReturn
Fix return
2 parents 9a1cdb2 + 46f04a4 commit 918432d

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ public function process(File $phpcsFile, $stackPtr)
3737
$tokens = $phpcsFile->getTokens();
3838
$current = $stackPtr;
3939
$previousLine = $tokens[$stackPtr]['line'] - 1;
40-
$prevLineTokens = array();
40+
$prevLineTokens = array();
4141

4242
while ($current >= 0 && $tokens[$current]['line'] >= $previousLine) {
4343
if ($tokens[$current]['line'] === $previousLine
4444
&& 'T_WHITESPACE' !== $tokens[$current]['type']
4545
&& 'T_COMMENT' !== $tokens[$current]['type']
46+
&& 'T_DOC_COMMENT_STRING' !== $tokens[$current]['type']
47+
&& 'T_DOC_COMMENT_OPEN_TAG' !== $tokens[$current]['type']
4648
&& 'T_DOC_COMMENT_CLOSE_TAG' !== $tokens[$current]['type']
4749
&& 'T_DOC_COMMENT_WHITESPACE' !== $tokens[$current]['type']
4850
) {
@@ -62,7 +64,7 @@ public function process(File $phpcsFile, $stackPtr)
6264
$fix = $phpcsFile->addFixableError(
6365
'Missing blank line before return statement',
6466
$stackPtr,
65-
'MissedBlankLineBeforeRetrun'
67+
'MissedBlankLineBeforeReturn'
6668
);
6769

6870
if (true === $fix) {

SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ function validFunctionReturnFive()
3131
return;
3232
}
3333

34+
function validFunctionReturnSix()
35+
{
36+
/** comment */
37+
return;
38+
}
39+
3440
function invalidFunctionReturnOne()
3541
{
3642
echo "";

SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ function validFunctionReturnFive()
3131
return;
3232
}
3333

34+
function validFunctionReturnSix()
35+
{
36+
/** comment */
37+
return;
38+
}
39+
3440
function invalidFunctionReturnOne()
3541
{
3642
echo "";

SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class BlankLineBeforeReturnUnitTest extends AbstractSniffUnitTest
2222
public function getErrorList()
2323
{
2424
return array(
25-
37 => 1,
25+
43 => 1,
2626
);
2727
}
2828

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This standard can be installed with the [Composer](https://getcomposer.org/) dep
55
1. Add the coding standard as a dependency of your project
66

77
```
8-
composer require --dev vincentlanglet/symfony3-custom-coding-standard
8+
composer require --dev vincentlanglet/symfony-custom-coding-standard
99
```
1010

1111
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.
1414
This is important to make it work both in your vagrant, local machine and PHPStorm
1515

1616
```
17-
bin/phpcs --config-set installed_paths ../../vincentlanglet/symfony3-custom-coding-standard
17+
bin/phpcs --config-set installed_paths ../../vincentlanglet/symfony-custom-coding-standard
1818
```
1919

2020
3. Check the installed coding standards

0 commit comments

Comments
 (0)