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 4e07cf3b2a
commit 74fbe59401
10 changed files with 13 additions and 14 deletions

View File

@@ -53,8 +53,8 @@ final class Polygon implements Element
{
return [
'points' => current($this->points) instanceof Point
? array_map(fn (Point $point) => $point->toArray(), $this->points)
: array_map(fn (array $path) => array_map(fn (Point $point) => $point->toArray(), $path), $this->points),
? array_map(static fn (Point $point) => $point->toArray(), $this->points)
: array_map(static fn (array $path) => array_map(static fn (Point $point) => $point->toArray(), $path), $this->points),
'title' => $this->title,
'infoWindow' => $this->infoWindow?->toArray(),
'extra' => $this->extra,
@@ -81,7 +81,7 @@ final class Polygon implements Element
$polygon['points'] = isset($polygon['points'][0]['lat'], $polygon['points'][0]['lng'])
? array_map(Point::fromArray(...), $polygon['points'])
: array_map(fn (array $points) => array_map(Point::fromArray(...), $points), $polygon['points']);
: array_map(static fn (array $points) => array_map(Point::fromArray(...), $points), $polygon['points']);
if (isset($polygon['infoWindow'])) {
$polygon['infoWindow'] = InfoWindow::fromArray($polygon['infoWindow']);

View File

@@ -51,7 +51,7 @@ final class Polyline implements Element
public function toArray(): array
{
return [
'points' => array_map(fn (Point $point) => $point->toArray(), $this->points),
'points' => array_map(static fn (Point $point) => $point->toArray(), $this->points),
'title' => $this->title,
'infoWindow' => $this->infoWindow?->toArray(),
'extra' => $this->extra,

View File

@@ -87,7 +87,7 @@ abstract class AbstractRenderer implements RendererInterface
private function getMapAttributes(Map $map): array
{
$computeId = fn (array $array) => hash('xxh3', json_encode($array, \JSON_THROW_ON_ERROR));
$computeId = static fn (array $array) => hash('xxh3', json_encode($array, \JSON_THROW_ON_ERROR));
$attrs = $map->toArray();

View File

@@ -30,7 +30,7 @@ final class NullRenderer implements RendererInterface
{
$message = 'You must install at least one bridge package to use the Symfony UX Map component.';
if ($this->availableBridges) {
$message .= \PHP_EOL.'Try running '.implode(' or ', array_map(fn ($name) => \sprintf('"composer require %s"', $name), $this->availableBridges)).'.';
$message .= \PHP_EOL.'Try running '.implode(' or ', array_map(static fn ($name) => \sprintf('"composer require %s"', $name), $this->availableBridges)).'.';
}
throw new LogicException($message);

View File

@@ -78,9 +78,8 @@ abstract class RendererTestCase extends TestCase
throw new \LogicException(\sprintf('Failed to parse the rendered HTML for property "%s".', $property));
} elseif (0 === $matchesResult) {
throw new \LogicException(\sprintf('It looks like the property "%s" is missing from "Map::toArray()" normalization.', $property));
} else {
$htmlAttributes[$property] = $matches[1];
}
$htmlAttributes[$property] = $matches[1];
}
// Check that each property has a computed "@id" attribute

View File

@@ -69,7 +69,7 @@ final class UXMapBundle extends AbstractBundle
if (str_starts_with($config['renderer'], 'null://')) {
$container->services()
->set('ux_map.renderer_factory.null', NullRendererFactory::class)
->arg(0, array_map(fn ($name) => 'symfony/ux-'.$name.'-map', array_keys(self::$bridges)))
->arg(0, array_map(static fn ($name) => 'symfony/ux-'.$name.'-map', array_keys(self::$bridges)))
->tag('ux_map.renderer_factory');
}

View File

@@ -69,8 +69,8 @@ class IconTest extends TestCase
$refl = new \ReflectionClass(SvgIcon::class);
$customizationMethods = array_diff(
array_map(
fn (\ReflectionMethod $method) => $method->name,
array_filter($refl->getMethods(\ReflectionMethod::IS_PUBLIC), fn (\ReflectionMethod $method) => SvgIcon::class === $method->getDeclaringClass()->getName())
static fn (\ReflectionMethod $method) => $method->name,
array_filter($refl->getMethods(\ReflectionMethod::IS_PUBLIC), static fn (\ReflectionMethod $method) => SvgIcon::class === $method->getDeclaringClass()->getName())
),
['toArray', 'fromArray']
);

View File

@@ -34,7 +34,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

@@ -35,7 +35,7 @@ class TwigAppKernel 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

@@ -40,7 +40,7 @@ class TwigComponentKernel 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,