Skip to content

Commit 10c3d0f

Browse files
✨ Start using PSR12
1 parent 7f763c5 commit 10c3d0f

12 files changed

+24
-302
lines changed

SymfonyCustom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function process(File $phpcsFile, $stackPtr): void
3636
$phpcsFile->addError(
3737
'The %s annotation is forbidden to use',
3838
$stackPtr,
39-
'',
39+
'Invalid',
4040
[$tokens[$stackPtr]['content']]
4141
);
4242
}

SymfonyCustom/Sniffs/Commenting/DocCommentSniff.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ public function process(File $phpcsFile, $stackPtr): void
3838

3939
$commentEnd = $tokens[$stackPtr]['comment_closer'];
4040

41-
$empty = [
42-
T_DOC_COMMENT_WHITESPACE,
43-
T_DOC_COMMENT_STAR,
44-
];
41+
$empty = [T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR];
4542

4643
$short = $phpcsFile->findNext($empty, $stackPtr + 1, $commentEnd, true);
4744
if (false === $short) {

SymfonyCustom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ public function process(File $phpcsFile, $stackPtr): void
100100
}
101101
}
102102
}
103-
104-
$this->processWhitespace($phpcsFile, $commentStart);
105103
}
106104

107105
/**
@@ -215,58 +213,6 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart): voi
215213
parent::processParams($phpcsFile, $stackPtr, $commentStart);
216214
}
217215

218-
/**
219-
* @param File $phpcsFile
220-
* @param int $commentStart
221-
* @param bool $hasComment
222-
*/
223-
private function processWhitespace(File $phpcsFile, int $commentStart, bool $hasComment = true): void
224-
{
225-
$tokens = $phpcsFile->getTokens();
226-
$before = $phpcsFile->findPrevious(T_WHITESPACE, $commentStart - 1, null, true);
227-
228-
$startLine = $tokens[$commentStart]['line'];
229-
$prevLine = $tokens[$before]['line'];
230-
231-
$found = $startLine - $prevLine - 1;
232-
233-
// Skip for class opening
234-
if ($found < 1 && T_OPEN_CURLY_BRACKET !== $tokens[$before]['code']) {
235-
if ($found < 0) {
236-
$found = 0;
237-
}
238-
239-
if ($hasComment) {
240-
$error = 'Expected 1 blank line before docblock; %s found';
241-
$rule = 'SpacingBeforeDocblock';
242-
} else {
243-
$error = 'Expected 1 blank line before function; %s found';
244-
$rule = 'SpacingBeforeFunction';
245-
}
246-
247-
$fix = $phpcsFile->addFixableError($error, $commentStart, $rule, [$found]);
248-
249-
if ($fix) {
250-
if ($found > 1) {
251-
$phpcsFile->fixer->beginChangeset();
252-
253-
for ($i = $before + 1; $i < $commentStart - 1; $i++) {
254-
$phpcsFile->fixer->replaceToken($i, '');
255-
}
256-
257-
$phpcsFile->fixer->endChangeset();
258-
} else {
259-
// Try and maintain indentation.
260-
if (T_WHITESPACE === $tokens[$commentStart - 1]['code']) {
261-
$phpcsFile->fixer->addNewlineBefore($commentStart - 1);
262-
} else {
263-
$phpcsFile->fixer->addNewlineBefore($commentStart);
264-
}
265-
}
266-
}
267-
}
268-
}
269-
270216
/**
271217
* @param File $phpcsFile
272218
* @param int $stackPtr

SymfonyCustom/Sniffs/Commenting/VariableCommentSniff.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ public function processMemberVar(File $phpcsFile, $stackPtr): void
110110
$phpcsFile->fixer->replaceToken($string, implode(' ', $newContent));
111111
}
112112
}
113-
114-
$this->processWhitespace($phpcsFile, $commentStart);
115113
}
116114

117115
/**
@@ -129,52 +127,4 @@ protected function processVariable(File $phpcsFile, $stackPtr): void
129127
protected function processVariableInString(File $phpcsFile, $stackPtr): void
130128
{
131129
}
132-
133-
/**
134-
* @param File $phpcsFile
135-
* @param int $commentStart
136-
*/
137-
private function processWhitespace(File $phpcsFile, int $commentStart): void
138-
{
139-
$tokens = $phpcsFile->getTokens();
140-
$before = $phpcsFile->findPrevious(T_WHITESPACE, $commentStart - 1, null, true);
141-
142-
$startLine = $tokens[$commentStart]['line'];
143-
$prevLine = $tokens[$before]['line'];
144-
145-
$found = $startLine - $prevLine - 1;
146-
147-
// Skip for class opening
148-
if ($found < 1 && T_OPEN_CURLY_BRACKET !== $tokens[$before]['code']) {
149-
if ($found < 0) {
150-
$found = 0;
151-
}
152-
153-
$fix = $phpcsFile->addFixableError(
154-
'Expected 1 blank line before docblock; %s found',
155-
$commentStart,
156-
'SpacingBeforeDocblock',
157-
[$found]
158-
);
159-
160-
if ($fix) {
161-
if ($found > 1) {
162-
$phpcsFile->fixer->beginChangeset();
163-
164-
for ($i = $before + 1; $i < $commentStart - 1; $i++) {
165-
$phpcsFile->fixer->replaceToken($i, '');
166-
}
167-
168-
$phpcsFile->fixer->endChangeset();
169-
} else {
170-
// Try and maintain indentation.
171-
if (T_WHITESPACE === $tokens[$commentStart - 1]['code']) {
172-
$phpcsFile->fixer->addNewlineBefore($commentStart - 1);
173-
} else {
174-
$phpcsFile->fixer->addNewlineBefore($commentStart);
175-
}
176-
}
177-
}
178-
}
179-
}
180130
}

