Completed
Pull Request — develop (#1492)
by Zack
28:58 queued 09:00
created
Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function register()
43 43
     {
44
-        return [T_FOR];
44
+        return [ T_FOR ];
45 45
 
46 46
     }//end register()
47 47
 
@@ -55,42 +55,42 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return void
57 57
      */
58
-    public function process(File $phpcsFile, $stackPtr)
58
+    public function process( File $phpcsFile, $stackPtr )
59 59
     {
60 60
         $tokens = $phpcsFile->getTokens();
61
-        $token  = $tokens[$stackPtr];
61
+        $token  = $tokens[ $stackPtr ];
62 62
 
63 63
         // Skip invalid statement.
64
-        if (isset($token['parenthesis_opener']) === false) {
64
+        if ( isset( $token[ 'parenthesis_opener' ] ) === false ) {
65 65
             return;
66 66
         }
67 67
 
68
-        $next = ++$token['parenthesis_opener'];
69
-        $end  = --$token['parenthesis_closer'];
68
+        $next = ++$token[ 'parenthesis_opener' ];
69
+        $end  = --$token[ 'parenthesis_closer' ];
70 70
 
71 71
         $position = 0;
72 72
 
73
-        for (; $next <= $end; ++$next) {
74
-            $code = $tokens[$next]['code'];
75
-            if ($code === T_SEMICOLON) {
73
+        for ( ; $next <= $end; ++$next ) {
74
+            $code = $tokens[ $next ][ 'code' ];
75
+            if ( $code === T_SEMICOLON ) {
76 76
                 ++$position;
77 77
             }
78 78
 
79
-            if ($position < 1) {
79
+            if ( $position < 1 ) {
80 80
                 continue;
81
-            } else if ($position > 1) {
81
+            } else if ( $position > 1 ) {
82 82
                 break;
83
-            } else if ($code !== T_VARIABLE && $code !== T_STRING) {
83
+            } else if ( $code !== T_VARIABLE && $code !== T_STRING ) {
84 84
                 continue;
85 85
             }
86 86
 
87 87
             // Find next non empty token, if it is a open curly brace we have a
88 88
             // function call.
89
-            $index = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true);
89
+            $index = $phpcsFile->findNext( Tokens::$emptyTokens, ( $next + 1 ), null, true );
90 90
 
91
-            if ($tokens[$index]['code'] === T_OPEN_PARENTHESIS) {
91
+            if ( $tokens[ $index ][ 'code' ] === T_OPEN_PARENTHESIS ) {
92 92
                 $error = 'Avoid function calls in a FOR loop test part';
93
-                $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed');
93
+                $phpcsFile->addWarning( $error, $stackPtr, 'NotAllowed' );
94 94
                 break;
95 95
             }
96 96
         }//end for
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -44,28 +44,28 @@  discard block
 block discarded – undo
44 44
      *
45 45
      * @return void
46 46
      */
47
-    public function process(File $phpcsFile, $stackPtr)
47
+    public function process( File $phpcsFile, $stackPtr )
48 48
     {
49 49
         $tokens = $phpcsFile->getTokens();
50 50
 
51
-        switch ($tokens[$stackPtr]['type']) {
51
+        switch ( $tokens[ $stackPtr ][ 'type' ] ) {
52 52
         // Detect `something();;`.
53 53
         case 'T_SEMICOLON':
54
-            $prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
54
+            $prevNonEmpty = $phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
55 55
 
56
-            if ($prevNonEmpty === false
57
-                || ($tokens[$prevNonEmpty]['code'] !== T_SEMICOLON
58
-                && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG
59
-                && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO)
56
+            if ( $prevNonEmpty === false
57
+                || ( $tokens[ $prevNonEmpty ][ 'code' ] !== T_SEMICOLON
58
+                && $tokens[ $prevNonEmpty ][ 'code' ] !== T_OPEN_TAG
59
+                && $tokens[ $prevNonEmpty ][ 'code' ] !== T_OPEN_TAG_WITH_ECHO )
60 60
             ) {
61 61
                 return;
62 62
             }
63 63
 
64
-            if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
65
-                $nested     = $tokens[$stackPtr]['nested_parenthesis'];
66
-                $lastCloser = array_pop($nested);
67
-                if (isset($tokens[$lastCloser]['parenthesis_owner']) === true
68
-                    && $tokens[$tokens[$lastCloser]['parenthesis_owner']]['code'] === T_FOR
64
+            if ( isset( $tokens[ $stackPtr ][ 'nested_parenthesis' ] ) === true ) {
65
+                $nested     = $tokens[ $stackPtr ][ 'nested_parenthesis' ];
66
+                $lastCloser = array_pop( $nested );
67
+                if ( isset( $tokens[ $lastCloser ][ 'parenthesis_owner' ] ) === true
68
+                    && $tokens[ $tokens[ $lastCloser ][ 'parenthesis_owner' ] ][ 'code' ] === T_FOR
69 69
                 ) {
70 70
                     // Empty for() condition.
71 71
                     return;
@@ -77,29 +77,29 @@  discard block
 block discarded – undo
77 77
                 $stackPtr,
78 78
                 'SemicolonWithoutCodeDetected'
79 79
             );
80
-            if ($fix === true) {
80
+            if ( $fix === true ) {
81 81
                 $phpcsFile->fixer->beginChangeset();
82 82
 
83
-                if ($tokens[$prevNonEmpty]['code'] === T_OPEN_TAG
84
-                    || $tokens[$prevNonEmpty]['code'] === T_OPEN_TAG_WITH_ECHO
83
+                if ( $tokens[ $prevNonEmpty ][ 'code' ] === T_OPEN_TAG
84
+                    || $tokens[ $prevNonEmpty ][ 'code' ] === T_OPEN_TAG_WITH_ECHO
85 85
                 ) {
86 86
                     // Check for superfluous whitespace after the semi-colon which will be
87 87
                     // removed as the `<?php ` open tag token already contains whitespace,
88 88
                     // either a space or a new line.
89
-                    if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
90
-                        $replacement = str_replace(' ', '', $tokens[($stackPtr + 1)]['content']);
91
-                        $phpcsFile->fixer->replaceToken(($stackPtr + 1), $replacement);
89
+                    if ( $tokens[ ( $stackPtr + 1 ) ][ 'code' ] === T_WHITESPACE ) {
90
+                        $replacement = str_replace( ' ', '', $tokens[ ( $stackPtr + 1 ) ][ 'content' ] );
91
+                        $phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
92 92
                     }
93 93
                 }
94 94
 
95
-                for ($i = $stackPtr; $i > $prevNonEmpty; $i--) {
96
-                    if ($tokens[$i]['code'] !== T_SEMICOLON
97
-                        && $tokens[$i]['code'] !== T_WHITESPACE
95
+                for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
96
+                    if ( $tokens[ $i ][ 'code' ] !== T_SEMICOLON
97
+                        && $tokens[ $i ][ 'code' ] !== T_WHITESPACE
98 98
                     ) {
99 99
                         break;
100 100
                     }
101 101
 
102
-                    $phpcsFile->fixer->replaceToken($i, '');
102
+                    $phpcsFile->fixer->replaceToken( $i, '' );
103 103
                 }
104 104
 
105 105
                 $phpcsFile->fixer->endChangeset();
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 
109 109
         // Detect `<?php ? >`.
110 110
         case 'T_CLOSE_TAG':
111
-            $prevNonEmpty = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
111
+            $prevNonEmpty = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
112 112
 
113
-            if ($prevNonEmpty === false
114
-                || ($tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG
115
-                && $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO)
113
+            if ( $prevNonEmpty === false
114
+                || ( $tokens[ $prevNonEmpty ][ 'code' ] !== T_OPEN_TAG
115
+                && $tokens[ $prevNonEmpty ][ 'code' ] !== T_OPEN_TAG_WITH_ECHO )
116 116
             ) {
117 117
                 return;
118 118
             }
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
                 $prevNonEmpty,
123 123
                 'EmptyPHPOpenCloseTagsDetected'
124 124
             );
125
-            if ($fix === true) {
125
+            if ( $fix === true ) {
126 126
                 $phpcsFile->fixer->beginChangeset();
127 127
 
128
-                for ($i = $prevNonEmpty; $i <= $stackPtr; $i++) {
129
-                    $phpcsFile->fixer->replaceToken($i, '');
128
+                for ( $i = $prevNonEmpty; $i <= $stackPtr; $i++ ) {
129
+                    $phpcsFile->fixer->replaceToken( $i, '' );
130 130
                 }
131 131
 
132 132
                 $phpcsFile->fixer->endChangeset();
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_OPEN_TAG];
26
+        return [ T_OPEN_TAG ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,29 +37,29 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return int
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42 42
         $filename = $phpcsFile->getFilename();
43
-        if ($filename === 'STDIN') {
43
+        if ( $filename === 'STDIN' ) {
44 44
             return;
45 45
         }
46 46
 
47
-        $filename          = basename($filename);
48
-        $lowercaseFilename = strtolower($filename);
49
-        if ($filename !== $lowercaseFilename) {
50
-            $data  = [
47
+        $filename          = basename( $filename );
48
+        $lowercaseFilename = strtolower( $filename );
49
+        if ( $filename !== $lowercaseFilename ) {
50
+            $data = [
51 51
                 $filename,
52 52
                 $lowercaseFilename,
53 53
             ];
54 54
             $error = 'Filename "%s" doesn\'t match the expected filename "%s"';
55
-            $phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
56
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
55
+            $phpcsFile->addError( $error, $stackPtr, 'NotFound', $data );
56
+            $phpcsFile->recordMetric( $stackPtr, 'Lowercase filename', 'no' );
57 57
         } else {
58
-            $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
58
+            $phpcsFile->recordMetric( $stackPtr, 'Lowercase filename', 'yes' );
59 59
         }
60 60
 
61 61
         // Ignore the rest of the file.
62
-        return ($phpcsFile->numTokens + 1);
62
+        return ( $phpcsFile->numTokens + 1 );
63 63
 
64 64
     }//end process()
65 65
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@
 block discarded – undo
41 41
      *
42 42
      * @return void
43 43
      */
44
-    public function process(File $phpcsFile, $stackPtr)
44
+    public function process( File $phpcsFile, $stackPtr )
45 45
     {
46
-        $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
47
-        if ($nextClass !== false) {
46
+        $nextClass = $phpcsFile->findNext( $this->register(), ( $stackPtr + 1 ) );
47
+        if ( $nextClass !== false ) {
48 48
             $error = 'Only one object structure is allowed in a file';
49
-            $phpcsFile->addError($error, $nextClass, 'MultipleFound');
49
+            $phpcsFile->addError( $error, $nextClass, 'MultipleFound' );
50 50
         }
51 51
 
52 52
     }//end process()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_CLASS];
26
+        return [ T_CLASS ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42
-        $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
-        if ($nextClass !== false) {
42
+        $nextClass = $phpcsFile->findNext( $this->register(), ( $stackPtr + 1 ) );
43
+        if ( $nextClass !== false ) {
44 44
             $error = 'Only one class is allowed in a file';
45
-            $phpcsFile->addError($error, $nextClass, 'MultipleFound');
45
+            $phpcsFile->addError( $error, $nextClass, 'MultipleFound' );
46 46
         }
47 47
 
48 48
     }//end process()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function register()
38 38
     {
39
-        return [T_INLINE_HTML];
39
+        return [ T_INLINE_HTML ];
40 40
 
41 41
     }//end register()
42 42
 
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
      *
51 51
      * @return void
52 52
      */
53
-    public function process(File $phpcsFile, $stackPtr)
53
+    public function process( File $phpcsFile, $stackPtr )
54 54
     {
55 55
         // Allow a byte-order mark.
56 56
         $tokens = $phpcsFile->getTokens();
57
-        foreach ($this->bomDefinitions as $bomName => $expectedBomHex) {
58
-            $bomByteLength = (strlen($expectedBomHex) / 2);
59
-            $htmlBomHex    = bin2hex(substr($tokens[0]['content'], 0, $bomByteLength));
60
-            if ($htmlBomHex === $expectedBomHex && strlen($tokens[0]['content']) === $bomByteLength) {
57
+        foreach ( $this->bomDefinitions as $bomName => $expectedBomHex ) {
58
+            $bomByteLength = ( strlen( $expectedBomHex ) / 2 );
59
+            $htmlBomHex    = bin2hex( substr( $tokens[ 0 ][ 'content' ], 0, $bomByteLength ) );
60
+            if ( $htmlBomHex === $expectedBomHex && strlen( $tokens[ 0 ][ 'content' ] ) === $bomByteLength ) {
61 61
                 return;
62 62
             }
63 63
         }
64 64
 
65 65
         // Ignore shebang lines.
66 66
         $tokens = $phpcsFile->getTokens();
67
-        if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
67
+        if ( substr( $tokens[ $stackPtr ][ 'content' ], 0, 2 ) === '#!' ) {
68 68
             return;
69 69
         }
70 70
 
71 71
         $error = 'PHP files must only contain PHP code';
72
-        $phpcsFile->addError($error, $stackPtr, 'Found');
72
+        $phpcsFile->addError( $error, $stackPtr, 'Found' );
73 73
 
74 74
         return $phpcsFile->numTokens;
75 75
 
Please login to merge, or discard this patch.
src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public function register()
25 25
     {
26
-        return [T_INTERFACE];
26
+        return [ T_INTERFACE ];
27 27
 
28 28
     }//end register()
29 29
 
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
      *
38 38
      * @return void
39 39
      */
40
-    public function process(File $phpcsFile, $stackPtr)
40
+    public function process( File $phpcsFile, $stackPtr )
41 41
     {
42
-        $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
43
-        if ($nextInterface !== false) {
42
+        $nextInterface = $phpcsFile->findNext( $this->register(), ( $stackPtr + 1 ) );
43
+        if ( $nextInterface !== false ) {
44 44
             $error = 'Only one interface is allowed in a file';
45
-            $phpcsFile->addError($error, $nextInterface, 'MultipleFound');
45
+            $phpcsFile->addError( $error, $nextInterface, 'MultipleFound' );
46 46
         }
47 47
 
48 48
     }//end process()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public function register()
53 53
     {
54
-        return [T_OPEN_TAG];
54
+        return [ T_OPEN_TAG ];
55 55
 
56 56
     }//end register()
57 57
 
@@ -65,19 +65,19 @@  discard block
 block discarded – undo
65 65
      *
66 66
      * @return int
67 67
      */
68
-    public function process(File $phpcsFile, $stackPtr)
68
+    public function process( File $phpcsFile, $stackPtr )
69 69
     {
70 70
         $tokens = $phpcsFile->getTokens();
71
-        for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
72
-            if ($tokens[$i]['column'] === 1) {
73
-                $this->checkLineLength($phpcsFile, $tokens, $i);
71
+        for ( $i = 1; $i < $phpcsFile->numTokens; $i++ ) {
72
+            if ( $tokens[ $i ][ 'column' ] === 1 ) {
73
+                $this->checkLineLength( $phpcsFile, $tokens, $i );
74 74
             }
75 75
         }
76 76
 
77
-        $this->checkLineLength($phpcsFile, $tokens, $i);
77
+        $this->checkLineLength( $phpcsFile, $tokens, $i );
78 78
 
79 79
         // Ignore the rest of the file.
80
-        return ($phpcsFile->numTokens + 1);
80
+        return ( $phpcsFile->numTokens + 1 );
81 81
 
82 82
     }//end process()
83 83
 
@@ -91,51 +91,51 @@  discard block
 block discarded – undo
91 91
      *
92 92
      * @return null|false
93 93
      */
94
-    protected function checkLineLength($phpcsFile, $tokens, $stackPtr)
94
+    protected function checkLineLength( $phpcsFile, $tokens, $stackPtr )
95 95
     {
96 96
         // The passed token is the first on the line.
97 97
         $stackPtr--;
98 98
 
99
-        if ($tokens[$stackPtr]['column'] === 1
100
-            && $tokens[$stackPtr]['length'] === 0
99
+        if ( $tokens[ $stackPtr ][ 'column' ] === 1
100
+            && $tokens[ $stackPtr ][ 'length' ] === 0
101 101
         ) {
102 102
             // Blank line.
103 103
             return;
104 104
         }
105 105
 
106
-        if ($tokens[$stackPtr]['column'] !== 1
107
-            && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar
106
+        if ( $tokens[ $stackPtr ][ 'column' ] !== 1
107
+            && $tokens[ $stackPtr ][ 'content' ] === $phpcsFile->eolChar
108 108
         ) {
109 109
             $stackPtr--;
110 110
         }
111 111
 
112
-        if (isset(Tokens::$phpcsCommentTokens[$tokens[$stackPtr]['code']]) === true) {
113
-            $prevNonWhiteSpace = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
114
-            if ($tokens[$stackPtr]['line'] !== $tokens[$prevNonWhiteSpace]['line']) {
112
+        if ( isset( Tokens::$phpcsCommentTokens[ $tokens[ $stackPtr ][ 'code' ] ] ) === true ) {
113
+            $prevNonWhiteSpace = $phpcsFile->findPrevious( T_WHITESPACE, ( $stackPtr - 1 ), null, true );
114
+            if ( $tokens[ $stackPtr ][ 'line' ] !== $tokens[ $prevNonWhiteSpace ][ 'line' ] ) {
115 115
                 // Ignore PHPCS annotation comments if they are on a line by themselves.
116 116
                 return;
117 117
             }
118 118
 
119
-            unset($prevNonWhiteSpace);
119
+            unset( $prevNonWhiteSpace );
120 120
         }
121 121
 
122
-        $lineLength = ($tokens[$stackPtr]['column'] + $tokens[$stackPtr]['length'] - 1);
122
+        $lineLength = ( $tokens[ $stackPtr ][ 'column' ] + $tokens[ $stackPtr ][ 'length' ] - 1 );
123 123
 
124 124
         // Record metrics for common line length groupings.
125
-        if ($lineLength <= 80) {
126
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
127
-        } else if ($lineLength <= 120) {
128
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
129
-        } else if ($lineLength <= 150) {
130
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
125
+        if ( $lineLength <= 80 ) {
126
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '80 or less' );
127
+        } else if ( $lineLength <= 120 ) {
128
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '81-120' );
129
+        } else if ( $lineLength <= 150 ) {
130
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '121-150' );
131 131
         } else {
132
-            $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
132
+            $phpcsFile->recordMetric( $stackPtr, 'Line length', '151 or more' );
133 133
         }
134 134
 
135
-        if ($tokens[$stackPtr]['code'] === T_COMMENT
136
-            || $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING
135
+        if ( $tokens[ $stackPtr ][ 'code' ] === T_COMMENT
136
+            || $tokens[ $stackPtr ][ 'code' ] === T_DOC_COMMENT_STRING
137 137
         ) {
138
-            if ($this->ignoreComments === true) {
138
+            if ( $this->ignoreComments === true ) {
139 139
                 return;
140 140
             }
141 141
 
@@ -143,25 +143,25 @@  discard block
 block discarded – undo
143 143
             // Some comments contain unbreakable strings like URLs and so it makes sense
144 144
             // to ignore the line length in these cases if the URL would be longer than the max
145 145
             // line length once you indent it to the correct level.
146
-            if ($lineLength > $this->lineLimit) {
147
-                $oldLength = strlen($tokens[$stackPtr]['content']);
148
-                $newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
149
-                $indent    = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
146
+            if ( $lineLength > $this->lineLimit ) {
147
+                $oldLength = strlen( $tokens[ $stackPtr ][ 'content' ] );
148
+                $newLength = strlen( ltrim( $tokens[ $stackPtr ][ 'content' ], "/#\t " ) );
149
+                $indent    = ( ( $tokens[ $stackPtr ][ 'column' ] - 1 ) + ( $oldLength - $newLength ) );
150 150
 
151
-                $nonBreakingLength = $tokens[$stackPtr]['length'];
151
+                $nonBreakingLength = $tokens[ $stackPtr ][ 'length' ];
152 152
 
153
-                $space = strrpos($tokens[$stackPtr]['content'], ' ');
154
-                if ($space !== false) {
155
-                    $nonBreakingLength -= ($space + 1);
153
+                $space = strrpos( $tokens[ $stackPtr ][ 'content' ], ' ' );
154
+                if ( $space !== false ) {
155
+                    $nonBreakingLength -= ( $space + 1 );
156 156
                 }
157 157
 
158
-                if (($nonBreakingLength + $indent) > $this->lineLimit) {
158
+                if ( ( $nonBreakingLength + $indent ) > $this->lineLimit ) {
159 159
                     return;
160 160
                 }
161 161
             }
162 162
         }//end if
163 163
 
164
-        if ($this->absoluteLineLimit > 0
164
+        if ( $this->absoluteLineLimit > 0
165 165
             && $lineLength > $this->absoluteLineLimit
166 166
         ) {
167 167
             $data = [
@@ -170,15 +170,15 @@  discard block
 block discarded – undo
170 170
             ];
171 171
 
172 172
             $error = 'Line exceeds maximum limit of %s characters; contains %s characters';
173
-            $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
174
-        } else if ($lineLength > $this->lineLimit) {
173
+            $phpcsFile->addError( $error, $stackPtr, 'MaxExceeded', $data );
174
+        } else if ( $lineLength > $this->lineLimit ) {
175 175
             $data = [
176 176
                 $this->lineLimit,
177 177
                 $lineLength,
178 178
             ];
179 179
 
180 180
             $warning = 'Line exceeds %s characters; contains %s characters';
181
-            $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data);
181
+            $phpcsFile->addWarning( $warning, $stackPtr, 'TooLong', $data );
182 182
         }
183 183
 
184 184
     }//end checkLineLength()
Please login to merge, or discard this patch.
php_codesniffer/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function register()
39 39
     {
40
-        return [T_INLINE_HTML];
40
+        return [ T_INLINE_HTML ];
41 41
 
42 42
     }//end register()
43 43
 
@@ -51,28 +51,28 @@  discard block
 block discarded – undo
51 51
      *
52 52
      * @return void
53 53
      */
54
-    public function process(File $phpcsFile, $stackPtr)
54
+    public function process( File $phpcsFile, $stackPtr )
55 55
     {
56 56
         // The BOM will be the very first token in the file.
57
-        if ($stackPtr !== 0) {
57
+        if ( $stackPtr !== 0 ) {
58 58
             return;
59 59
         }
60 60
 
61 61
         $tokens = $phpcsFile->getTokens();
62 62
 
63
-        foreach ($this->bomDefinitions as $bomName => $expectedBomHex) {
64
-            $bomByteLength = (strlen($expectedBomHex) / 2);
65
-            $htmlBomHex    = bin2hex(substr($tokens[$stackPtr]['content'], 0, $bomByteLength));
66
-            if ($htmlBomHex === $expectedBomHex) {
67
-                $errorData = [$bomName];
63
+        foreach ( $this->bomDefinitions as $bomName => $expectedBomHex ) {
64
+            $bomByteLength = ( strlen( $expectedBomHex ) / 2 );
65
+            $htmlBomHex    = bin2hex( substr( $tokens[ $stackPtr ][ 'content' ], 0, $bomByteLength ) );
66
+            if ( $htmlBomHex === $expectedBomHex ) {
67
+                $errorData = [ $bomName ];
68 68
                 $error     = 'File contains %s byte order mark, which may corrupt your application';
69
-                $phpcsFile->addError($error, $stackPtr, 'Found', $errorData);
70
-                $phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'yes');
69
+                $phpcsFile->addError( $error, $stackPtr, 'Found', $errorData );
70
+                $phpcsFile->recordMetric( $stackPtr, 'Using byte order mark', 'yes' );
71 71
                 return;
72 72
             }
73 73
         }
74 74
 
75
-        $phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'no');
75
+        $phpcsFile->recordMetric( $stackPtr, 'Using byte order mark', 'no' );
76 76
 
77 77
     }//end process()
78 78
 
Please login to merge, or discard this patch.