Skip to content

Commit 9df3627

Browse files
Merge pull request #23 from VincentLanglet/staging
Staging
2 parents d735a22 + b49c817 commit 9df3627

File tree

52 files changed

+685
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+685
-309
lines changed

Symfony3Custom/Sniffs/Arrays/ArrayDeclarationSniff.php

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<?php
22

3+
namespace Symfony3Custom\Sniffs\Arrays;
4+
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Sniffs\Sniff;
7+
use PHP_CodeSniffer\Util\Tokens;
8+
39
/**
410
* A test to ensure that arrays conform to the array coding standard.
511
*/
6-
class Symfony3Custom_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
12+
class ArrayDeclarationSniff implements Sniff
713
{
814
/**
915
* The number of spaces code should be indented.
@@ -41,13 +47,13 @@ public function register()
4147
/**
4248
* Processes this sniff, when one of its tokens is encountered.
4349
*
44-
* @param PHP_CodeSniffer_File $phpcsFile The current file being checked.
45-
* @param int $stackPtr The position of the current token in
46-
* the stack passed in $tokens.
50+
* @param File $phpcsFile The current file being checked.
51+
* @param int $stackPtr The position of the current token in
52+
* the stack passed in $tokens.
4753
*
4854
* @return void
4955
*/
50-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56+
public function process(File $phpcsFile, $stackPtr)
5157
{
5258
$tokens = $phpcsFile->getTokens();
5359

@@ -132,15 +138,15 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
132138
/**
133139
* Processes a single-line array definition.
134140
*
135-
* @param PHP_CodeSniffer_File $phpcsFile The current file being checked.
136-
* @param int $stackPtr The position of the current token
137-
* in the stack passed in $tokens.
138-
* @param int $arrayStart The token that starts the array definition.
139-
* @param int $arrayEnd The token that ends the array definition.
141+
* @param File $phpcsFile The current file being checked.
142+
* @param int $stackPtr The position of the current token
143+
* in the stack passed in $tokens.
144+
* @param int $arrayStart The token that starts the array definition.
145+
* @param int $arrayEnd The token that ends the array definition.
140146
*
141147
* @return void
142148
*/
143-
public function processSingleLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $arrayStart, $arrayEnd)
149+
public function processSingleLineArray(File $phpcsFile, $stackPtr, $arrayStart, $arrayEnd)
144150
{
145151
$tokens = $phpcsFile->getTokens();
146152

@@ -278,15 +284,15 @@ public function processSingleLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPt
278284
/**
279285
* Processes a multi-line array definition.
280286
*
281-
* @param PHP_CodeSniffer_File $phpcsFile The current file being checked.
282-
* @param int $stackPtr The position of the current token
283-
* in the stack passed in $tokens.
284-
* @param int $arrayStart The token that starts the array definition.
285-
* @param int $arrayEnd The token that ends the array definition.
287+
* @param File $phpcsFile The current file being checked.
288+
* @param int $stackPtr The position of the current token
289+
* in the stack passed in $tokens.
290+
* @param int $arrayStart The token that starts the array definition.
291+
* @param int $arrayEnd The token that ends the array definition.
286292
*
287293
* @return void
288294
*/
289-
public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $arrayStart, $arrayEnd)
295+
public function processMultiLineArray(File $phpcsFile, $stackPtr, $arrayStart, $arrayEnd)
290296
{
291297
$tokens = $phpcsFile->getTokens();
292298

@@ -435,7 +441,7 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
435441
}
436442

437443
$valueContent = $phpcsFile->findNext(
438-
PHP_CodeSniffer_Tokens::$emptyTokens,
444+
Tokens::$emptyTokens,
439445
($lastToken + 1),
440446
$nextToken,
441447
true
@@ -482,7 +488,7 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
482488

483489
// Find the value of this index.
484490
$nextContent = $phpcsFile->findNext(
485-
PHP_CodeSniffer_Tokens::$emptyTokens,
491+
Tokens::$emptyTokens,
486492
($nextToken + 1),
487493
$arrayEnd,
488494
true
@@ -510,7 +516,7 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
510516
$lastIndex = $indices[($count - 1)]['value'];
511517

512518
$trailingContent = $phpcsFile->findPrevious(
513-
PHP_CodeSniffer_Tokens::$emptyTokens,
519+
Tokens::$emptyTokens,
514520
($arrayEnd - 1),
515521
$lastIndex,
516522
true
@@ -762,7 +768,7 @@ public function processMultiLineArray(PHP_CodeSniffer_File $phpcsFile, $stackPtr
762768
}
763769

764770
// Skip to the end of multi-line strings.
765-
if (isset(PHP_CodeSniffer_Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
771+
if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
766772
$i = $phpcsFile->findNext($tokens[$i]['code'], ($i + 1), null, true);
767773
$i--;
768774
$valueLine = $tokens[$i]['line'];

Symfony3Custom/Sniffs/Classes/PropertyDeclarationSniff.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22

3+
namespace Symfony3Custom\Sniffs\Classes;
4+
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Sniffs\Sniff;
7+
38
/**
49
* Throws warnings if properties are declared after methods
510
*/
6-
class Symfony3Custom_Sniffs_Classes_PropertyDeclarationSniff implements PHP_CodeSniffer_Sniff
11+
class PropertyDeclarationSniff implements Sniff
712
{
813
/**
914
* Returns an array of tokens this test wants to listen for.
@@ -20,13 +25,13 @@ public function register()
2025
/**
2126
* Processes this test, when one of its tokens is encountered.
2227
*
23-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
24-
* @param int $stackPtr The position of the current token
25-
* in the stack passed in $tokens.
28+
* @param File $phpcsFile The file being scanned.
29+
* @param int $stackPtr The position of the current token
30+
* in the stack passed in $tokens.
2631
*
2732
* @return void
2833
*/
29-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
34+
public function process(File $phpcsFile, $stackPtr)
3035
{
3136
$tokens = $phpcsFile->getTokens();
3237

Symfony3Custom/Sniffs/Commenting/ClassCommentSniff.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
<?php
22

3-
if (class_exists('PHP_CodeSniffer_Tokenizers_Comment', true) === false) {
4-
$error = 'Class PHP_CodeSniffer_Tokenizers_Comment not found';
5-
throw new PHP_CodeSniffer_Exception($error);
6-
}
3+
namespace Symfony3Custom\Sniffs\Commenting;
74

8-
if (class_exists('PEAR_Sniffs_Commenting_ClassCommentSniff', true) === false) {
9-
$error = 'Class PEAR_Sniffs_Commenting_ClassCommentSniff not found';
10-
throw new PHP_CodeSniffer_Exception($error);
11-
}
5+
use PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\ClassCommentSniff as PEARClassCommentSniff;
126

137
/**
148
* Parses and verifies the doc comments for classes.
@@ -24,7 +18,7 @@
2418
* <li>Check required and optional tags and the format of their content.</li>
2519
* </ul>
2620
*/
27-
class Symfony3Custom_Sniffs_Commenting_ClassCommentSniff extends PEAR_Sniffs_Commenting_ClassCommentSniff
21+
class ClassCommentSniff extends PEARClassCommentSniff
2822
{
2923
/**
3024
* Tags in correct order and related info.

Symfony3Custom/Sniffs/Commenting/DocCommentForbiddenTagsSniff.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22

3+
namespace Symfony3Custom\Sniffs\Commenting;
4+
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Sniffs\Sniff;
7+
38
/**
49
* Throws errors if forbidden tags are met.
510
*/
6-
class Symfony3Custom_Sniffs_Commenting_DocCommentForbiddenTagsSniff implements PHP_CodeSniffer_Sniff
11+
class DocCommentForbiddenTagsSniff implements Sniff
712
{
813
/**
914
* A list of PHPDoc tags that are forbidden.
@@ -30,13 +35,13 @@ public function register()
3035
/**
3136
* Processes this test, when one of its tokens is encountered.
3237
*
33-
* @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
34-
* @param int $stackPtr The position of the current token in
35-
* the stack passed in $tokens.
38+
* @param File $phpcsFile All the tokens found in the document.
39+
* @param int $stackPtr The position of the current token in
40+
* the stack passed in $tokens.
3641
*
3742
* @return void
3843
*/
39-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
44+
public function process(File $phpcsFile, $stackPtr)
4045
{
4146
$tokens = $phpcsFile->getTokens();
4247
if (in_array(

Symfony3Custom/Sniffs/Commenting/DocCommentGroupSameTypeSniff.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22

3+
namespace Symfony3Custom\Sniffs\Commenting;
4+
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Sniffs\Sniff;
7+
38
/**
49
* Throws errors if comments are not grouped by type with one blank line between them.
510
*/
6-
class Symfony3Custom_Sniffs_Commenting_DocCommentGroupSameTypeSniff implements PHP_CodeSniffer_Sniff
11+
class DocCommentGroupSameTypeSniff implements Sniff
712
{
813
/**
914
* A list of PHPDoc tags that are checked.
@@ -56,13 +61,13 @@ public function register()
5661
/**
5762
* Processes this test, when one of its tokens is encountered.
5863
*
59-
* @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
60-
* @param int $stackPtr The position of the current token in
61-
* the stack passed in $tokens.
64+
* @param File $phpcsFile All the tokens found in the document.
65+
* @param int $stackPtr The position of the current token in
66+
* the stack passed in $tokens.
6267
*
6368
* @return void
6469
*/
65-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
70+
public function process(File $phpcsFile, $stackPtr)
6671
{
6772
$tokens = $phpcsFile->getTokens();
6873

@@ -176,15 +181,15 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
176181
*
177182
* Note: this method does not start or end changeset.
178183
*
179-
* @param PHP_CodeSniffer_File $phpcsFile File to make changes in
180-
* @param int $fromPtr Start searching tokens from here
181-
* @param int $fromLine First line to delete tokens from
182-
* @param int $toLine Last line to delete tokens from
184+
* @param File $phpcsFile File to make changes in
185+
* @param int $fromPtr Start searching tokens from here
186+
* @param int $fromLine First line to delete tokens from
187+
* @param int $toLine Last line to delete tokens from
183188
*
184189
* @return void
185190
*/
186191
protected function removeLines(
187-
PHP_CodeSniffer_File $phpcsFile,
192+
File $phpcsFile,
188193
$fromPtr,
189194
$fromLine,
190195
$toLine

Symfony3Custom/Sniffs/Commenting/FunctionCommentSniff.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<?php
22

3-
if (class_exists('PEAR_Sniffs_Commenting_FunctionCommentSniff', true) === false) {
4-
$error = 'Class PEAR_Sniffs_Commenting_FunctionCommentSniff not found';
5-
throw new PHP_CodeSniffer_Exception($error);
6-
}
3+
namespace Symfony3Custom\Sniffs\Commenting;
4+
5+
use PHP_CodeSniffer\Files\File;
6+
use PHP_CodeSniffer\Standards\PEAR\Sniffs\Commenting\FunctionCommentSniff as PEARFunctionCommentSniff;
7+
use PHP_CodeSniffer\Util\Tokens;
78

89
/**
910
* Symfony3Custom standard customization to PEARs FunctionCommentSniff.
@@ -15,21 +16,21 @@
1516
* </li>
1617
* </ul>
1718
*/
18-
class Symfony3Custom_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commenting_FunctionCommentSniff
19+
class FunctionCommentSniff extends PEARFunctionCommentSniff
1920
{
2021
/**
2122
* Processes this test, when one of its tokens is encountered.
2223
*
23-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
24-
* @param int $stackPtr The position of the current token
25-
* in the stack passed in $tokens.
24+
* @param File $phpcsFile The file being scanned.
25+
* @param int $stackPtr The position of the current token
26+
* in the stack passed in $tokens.
2627
*
2728
* @return void
2829
*/
29-
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
30+
public function process(File $phpcsFile, $stackPtr)
3031
{
3132
$tokens = $phpcsFile->getTokens();
32-
$find = PHP_CodeSniffer_Tokens::$methodPrefixes;
33+
$find = Tokens::$methodPrefixes;
3334
$find[] = T_WHITESPACE;
3435

3536
$commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
@@ -97,7 +98,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
9798
} else {
9899
// No comment but maybe a method prefix
99100
$methodPrefixes = $phpcsFile->findFirstOnLine(
100-
PHP_CodeSniffer_Tokens::$methodPrefixes,
101+
Tokens::$methodPrefixes,
101102
$stackPtr
102103
);
103104

@@ -132,17 +133,15 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
132133
/**
133134
* Process the return comment of this function comment.
134135
*
135-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
136-
* @param int $stackPtr The position of the current token
137-
* in the stack passed in $tokens.
138-
* @param int|null $commentStart The position in the stack
139-
* where the comment started.
140-
* @param bool $hasRealComment
136+
* @param File $phpcsFile The file being scanned.
137+
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
138+
* @param int|null $commentStart The position in the stack where the comment started.
139+
* @param bool $hasRealComment
141140
*
142141
* @return void
143142
*/
144143
protected function processReturn(
145-
PHP_CodeSniffer_File $phpcsFile,
144+
File $phpcsFile,
146145
$stackPtr,
147146
$commentStart,
148147
$hasRealComment = true
@@ -190,12 +189,12 @@ protected function processReturn(
190189
}
191190

192191
/**
193-
* @param PHP_CodeSniffer_File $phpcsFile
194-
* @param int $commentStart
195-
* @param bool $hasRealComment
192+
* @param File $phpcsFile
193+
* @param int $commentStart
194+
* @param bool $hasRealComment
196195
*/
197196
protected function processWhitespace(
198-
PHP_CodeSniffer_File $phpcsFile,
197+
File $phpcsFile,
199198
$commentStart,
200199
$hasRealComment = true
201200
) {
@@ -248,13 +247,12 @@ protected function processWhitespace(
248247
/**
249248
* Is the comment an inheritdoc?
250249
*
251-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
252-
* @param int $stackPtr The position of the current token
253-
* in the stack passed in $tokens.
250+
* @param File $phpcsFile The file being scanned.
251+
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
254252
*
255253
* @return bool True if the comment is an inheritdoc
256254
*/
257-
protected function isInheritDoc(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
255+
protected function isInheritDoc(File $phpcsFile, $stackPtr)
258256
{
259257
$start = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1);
260258
$end = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, $start);
@@ -267,16 +265,14 @@ protected function isInheritDoc(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
267265
/**
268266
* Process the function parameter comments.
269267
*
270-
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
271-
* @param int $stackPtr The position of the current token
272-
* in the stack passed in $tokens.
273-
* @param int $commentStart The position in the stack
274-
* where the comment started.
268+
* @param File $phpcsFile The file being scanned.
269+
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
270+
* @param int $commentStart The position in the stack where the comment started.
275271
*
276272
* @return void
277273
*/
278274
protected function processParams(
279-
PHP_CodeSniffer_File $phpcsFile,
275+
File $phpcsFile,
280276
$stackPtr,
281277
$commentStart
282278
) {

0 commit comments

Comments
 (0)