SymfonyCustom/Sniffs/Namespaces/AlphabeticallySortedUseSniff.php

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,42 +62,6 @@ public function process(File $phpcsFile, $stackPtr): int
6262
return $stackPtr + 1;
6363
}
6464

65-
// Check empty lines between use statements.
66-
// There must be no empty lines between use statements.
67-
$lineDiff = $tokens[$use['ptrUse']]['line'] - $tokens[$lastUse['ptrUse']]['line'];
68-
if ($lineDiff > 1) {
69-
$fix = $phpcsFile->addFixableError(
70-
'There must not be any empty line between use statement',
71-
$use['ptrUse'],
72-
'EmptyLine'
73-
);
74-
75-
if ($fix) {
76-
$phpcsFile->fixer->beginChangeset();
77-
for ($i = $lastUse['ptrEnd'] + 1; $i < $use['ptrUse']; ++$i) {
78-
if (false !== strpos($tokens[$i]['content'], $phpcsFile->eolChar)) {
79-
$phpcsFile->fixer->replaceToken($i, '');
80-
--$lineDiff;
81-
82-
if (1 === $lineDiff) {
83-
break;
84-
}
85-
}
86-
}
87-
$phpcsFile->fixer->endChangeset();
88-
}
89-
} elseif (0 === $lineDiff) {
90-
$fix = $phpcsFile->addFixableError(
91-
'Each use statement must be in new line',
92-
$use['ptrUse'],
93-
'TheSameLine'
94-
);
95-
96-
if ($fix) {
97-
$phpcsFile->fixer->addNewline($lastUse['ptrEnd']);
98-
}
99-
}
100-
10165
$lastUse = $use;
10266
}
10367

SymfonyCustom/Sniffs/Namespaces/NamespaceDeclarationSniff.php

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

SymfonyCustom/Sniffs/SniffHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHP_CodeSniffer\Util\Tokens;
99

1010
/**
11-
* class Helper
11+
* class SniffHelper
1212
*
1313
* @internal
1414
*/

SymfonyCustom/Sniffs/WhiteSpace/UnaryOperatorSpacingSniff.php

Lines changed: 1 addition & 1 deletion
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 +/- sign operators or "!" boolean negators.
11+
* Ensures there are no spaces +/- sign operators.
1212
*/
1313
class UnaryOperatorSpacingSniff implements Sniff
1414
{

SymfonyCustom/Tests/Namespaces/NamespaceDeclarationUnitTest.inc

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

SymfonyCustom/Tests/Namespaces/NamespaceDeclarationUnitTest.inc.fixed

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

SymfonyCustom/Tests/Namespaces/NamespaceDeclarationUnitTest.php

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

0 commit comments

Comments
 (0)