Skip to content

Commit 1baadaf

Browse files
🔧 Update version + some fix
1 parent 694c0e0 commit 1baadaf

10 files changed

+178
-238
lines changed

SymfonyCustom/Sniffs/Formatting/BlankLineBeforeReturnSniff.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use PHP_CodeSniffer\Files\File;
66
use PHP_CodeSniffer\Sniffs\Sniff;
7+
use PHP_CodeSniffer\Util\Tokens;
78

89
/**
910
* Throws errors if there's no blank line before return statements.
@@ -92,11 +93,6 @@ public function process(File $phpcsFile, $stackPtr)
9293
*/
9394
private function isComment(array $token)
9495
{
95-
return 'T_COMMENT' === $token['type']
96-
|| 'T_DOC_COMMENT_STRING' === $token['type']
97-
|| 'T_DOC_COMMENT_OPEN_TAG' === $token['type']
98-
|| 'T_DOC_COMMENT_TAG' === $token['type']
99-
|| 'T_DOC_COMMENT_CLOSE_TAG' === $token['type']
100-
|| 'T_DOC_COMMENT_WHITESPACE' === $token['type'];
96+
return in_array($token['code'], Tokens::$commentTokens);
10197
}
10298
}

SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ public function process(File $phpcsFile, $stackPtr)
102102

103103
while (false !== $classUsed) {
104104
if (strtolower($tokens[$classUsed]['content']) === $lowerClassName) {
105-
// If the name is used in a PHP 7 function return type declaration stop.
106-
if (T_RETURN_TYPE === $tokens[$classUsed]['code']) {
107-
return;
108-
}
109-
110105
$beforeUsage = $phpcsFile->findPrevious(
111106
Tokens::$emptyTokens,
112107
($classUsed - 1),
@@ -125,10 +120,7 @@ public function process(File $phpcsFile, $stackPtr)
125120
}
126121
}
127122

128-
$classUsed = $phpcsFile->findNext(
129-
[T_STRING, T_RETURN_TYPE],
130-
($classUsed + 1)
131-
);
123+
$classUsed = $phpcsFile->findNext([T_STRING], ($classUsed + 1));
132124
}
133125

134126
// More checks

SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.inc.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function invalidFunctionReturnTwo()
7272
function invalidFunctionReturnThree()
7373
{
7474
echo "";
75+
7576
/**
7677
* comment
7778
*/

SymfonyCustom/Tests/Formatting/BlankLineBeforeReturnUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function getErrorList()
2424
return array(
2525
60 => 1,
2626
67 => 1,
27+
76 => 1,
2728
);
2829
}
2930

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use Route;
88
use ORM;
99
use Truc;
1010
use Machin;
11-
use Machine;
1211
use Unused;
1312
use Client;
1413
use Clients;
1514
use PasClient;
15+
use Somewhere\Something;
1616

