File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -2139,15 +2139,25 @@ protected function tokenize($string)
2139
2139
continue ;
2140
2140
}
2141
2141
2142
- if (($ tokenType !== T_CALLABLE
2143
- && isset ($ lastRelevantNonEmpty ) === false )
2144
- || ($ lastRelevantNonEmpty === T_ARRAY
2145
- && $ tokenType === '( ' )
2146
- || (isset (Tokens::NAME_TOKENS [$ lastRelevantNonEmpty ]) === true
2147
- && ($ tokenType === T_DOUBLE_COLON
2148
- || $ tokenType === '( '
2149
- || $ tokenType === ': ' ))
2150
- ) {
2142
+ $ isInlineThen = false ;
2143
+ if (isset ($ lastRelevantNonEmpty ) === false && $ tokenType !== T_CALLABLE ) {
2144
+ // Can be anything, but is definitely not a type declaration.
2145
+ $ isInlineThen = true ;
2146
+ } else if (isset ($ lastRelevantNonEmpty ) === true ) {
2147
+ if ($ lastRelevantNonEmpty === T_ARRAY && $ tokenType === '( ' ) {
2148
+ // Array declaration in ternary then.
2149
+ $ isInlineThen = true ;
2150
+ } else if (isset (Tokens::NAME_TOKENS [$ lastRelevantNonEmpty ]) === true
2151
+ && ($ tokenType === T_DOUBLE_COLON
2152
+ || $ tokenType === '( '
2153
+ || $ tokenType === ': ' )
2154
+ ) {
2155
+ // Constant access, function call, static class member access in ternary then.
2156
+ $ isInlineThen = true ;
2157
+ }
2158
+ }
2159
+
2160
+ if ($ isInlineThen === true ) {
2151
2161
if (PHP_CODESNIFFER_VERBOSITY > 1 ) {
2152
2162
StatusWriter::write ("* token $ stackPtr changed from ? to T_INLINE_THEN " , 2 );
2153
2163
}
You can’t perform that action at this time.
0 commit comments