Skip to content

Commit 001ca17

Browse files
committed
Update
1 parent ede9fee commit 001ca17

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Fixer/TypedClassConstantFixer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,6 @@ private static function isOfTypeBasedOnKinds(
180180
array $instantWinners
181181
): bool {
182182
foreach ($expressionTokenKinds as $index => $expressionTokenKind) {
183-
if ($expressionTokenKind === '?') {
184-
return false;
185-
}
186183
if (\in_array($expressionTokenKind, $instantWinners, true)) {
187184
return true;
188185
}

tests/Fixer/TypedClassConstantFixerTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,19 @@ class Bar {
240240
'<?php class Foo { public const BAR = 10 * FLOAT_OR_INTEGER + 3; }',
241241
];
242242

243-
yield 'constant that can be of different types' => [
244-
'<?php class Foo { public const mixed BAR = SHOULD_BE_INT ? 1 : ["one"]; }',
245-
'<?php class Foo { public const BAR = SHOULD_BE_INT ? 1 : ["one"]; }',
243+
yield 'constants that can be of different types' => [
244+
<<<'PHP'
245+
<?php class Foo {
246+
public const mixed BAR = SHOULD_BE_INT ? 1 : ["one"];
247+
public const mixed BAZ = NAME === 'A' . 'b' ? 1 : ["one"];
248+
}
249+
PHP,
250+
<<<'PHP'
251+
<?php class Foo {
252+
public const BAR = SHOULD_BE_INT ? 1 : ["one"];
253+
public const BAZ = NAME === 'A' . 'b' ? 1 : ["one"];
254+
}
255+
PHP,
246256
];
247257

248258
yield 'constant that can be of different types - more complex case' => [

0 commit comments

Comments
 (0)