14
14
use PHP_CodeSniffer \Exceptions \TokenizerException ;
15
15
use PHP_CodeSniffer \Fixer ;
16
16
use PHP_CodeSniffer \Ruleset ;
17
- use PHP_CodeSniffer \Util ;
17
+ use PHP_CodeSniffer \Util \Common ;
18
+ use PHP_CodeSniffer \Util \Tokens ;
18
19
19
20
class File
20
21
{
@@ -276,7 +277,7 @@ public function setContent($content)
276
277
$ this ->tokens = [];
277
278
278
279
try {
279
- $ this ->eolChar = Util \ Common::detectLineEndings ($ content );
280
+ $ this ->eolChar = Common::detectLineEndings ($ content );
280
281
} catch (RuntimeException $ e ) {
281
282
$ this ->addWarningOnLine ($ e ->getMessage (), 1 , 'Internal.DetectLineEndings ' );
282
283
return ;
@@ -430,7 +431,7 @@ public function process()
430
431
431
432
if (PHP_CODESNIFFER_VERBOSITY > 2 ) {
432
433
$ type = $ token ['type ' ];
433
- $ content = Util \ Common::prepareForOutput ($ token ['content ' ]);
434
+ $ content = Common::prepareForOutput ($ token ['content ' ]);
434
435
echo "\t\tProcess token $ stackPtr: $ type => $ content " .PHP_EOL ;
435
436
}
436
437
@@ -872,7 +873,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s
872
873
$ parts = explode ('. ' , $ code );
873
874
if ($ parts [0 ] === 'Internal ' ) {
874
875
// An internal message.
875
- $ listenerCode = Util \ Common::getSniffCode ($ this ->activeListener );
876
+ $ listenerCode = Common::getSniffCode ($ this ->activeListener );
876
877
$ sniffCode = $ code ;
877
878
$ checkCodes = [$ sniffCode ];
878
879
} else {
@@ -881,7 +882,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s
881
882
$ sniffCode = $ code ;
882
883
$ listenerCode = substr ($ sniffCode , 0 , strrpos ($ sniffCode , '. ' ));
883
884
} else {
884
- $ listenerCode = Util \ Common::getSniffCode ($ this ->activeListener );
885
+ $ listenerCode = Common::getSniffCode ($ this ->activeListener );
885
886
$ sniffCode = $ listenerCode .'. ' .$ code ;
886
887
$ parts = explode ('. ' , $ sniffCode );
887
888
}
@@ -1615,7 +1616,7 @@ public function getMethodParameters($stackPtr)
1615
1616
$ paramCount ++;
1616
1617
break ;
1617
1618
case T_EQUAL :
1618
- $ defaultStart = $ this ->findNext (Util \ Tokens::$ emptyTokens , ($ i + 1 ), null , true );
1619
+ $ defaultStart = $ this ->findNext (Tokens::$ emptyTokens , ($ i + 1 ), null , true );
1619
1620
$ equalToken = $ i ;
1620
1621
break ;
1621
1622
}//end switch
@@ -1885,7 +1886,7 @@ public function getMemberProperties($stackPtr)
1885
1886
T_READONLY => T_READONLY ,
1886
1887
];
1887
1888
1888
- $ valid += Util \ Tokens::$ emptyTokens ;
1889
+ $ valid += Tokens::$ emptyTokens ;
1889
1890
1890
1891
$ scope = 'public ' ;
1891
1892
$ scopeSpecified = false ;
@@ -2073,7 +2074,7 @@ public function isReference($stackPtr)
2073
2074
}
2074
2075
2075
2076
$ tokenBefore = $ this ->findPrevious (
2076
- Util \ Tokens::$ emptyTokens ,
2077
+ Tokens::$ emptyTokens ,
2077
2078
($ stackPtr - 1 ),
2078
2079
null ,
2079
2080
true
@@ -2097,14 +2098,14 @@ public function isReference($stackPtr)
2097
2098
return true ;
2098
2099
}
2099
2100
2100
- if (isset (Util \ Tokens::$ assignmentTokens [$ this ->tokens [$ tokenBefore ]['code ' ]]) === true ) {
2101
+ if (isset (Tokens::$ assignmentTokens [$ this ->tokens [$ tokenBefore ]['code ' ]]) === true ) {
2101
2102
// This is directly after an assignment. It's a reference. Even if
2102
2103
// it is part of an operation, the other tests will handle it.
2103
2104
return true ;
2104
2105
}
2105
2106
2106
2107
$ tokenAfter = $ this ->findNext (
2107
- Util \ Tokens::$ emptyTokens ,
2108
+ Tokens::$ emptyTokens ,
2108
2109
($ stackPtr + 1 ),
2109
2110
null ,
2110
2111
true
@@ -2155,7 +2156,7 @@ public function isReference($stackPtr)
2155
2156
if ($ this ->tokens [$ tokenAfter ]['code ' ] === T_VARIABLE ) {
2156
2157
return true ;
2157
2158
} else {
2158
- $ skip = Util \ Tokens::$ emptyTokens ;
2159
+ $ skip = Tokens::$ emptyTokens ;
2159
2160
$ skip [] = T_NS_SEPARATOR ;
2160
2161
$ skip [] = T_SELF ;
2161
2162
$ skip [] = T_PARENT ;
@@ -2382,7 +2383,7 @@ public function findNext(
2382
2383
*/
2383
2384
public function findStartOfStatement ($ start , $ ignore =null )
2384
2385
{
2385
- $ startTokens = Util \ Tokens::$ blockOpeners ;
2386
+ $ startTokens = Tokens::$ blockOpeners ;
2386
2387
$ startTokens [T_OPEN_SHORT_ARRAY ] = true ;
2387
2388
$ startTokens [T_OPEN_TAG ] = true ;
2388
2389
$ startTokens [T_OPEN_TAG_WITH_ECHO ] = true ;
@@ -2436,7 +2437,7 @@ public function findStartOfStatement($start, $ignore=null)
2436
2437
2437
2438
if ($ prevMatch <= $ this ->tokens [$ matchExpression ]['scope_opener ' ]) {
2438
2439
// We're before the arrow in the first case.
2439
- $ next = $ this ->findNext (Util \ Tokens::$ emptyTokens , ($ this ->tokens [$ matchExpression ]['scope_opener ' ] + 1 ), null , true );
2440
+ $ next = $ this ->findNext (Tokens::$ emptyTokens , ($ this ->tokens [$ matchExpression ]['scope_opener ' ] + 1 ), null , true );
2440
2441
if ($ next === false ) {
2441
2442
return $ start ;
2442
2443
}
@@ -2449,12 +2450,12 @@ public function findStartOfStatement($start, $ignore=null)
2449
2450
$ prevMatchArrow = $ this ->findPrevious (T_MATCH_ARROW , ($ prevMatch - 1 ), $ this ->tokens [$ matchExpression ]['scope_opener ' ]);
2450
2451
if ($ prevMatchArrow === false ) {
2451
2452
// We're before the arrow in the first case.
2452
- $ next = $ this ->findNext (Util \ Tokens::$ emptyTokens , ($ this ->tokens [$ matchExpression ]['scope_opener ' ] + 1 ), null , true );
2453
+ $ next = $ this ->findNext (Tokens::$ emptyTokens , ($ this ->tokens [$ matchExpression ]['scope_opener ' ] + 1 ), null , true );
2453
2454
return $ next ;
2454
2455
}
2455
2456
2456
2457
$ end = $ this ->findEndOfStatement ($ prevMatchArrow );
2457
- $ next = $ this ->findNext (Util \ Tokens::$ emptyTokens , ($ end + 1 ), null , true );
2458
+ $ next = $ this ->findNext (Tokens::$ emptyTokens , ($ end + 1 ), null , true );
2458
2459
return $ next ;
2459
2460
}
2460
2461
}//end if
@@ -2515,7 +2516,7 @@ public function findStartOfStatement($start, $ignore=null)
2515
2516
}
2516
2517
}//end if
2517
2518
2518
- if (isset (Util \ Tokens::$ emptyTokens [$ this ->tokens [$ i ]['code ' ]]) === false ) {
2519
+ if (isset (Tokens::$ emptyTokens [$ this ->tokens [$ i ]['code ' ]]) === false ) {
2519
2520
$ lastNotEmpty = $ i ;
2520
2521
}
2521
2522
}//end for
@@ -2610,7 +2611,7 @@ public function findEndOfStatement($start, $ignore=null)
2610
2611
continue ;
2611
2612
}
2612
2613
2613
- if ($ i === $ start && isset (Util \ Tokens::$ scopeOpeners [$ this ->tokens [$ i ]['code ' ]]) === true ) {
2614
+ if ($ i === $ start && isset (Tokens::$ scopeOpeners [$ this ->tokens [$ i ]['code ' ]]) === true ) {
2614
2615
return $ this ->tokens [$ i ]['scope_closer ' ];
2615
2616
}
2616
2617
@@ -2630,7 +2631,7 @@ public function findEndOfStatement($start, $ignore=null)
2630
2631
}
2631
2632
}//end if
2632
2633
2633
- if (isset (Util \ Tokens::$ emptyTokens [$ this ->tokens [$ i ]['code ' ]]) === false ) {
2634
+ if (isset (Tokens::$ emptyTokens [$ this ->tokens [$ i ]['code ' ]]) === false ) {
2634
2635
$ lastNotEmpty = $ i ;
2635
2636
}
2636
2637
}//end for
0 commit comments