|
21 | 21 |
|
22 | 22 | final class TypedClassConstantFixer extends AbstractFixer |
23 | 23 | { |
| 24 | + private const INTEGER_KINDS = [\T_LNUMBER, '+', '-', '*', '(', ')', \T_SL, \T_SR]; |
| 25 | + private const FLOAT_KINDS = [\T_DNUMBER, ...self::INTEGER_KINDS, '/']; |
| 26 | + private const STRING_KINDS = [\T_CONSTANT_ENCAPSED_STRING, '.', \T_LNUMBER, \T_DNUMBER]; |
| 27 | + |
24 | 28 | public function getDefinition(): FixerDefinitionInterface |
25 | 29 | { |
26 | 30 | return new FixerDefinition( |
@@ -140,15 +144,15 @@ private static function getTypeOfExpression(Tokens $tokens, int $index): string |
140 | 144 | */ |
141 | 145 | private static function getTypeOfExpressionForTokenKinds(array $tokenKinds): string |
142 | 146 | { |
143 | | - if (self::hasExclusivelyKinds($tokenKinds, [\T_LNUMBER, '+', '-', '*', '(', ')'])) { |
| 147 | + if (self::hasExclusivelyKinds($tokenKinds, self::INTEGER_KINDS)) { |
144 | 148 | return 'int'; |
145 | 149 | } |
146 | 150 |
|
147 | | - if (self::hasExclusivelyKinds($tokenKinds, [\T_DNUMBER, \T_LNUMBER, '+', '-', '*', '/', '(', ')'])) { |
| 151 | + if (self::hasExclusivelyKinds($tokenKinds, self::FLOAT_KINDS)) { |
148 | 152 | return 'float'; |
149 | 153 | } |
150 | 154 |
|
151 | | - if (self::hasExclusivelyKinds($tokenKinds, [\T_CONSTANT_ENCAPSED_STRING, '.', \T_LNUMBER, \T_DNUMBER])) { |
| 155 | + if (self::hasExclusivelyKinds($tokenKinds, self::STRING_KINDS)) { |
152 | 156 | return 'string'; |
153 | 157 | } |
154 | 158 |
|
|
0 commit comments