Run PHP-CS-Fixer (no_useless_else & static_lambda)

This commit is contained in:
Hugo Alliaume
2026-02-03 07:47:35 +01:00
parent 32f621ab10
commit 2254e170c4
6 changed files with 68 additions and 69 deletions

View File

@@ -52,14 +52,14 @@ class Configuration implements ConfigurationInterface
->canBeUnset()
->beforeNormalization()
->ifString()
->then(fn ($v) => ['elements' => [$v]])
->then(static fn ($v) => ['elements' => [$v]])
->end()
->beforeNormalization()
->ifTrue(function ($v) { return \is_array($v) && is_numeric(key($v)); })
->then(function ($v) { return ['elements' => $v]; })
->ifTrue(static function ($v) { return \is_array($v) && is_numeric(key($v)); })
->then(static function ($v) { return ['elements' => $v]; })
->end()
->validate()
->always(function ($v) {
->always(static function ($v) {
$isExclusive = null;
$elements = [];
if (isset($v['type'])) {
@@ -94,7 +94,7 @@ class Configuration implements ConfigurationInterface
->scalarPrototype()->end()
->beforeNormalization()
->ifString()
->then(fn ($v) => [$v])
->then(static fn ($v) => [$v])
->end()
->end()
->end()

View File

@@ -82,12 +82,12 @@ final class IntlMessageParser
) {
if ($expectingCloseTag) {
break;
} else {
return $this->error(
ErrorKind::UNMATCHED_CLOSING_TAG,
new Location(clone $this->position, clone $this->position)
);
}
return $this->error(
ErrorKind::UNMATCHED_CLOSING_TAG,
new Location(clone $this->position, clone $this->position)
);
} elseif (
60 === $char /* `<` */
&& !$this->ignoreTag
@@ -267,11 +267,11 @@ final class IntlMessageParser
|| (125 === $ch /* `}` */ && $nestingLevel > 0)
) {
return null;
} else {
$this->bump();
return Utils::fromCodePoint($ch);
}
$this->bump();
return Utils::fromCodePoint($ch);
}
/**
@@ -473,32 +473,32 @@ final class IntlMessageParser
],
'err' => null,
];
} else {
if (0 === s($skeleton)->length()) {
return $this->error(ErrorKind::EXPECT_DATE_TIME_SKELETON, $location);
}
$dateTimePattern = $skeleton;
$style = [
'type' => SkeletonType::DATE_TIME,
'pattern' => $dateTimePattern,
'location' => $styleAndLocation['styleLocation'],
'parsedOptions' => [],
];
$type = 'date' === $argType ? Type::DATE : Type::TIME;
return [
'val' => [
'type' => $type,
'value' => $value,
'location' => $location,
'style' => $style,
],
'err' => null,
];
}
if (0 === s($skeleton)->length()) {
return $this->error(ErrorKind::EXPECT_DATE_TIME_SKELETON, $location);
}
$dateTimePattern = $skeleton;
$style = [
'type' => SkeletonType::DATE_TIME,
'pattern' => $dateTimePattern,
'location' => $styleAndLocation['styleLocation'],
'parsedOptions' => [],
];
$type = 'date' === $argType ? Type::DATE : Type::TIME;
return [
'val' => [
'type' => $type,
'value' => $value,
'location' => $location,
'style' => $style,
],
'err' => null,
];
}
// Regular style or no style.
@@ -593,21 +593,20 @@ final class IntlMessageParser
],
'err' => null,
];
} else {
return [
'val' => [
'type' => Type::PLURAL,
'value' => $value,
'offset' => $pluralOffset,
'options' => $optionsResult['val'],
'pluralType' => 'plural' === $argType ? 'cardinal' : 'ordinal',
'location' => $location,
],
'err' => null,
];
}
// no break
return [
'val' => [
'type' => Type::PLURAL,
'value' => $value,
'offset' => $pluralOffset,
'options' => $optionsResult['val'],
'pluralType' => 'plural' === $argType ? 'cardinal' : 'ordinal',
'location' => $location,
],
'err' => null,
];
default:
return $this->error(
ErrorKind::INVALID_ARGUMENT_TYPE,
@@ -962,11 +961,11 @@ final class IntlMessageParser
$this->bumpTo($index);
return true;
} else {
$this->bumpTo($this->messageLength);
return false;
}
$this->bumpTo($this->messageLength);
return false;
}
/**

View File

@@ -38,7 +38,7 @@ final class TypeScriptMessageParametersPrinter
$value = implode(
'|',
array_map(
fn (string $val) => 'other' === $val ? 'string' : "'".$val."'",
static fn (string $val) => 'other' === $val ? 'string' : "'".$val."'",
$parameter['values']
)
);

View File

@@ -201,7 +201,7 @@ class TranslationsDumper
return \sprintf(
'Message<{ %s }, %s>',
implode(', ', $typeScriptParametersType),
implode('|', array_map(fn (string $locale) => "'$locale'", array_unique($locales))),
implode('|', array_map(static fn (string $locale) => "'$locale'", array_unique($locales))),
);
}
@@ -229,7 +229,7 @@ class TranslationsDumper
}
// Filter empty patterns and deduplicate
$patterns = array_reduce($patterns, function (array $carry, string $pattern) {
$patterns = array_reduce($patterns, static function (array $carry, string $pattern) {
$trimmed = trim($pattern);
if ('' !== $trimmed && !\in_array($trimmed, $carry, true)) {
$carry[] = $trimmed;

View File

@@ -33,7 +33,7 @@ class FrameworkAppKernel extends Kernel
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(function (ContainerBuilder $container) {
$loader->load(static function (ContainerBuilder $container) {
$container->loadFromExtension('framework', [
'secret' => '$ecret',
'test' => true,

View File

@@ -211,7 +211,7 @@ class TranslationsDumperTest extends TestCase
{
yield 'included patterns' => [
['symfony.*', 'notification.*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should include keys matching patterns
$test->assertStringContainsString('symfony.great', $content);
$test->assertStringContainsString('symfony.what', $content);
@@ -226,7 +226,7 @@ class TranslationsDumperTest extends TestCase
yield 'excluded patterns' => [
['!apples.*', '!what.*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should exclude keys matching exclusion patterns
$test->assertStringNotContainsString('apples.count', $content);
$test->assertStringNotContainsString('what.count', $content);
@@ -240,7 +240,7 @@ class TranslationsDumperTest extends TestCase
yield 'mixed patterns' => [
['symfony.*', 'notification.*', '!*.what*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should include symfony.* but exclude *.what*
$test->assertStringContainsString('symfony.great', $content);
$test->assertStringNotContainsString('symfony.what', $content);
@@ -255,7 +255,7 @@ class TranslationsDumperTest extends TestCase
yield 'wildcard patterns' => [
['*.count.*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should include keys matching *.count.*
$test->assertStringContainsString('apples.count.0', $content);
$test->assertStringContainsString('what.count.1', $content);
@@ -268,7 +268,7 @@ class TranslationsDumperTest extends TestCase
yield 'empty pattern array' => [
[],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should include all keys when pattern array is empty
$test->assertStringContainsString('symfony.great', $content);
$test->assertStringContainsString('symfony.what', $content);
@@ -281,7 +281,7 @@ class TranslationsDumperTest extends TestCase
yield 'empty string patterns' => [
['', 'symfony.*', ''],
function (self $test, string $content) {
static function (self $test, string $content) {
// Empty strings should be filtered out, only 'symfony.*' should apply
$test->assertStringContainsString('symfony.great', $content);
$test->assertStringContainsString('symfony.what', $content);
@@ -294,7 +294,7 @@ class TranslationsDumperTest extends TestCase
yield 'malformed exclusion pattern' => [
['!'],
function (self $test, string $content) {
static function (self $test, string $content) {
// A single '!' should be treated as invalid and include all keys
$test->assertStringContainsString('symfony.great', $content);
$test->assertStringContainsString('notification.comment_created', $content);
@@ -304,7 +304,7 @@ class TranslationsDumperTest extends TestCase
yield 'patterns with special regex characters in key names' => [
['animal.*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should match keys with dashes and underscores
$test->assertStringContainsString('animal.dog-cat', $content);
$test->assertStringContainsString('animal.dog_cat', $content);
@@ -316,7 +316,7 @@ class TranslationsDumperTest extends TestCase
yield 'pattern matching keys starting with numeric' => [
['0starts.*'],
function (self $test, string $content) {
static function (self $test, string $content) {
// Should match keys starting with numeric characters
$test->assertStringContainsString('0starts.with.numeric', $content);