Skip to content

Commit 143e5a5

Browse files
📦 Start using some PSR12 rules
1 parent 566ff06 commit 143e5a5

13 files changed

+23
-324
lines changed

SymfonyCustom/Sniffs/Namespaces/UseWithoutStartingBackslashSniff.php

Lines changed: 0 additions & 72 deletions
This file was deleted.

SymfonyCustom/Sniffs/Objects/ObjectInstantiationSniff.php

Lines changed: 0 additions & 55 deletions
This file was deleted.

SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHP_CodeSniffer\Sniffs\Sniff;
99

1010
/**
11-
* Ensures there are no spaces on ++/-- or on +/- sign operators or "!" boolean negators.
11+
* Ensures there are no spaces +/- sign operators or "!" boolean negators.
1212
*/
1313
class UnaryOperatorSpacingSniff implements Sniff
1414
{
@@ -17,7 +17,7 @@ class UnaryOperatorSpacingSniff implements Sniff
1717
*/
1818
public function register(): array
1919
{
20-
return [T_DEC, T_INC, T_MINUS, T_PLUS, T_BOOLEAN_NOT];
20+
return [T_MINUS, T_PLUS, T_BOOLEAN_NOT];
2121
}
2222

2323
/**
@@ -28,40 +28,6 @@ public function process(File $phpcsFile, $stackPtr): void
2828
{
2929
$tokens = $phpcsFile->getTokens();
3030

31-
// Check decrement / increment.
32-
if (T_DEC === $tokens[$stackPtr]['code'] || T_INC === $tokens[$stackPtr]['code']) {
33-
$modifyLeft = substr($tokens[$stackPtr - 1]['content'], 0, 1) === '$'
34-
|| ';' === $tokens[$stackPtr + 1]['content'];
35-
36-
if ($modifyLeft && T_WHITESPACE === $tokens[$stackPtr - 1]['code']) {
37-
$fix = $phpcsFile->addFixableError(
38-
'There must not be a single space before a unary operator statement',
39-
$stackPtr,
40-
'IncDecLeft'
41-
);
42-
43-
if ($fix) {
44-
$phpcsFile->fixer->replaceToken($stackPtr - 1, '');
45-
}
46-
47-
return;
48-
}
49-
50-
if (!$modifyLeft && substr($tokens[$stackPtr + 1]['content'], 0, 1) !== '$') {
51-
$fix = $phpcsFile->addFixableError(
52-
'A unary operator statement must not be followed by a single space',
53-
$stackPtr,
54-
'IncDecRight'
55-
);
56-
57-
if ($fix) {
58-
$phpcsFile->fixer->replaceToken($stackPtr + 1, '');
59-
}
60-
61-
return;
62-
}
63-
}
64-
6531
// Check "!" operator.
6632
if (T_BOOLEAN_NOT === $tokens[$stackPtr]['code'] && T_WHITESPACE === $tokens[$stackPtr + 1]['code']) {
6733
$fix = $phpcsFile->addFixableError(

SymfonyCustom/Tests/Namespaces/UseWithoutStartingBackslashUnitTest.inc

Lines changed: 0 additions & 18 deletions
This file was deleted.

SymfonyCustom/Tests/Namespaces/UseWithoutStartingBackslashUnitTest.inc.fixed

Lines changed: 0 additions & 18 deletions
This file was deleted.

SymfonyCustom/Tests/Namespaces/UseWithoutStartingBackslashUnitTest.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.inc

Lines changed: 0 additions & 31 deletions
This file was deleted.

SymfonyCustom/Tests/Objects/ObjectInstantiationUnitTest.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

SymfonyCustom/Tests/PHP/DiscourageEmptyUnitTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace SymfonyCustom\Tests\Objects;
5+
namespace SymfonyCustom\Tests\PHP;
66

77
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
88

SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.inc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
$a = !$b;
44
$a = ! $b;
55

6-
$a++;
7-
$a ++;
8-
++$a;
9-
++ $a;
10-
116
1+-2;
127
1+- 2;
138
1+ -2;

SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.inc.fixed

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
$a = !$b;
44
$a = !$b;
55

6-
$a++;
7-
$a++;
8-
++$a;
9-
++$a;
10-
116
1+-2;
127
1+-2;
138
1+ -2;

SymfonyCustom/Tests/WhiteSpace/UnaryOperatorSpacingUnitTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ protected function getErrorList(): array
2323
7 => 1,
2424
9 => 1,
2525
12 => 1,
26-
14 => 1,
27-
17 => 1,
28-
18 => 1,
26+
13 => 1,
2927
];
3028
}
3129

0 commit comments

Comments
 (0)