Skip to content

Commit 8866323

Browse files
committed
replace match with switch
1 parent 3d026d4 commit 8866323

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Rules/Functions/PrintfHelper.php

+16-6
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,24 @@ public function getPrintfPlaceholderAcceptingTypes(string $format): array
6262
$typeName,
6363
static function (Type $t) use ($types): bool {
6464
foreach ($types as $acceptingType) {
65-
$subresult = match ($acceptingType) {
66-
'strict-int' => (new IntegerType())->accepts($t, true)->yes(),
67-
'int' => ! $t->toInteger() instanceof ErrorType,
68-
'float' => ! $t->toFloat() instanceof ErrorType,
65+
switch ($acceptingType) {
66+
case 'strict-int':
67+
$subresult = (new IntegerType())->accepts($t, true)->yes();
68+
break;
69+
case 'int':
70+
$subresult = ! $t->toInteger() instanceof ErrorType;
71+
break;
72+
case 'float':
73+
$subresult = ! $t->toFloat() instanceof ErrorType;
74+
break;
6975
// The function signature already limits the parameters to stringable types, so there's
7076
// no point in checking string again here.
71-
'string', 'mixed' => true,
72-
};
77+
case 'string':
78+
case 'mixed':
79+
default:
80+
$subresult = true;
81+
break;
82+
}
7383

7484
if (!$subresult) {
7585
return false;

0 commit comments

Comments
 (0)