Passed
Push — master ( f4c215...bf8a3b )
by Fabien
02:07
created
src/Codor/Sniffs/Classes/NewInstanceSniff.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types = 1);
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace Codor\Sniffs\Classes;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
      */
14 14
     public function register(): array
15 15
     {
16
-        return [T_FUNCTION];
16
+        return [ T_FUNCTION ];
17 17
     }
18 18
 
19 19
     /**
@@ -27,25 +27,25 @@  discard block
 block discarded – undo
27 27
     public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
28 28
     {
29 29
         $tokens = $phpcsFile->getTokens();
30
-        $functionName = $tokens[$stackPtr + 2]['content'];
30
+        $functionName = $tokens[ $stackPtr + 2 ][ 'content' ];
31 31
 
32 32
         $scopes = $this->getBracketsIndex($tokens, $stackPtr);
33
-        if (true === empty($scopes['open']) || true === empty($scopes['close'])) {
33
+        if (true === empty($scopes[ 'open' ]) || true === empty($scopes[ 'close' ])) {
34 34
             return;
35 35
         }
36 36
 
37
-        for ($index=$scopes['open']; $index <= $scopes['close']; $index++) {
38
-            if ($tokens[$index]['type'] === 'T_NEW') {
39
-                $phpcsFile->addWarning($this->getWarningMessage($functionName), $tokens[$index]['column'], __CLASS__);
37
+        for ($index = $scopes[ 'open' ]; $index <= $scopes[ 'close' ]; $index++) {
38
+            if ($tokens[ $index ][ 'type' ] === 'T_NEW') {
39
+                $phpcsFile->addWarning($this->getWarningMessage($functionName), $tokens[ $index ][ 'column' ], __CLASS__);
40 40
             }
41 41
         }
42 42
     }
43 43
 
44 44
     private function getBracketsIndex(array $tokens, int $stackPtr) : array
45 45
     {
46
-        $token = $tokens[$stackPtr];
47
-        $open = $token['scope_opener'] ?? null;
48
-        $close = $token['scope_closer'] ?? null;
46
+        $token = $tokens[ $stackPtr ];
47
+        $open = $token[ 'scope_opener' ] ?? null;
48
+        $close = $token[ 'scope_closer' ] ?? null;
49 49
 
50 50
         if (true === empty($open)) {
51 51
             return $this->searchBrackets($tokens, $stackPtr);
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
     private function searchBrackets(array $tokens, int $stackPtr) : array
61 61
     {
62 62
         $open = $close = null;
63
-        for ($i=$stackPtr; $i < count($tokens); $i++) {
64
-            if ($tokens[$i]['type'] === 'T_OPEN_CURLY_BRACKET') {
63
+        for ($i = $stackPtr; $i < count($tokens); $i++) {
64
+            if ($tokens[ $i ][ 'type' ] === 'T_OPEN_CURLY_BRACKET') {
65 65
                 $open = $i;
66 66
             }
67
-            if ($tokens[$i]['type'] === 'T_CLOSE_CURLY_BRACKET') {
67
+            if ($tokens[ $i ][ 'type' ] === 'T_CLOSE_CURLY_BRACKET') {
68 68
                 $close = $i;
69 69
             }
70 70
         }
Please login to merge, or discard this patch.