Skip to content

Commit c434d3e

Browse files
committed
Adopt CS
1 parent 2aa3713 commit c434d3e

File tree

8 files changed

+42
-61
lines changed

8 files changed

+42
-61
lines changed

lib/Doctrine/Sniffs/Spacing/ControlStructureSniff.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
<?php
2-
/*
3-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14-
*
15-
* This software consists of voluntary contributions made by many individuals
16-
* and is licensed under the MIT license. For more information, see
17-
* <http://www.doctrine-project.org>.
18-
*/
192

203
declare(strict_types=1);
214

@@ -39,9 +22,9 @@ final class ControlStructureSniff implements Sniff
3922
/**
4023
* Returns an array of tokens this test wants to listen for.
4124
*
42-
* @return array
25+
* @return int[]
4326
*/
44-
public function register()
27+
public function register() : array
4528
{
4629
return [
4730
\T_IF,
@@ -57,7 +40,11 @@ public function register()
5740
];
5841
}
5942

60-
public function process(File $phpcsFile, $stackPtr)
43+
/**
44+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
45+
* @param int $stackPtr
46+
*/
47+
public function process(File $phpcsFile, $stackPtr) : void
6148
{
6249
$tokens = $phpcsFile->getTokens();
6350

@@ -72,6 +59,9 @@ public function process(File $phpcsFile, $stackPtr)
7259
$this->validateParenthesisCloser($phpcsFile, $tokens, $stackPtr, $openerPosition, $closerPosition);
7360
}
7461

62+
/**
63+
* @param mixed[] $tokens
64+
*/
7565
private function validateParenthesisOpener(File $file, array $tokens, int $position, int $openerPosition) : void
7666
{
7767
$nextTokenPosition = $openerPosition + 1;
@@ -100,6 +90,9 @@ private function validateParenthesisOpener(File $file, array $tokens, int $posit
10090
$file->fixer->replaceToken($nextTokenPosition, '');
10191
}
10292

93+
/**
94+
* @param mixed[][] $tokens
95+
*/
10396
private function validateParenthesisCloser(
10497
File $file,
10598
array $tokens,

lib/Doctrine/Sniffs/Spacing/EnsureSpaces.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,4 @@
11
<?php
2-
/*
3-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14-
*
15-
* This software consists of voluntary contributions made by many individuals
16-
* and is licensed under the MIT license. For more information, see
17-
* <http://www.doctrine-project.org>.
18-
*/
192

203
declare(strict_types=1);
214

@@ -25,6 +8,9 @@
258

269
trait EnsureSpaces
2710
{
11+
/**
12+
* @param mixed[][] $tokens
13+
*/
2814
protected function ensureSpaceBefore(File $file, array $tokens, int $position, string $message) : void
2915
{
3016
$spacing = $this->numberOfSpaces($tokens, $position - 1);
@@ -45,6 +31,9 @@ protected function ensureSpaceBefore(File $file, array $tokens, int $position, s
4531
$file->fixer->replaceToken($position - 1, ' ');
4632
}
4733

34+
/**
35+
* @param mixed[][] $tokens
36+
*/
4837
protected function ensureSpaceAfter(File $file, array $tokens, int $position, string $message) : void
4938
{
5039
$spacing = $this->numberOfSpaces($tokens, $position + 1);
@@ -65,6 +54,9 @@ protected function ensureSpaceAfter(File $file, array $tokens, int $position, st
6554
$file->fixer->replaceToken($position + 1, ' ');
6655
}
6756

57+
/**
58+
* @param mixed[][] $tokens
59+
*/
6860
private function numberOfSpaces(array $tokens, int $position) : int
6961
{
7062
$token = $tokens[$position];

lib/Doctrine/Sniffs/Spacing/SpaceOnNotSniff.php

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
11
<?php
2-
/*
3-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7-
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8-
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9-
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10-
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11-
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13-
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14-
*
15-
* This software consists of voluntary contributions made by many individuals
16-
* and is licensed under the MIT license. For more information, see
17-
* <http://www.doctrine-project.org>.
18-
*/
192

203
declare(strict_types=1);
214

225
namespace Doctrine\Sniffs\Spacing;
236

24-
use PHP_CodeSniffer\Sniffs\Sniff;
257
use PHP_CodeSniffer\Files\File;
8+
use PHP_CodeSniffer\Sniffs\Sniff;
269

2710
final class SpaceOnNotSniff implements Sniff
2811
{
2912
use EnsureSpaces;
3013

3114
private const MESSAGE = 'There must be a single space %s a NOT operator; %d found';
3215

33-
public function register()
16+
/**
17+
* @return int[]
18+
*/
19+
public function register() : array
3420
{
3521
return [\T_BOOLEAN_NOT];
3622
}
3723

38-
public function process(File $phpcsFile, $stackPtr)
24+
/**
25+
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
26+
* @param int $stackPtr
27+
*/
28+
public function process(File $phpcsFile, $stackPtr) : void
3929
{
4030
$tokens = $phpcsFile->getTokens();
4131

tests/expected_report.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ FILE ERRORS WARNINGS
55
----------------------------------------------------------------------
66
tests/input/concatenation_spacing.php 19 0
77
tests/input/not_spacing.php 7 0
8-
tests/input/return_type_on_closures.php 21 0
9-
tests/input/return_type_on_methods.php 16 0
108
----------------------------------------------------------------------
11-
A TOTAL OF 63 ERRORS AND 0 WARNINGS WERE FOUND IN 4 FILES
9+
A TOTAL OF 26 ERRORS AND 0 WARNINGS WERE FOUND IN 2 FILES
1210
----------------------------------------------------------------------
13-
PHPCBF CAN FIX 63 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
11+
PHPCBF CAN FIX 26 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
1412
----------------------------------------------------------------------
1513

1614

tests/fixed/concatenation_spacing.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$string = 'Doctrine' . 'rulez';
46
$string = 'Doctrine' . 'rulez';
57
$string = 'Doctrine' . 'rulez';

tests/fixed/not_spacing.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$test = 1;
46

57
if ( ! $test > 0) {

tests/input/concatenation_spacing.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$string = 'Doctrine' . 'rulez';
46
$string = 'Doctrine'. 'rulez';
57
$string = 'Doctrine' .'rulez';

tests/input/not_spacing.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
$test = 1;
46

57
if (!$test > 0) {

0 commit comments

Comments
 (0)