From 74fbe594010f3ae904e05c384558d2098ec81052 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Tue, 3 Feb 2026 07:47:35 +0100 Subject: [PATCH] Run PHP-CS-Fixer (no_useless_else & static_lambda) --- src/Polygon.php | 6 +++--- src/Polyline.php | 2 +- src/Renderer/AbstractRenderer.php | 2 +- src/Renderer/NullRenderer.php | 2 +- src/Test/RendererTestCase.php | 3 +-- src/UXMapBundle.php | 2 +- tests/IconTest.php | 4 ++-- tests/Kernel/FrameworkAppKernel.php | 2 +- tests/Kernel/TwigAppKernel.php | 2 +- tests/Kernel/TwigComponentKernel.php | 2 +- 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Polygon.php b/src/Polygon.php index 068be69..8e4a7b6 100644 --- a/src/Polygon.php +++ b/src/Polygon.php @@ -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']); diff --git a/src/Polyline.php b/src/Polyline.php index 33ba037..04bcd30 100644 --- a/src/Polyline.php +++ b/src/Polyline.php @@ -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, diff --git a/src/Renderer/AbstractRenderer.php b/src/Renderer/AbstractRenderer.php index b56a534..5ed5a3a 100644 --- a/src/Renderer/AbstractRenderer.php +++ b/src/Renderer/AbstractRenderer.php @@ -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(); diff --git a/src/Renderer/NullRenderer.php b/src/Renderer/NullRenderer.php index 772a3d7..6c1454b 100644 --- a/src/Renderer/NullRenderer.php +++ b/src/Renderer/NullRenderer.php @@ -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); diff --git a/src/Test/RendererTestCase.php b/src/Test/RendererTestCase.php index e9c5009..789110d 100644 --- a/src/Test/RendererTestCase.php +++ b/src/Test/RendererTestCase.php @@ -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 diff --git a/src/UXMapBundle.php b/src/UXMapBundle.php index 2f4bb35..f97691e 100644 --- a/src/UXMapBundle.php +++ b/src/UXMapBundle.php @@ -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'); } diff --git a/tests/IconTest.php b/tests/IconTest.php index 68c42cf..50ae862 100644 --- a/tests/IconTest.php +++ b/tests/IconTest.php @@ -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'] ); diff --git a/tests/Kernel/FrameworkAppKernel.php b/tests/Kernel/FrameworkAppKernel.php index ed17715..cc8dbbd 100644 --- a/tests/Kernel/FrameworkAppKernel.php +++ b/tests/Kernel/FrameworkAppKernel.php @@ -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, diff --git a/tests/Kernel/TwigAppKernel.php b/tests/Kernel/TwigAppKernel.php index 531e8a9..f5dbf5b 100644 --- a/tests/Kernel/TwigAppKernel.php +++ b/tests/Kernel/TwigAppKernel.php @@ -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, diff --git a/tests/Kernel/TwigComponentKernel.php b/tests/Kernel/TwigComponentKernel.php index 1cf8d5e..c7a047d 100644 --- a/tests/Kernel/TwigComponentKernel.php +++ b/tests/Kernel/TwigComponentKernel.php @@ -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,