1717
class Container
1818
{
@@ -23,9 +23,9 @@ class Container
2323
*
2424
* @param Toto $toto
2525
* @var Truc $truc
26-
* @return Machin|Machine
26+
* @return Machin|\Machine
2727
*/
28-
function test (Bar $bar)
28+
function test (Bar $bar): Something
2929
{
3030
/** @var Client|Clients[]|PasClient $client */
3131

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc.fixed

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use Route;
88
use ORM;
99
use Truc;
1010
use Machin;
11-
use Machine;
1211
use Client;
1312
use Clients;
1413
use PasClient;
14+
use Somewhere\Something;
1515

1616
class Container
1717
{
@@ -22,9 +22,9 @@ class Container
2222
*
2323
* @param Toto $toto
2424
* @var Truc $truc
25-
* @return Machin|Machine
25+
* @return Machin|\Machine
2626
*/
27-
function test (Bar $bar)
27+
function test (Bar $bar): Something
2828
{
2929
/** @var Client|Clients[]|PasClient $client */
3030

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php

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

SymfonyCustom/ruleset.xml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,58 +16,58 @@
1616
<!-- *** PSR2 *** -->
1717
<!-- ************** -->
1818

19-
<!-- Include the whole PSR-2 (so PSR-1) standard -->
20-
<rule ref="PSR2"/>
19+
<!-- Include the whole PSR-2 (so PSR-1) standard -->
20+
<rule ref="PSR2"/>
2121

22-
<!-- Override SuperfluousWhitespace to not ignore blank lines -->
23-
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
24-
<properties>
25-
<property name="ignoreBlankLines" value="false"/>
26-
</properties>
27-
</rule>
22+
<!-- Override SuperfluousWhitespace to not ignore blank lines -->
23+
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
24+
<properties>
25+
<property name="ignoreBlankLines" value="false"/>
26+
</properties>
27+
</rule>
2828

29-
<!-- Override FunctionDeclaration to check space after type hinting -->
30-
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
31-
<severity>5</severity>
32-
</rule>
29+
<!-- Override FunctionDeclaration to check space after type hinting -->
30+
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
31+
<severity>5</severity>
32+
</rule>
3333

3434
<!-- **************** -->
3535
<!-- *** OTHERS *** -->
3636
<!-- **************** -->
3737

38-
<!-- From djoos repo -->
39-
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
40-
<rule ref="Squiz.NamingConventions.ValidVariableName">
41-
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
42-
<exclude name="Squiz.NamingConventions.ValidVariableName.ContainsNumbers"/>
43-
</rule>
44-
<rule ref="Generic.Formatting.SpaceAfterCast"/>
45-
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
46-
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
47-
<rule ref="Squiz.Scope.MemberVarScope"/>
48-
<rule ref="PEAR.Commenting.InlineComment"/>
38+
<!-- From djoos repo -->
39+
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
40+
<rule ref="Squiz.NamingConventions.ValidVariableName">
41+
<exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/>
42+
<exclude name="Squiz.NamingConventions.ValidVariableName.ContainsNumbers"/>
43+
</rule>
44+
<rule ref="Generic.Formatting.SpaceAfterCast"/>
45+
<rule ref="Squiz.Arrays.ArrayBracketSpacing"/>
46+
<rule ref="Squiz.PHP.LowercasePHPFunctions"/>
47+
<rule ref="Squiz.Scope.MemberVarScope"/>
48+
<rule ref="PEAR.Commenting.InlineComment"/>
4949

50-
<!-- From endouble repo -->
51-
<rule ref="Squiz.Strings.ConcatenationSpacing">
52-
<properties>
53-
<property name="ignoreNewlines" value="true" />
54-
</properties>
55-
</rule>
56-
<rule ref="SymfonyCustom.Commenting.FunctionComment">
57-
<exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/>
58-
</rule>
50+
<!-- From endouble repo -->
51+
<rule ref="Squiz.Strings.ConcatenationSpacing">
52+
<properties>
53+
<property name="ignoreNewlines" value="true" />
54+
</properties>
55+
</rule>
56+
<rule ref="SymfonyCustom.Commenting.FunctionComment">
57+
<exclude name="SymfonyCustom.Commenting.FunctionComment.MissingParamComment"/>
58+
</rule>
5959

60-
<!-- Added by VincentLanglet repo -->
61-
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
62-
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
63-
<rule ref="Squiz.Strings.DoubleQuoteUsage">
64-
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
65-
</rule>
66-
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
67-
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
68-
<properties>
69-
<property name="ignoreNewlines" value="true"/>
70-
</properties>
71-
</rule>
72-
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
60+
<!-- Added by VincentLanglet repo -->
61+
<rule ref="Generic.PHP.ForbiddenFunctions"/>
62+
<rule ref="Squiz.PHP.DiscouragedFunctions"/>
63+
<rule ref="Squiz.Strings.DoubleQuoteUsage">
64+
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
65+
</rule>
66+
<rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/>
67+
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
68+
<properties>
69+
<property name="ignoreNewlines" value="true"/>
70+
</properties>
71+
</rule>
72+
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
7373
</ruleset>

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
}
1616
],
1717
"require": {
18-
"squizlabs/php_codesniffer": "3.2.*"
18+
"squizlabs/php_codesniffer": "3.4.*"
1919
},
2020
"require-dev": {
21-
"phpunit/phpunit": "^6.0"
21+
"phpunit/phpunit": "^7.0"
2222
}
2323
}

0 commit comments

Comments
 (0)