From 039764d75c9c73a0022534676f317c9ffb9bdaac Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 18 Oct 2024 13:50:20 +0200 Subject: [PATCH] 5.1.1 (#1216) --- CHANGELOG.md | 4 ++++ src/Block/BlockContext.php | 6 +++--- src/Block/BlockContextManager.php | 4 ++-- src/Block/BlockLoaderChain.php | 4 ++-- src/Block/BlockRenderer.php | 6 +++--- src/Block/BlockServiceManager.php | 8 ++++---- src/Block/Loader/ServiceLoader.php | 6 +++--- src/Block/Service/MenuBlockService.php | 2 +- src/Command/DebugBlocksCommand.php | 8 ++++---- .../Compiler/TweakCompilerPass.php | 2 +- src/Exception/Renderer/InlineDebugRenderer.php | 2 +- src/Exception/Renderer/InlineRenderer.php | 2 +- src/Exception/Strategy/StrategyManager.php | 10 +++++----- src/Form/Type/ServiceListType.php | 4 ++-- src/Meta/Metadata.php | 2 +- src/Model/BaseBlock.php | 2 +- src/Profiler/DataCollector/BlockDataCollector.php | 2 +- src/Templating/Helper/BlockHelper.php | 14 +++++++------- 18 files changed, 46 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48a9184d..e4f45ba9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [5.1.1](https://github.com/sonata-project/SonataBlockBundle/compare/5.1.0...5.1.1) - 2024-10-18 +### Fixed +- [[#1212](https://github.com/sonata-project/SonataBlockBundle/pull/1212)] Symfony 7.1 deprecation about `Symfony\Component\HttpKernel\DependencyInjection\Extension` usage ([@VincentLanglet](https://github.com/VincentLanglet)) + ## [5.1.0](https://github.com/sonata-project/SonataBlockBundle/compare/5.0.1...5.1.0) - 2023-11-23 ### Added - [[#1193](https://github.com/sonata-project/SonataBlockBundle/pull/1193)] Symfony 7 support ([@VincentLanglet](https://github.com/VincentLanglet)) diff --git a/src/Block/BlockContext.php b/src/Block/BlockContext.php index 806b18fb..e96e137f 100644 --- a/src/Block/BlockContext.php +++ b/src/Block/BlockContext.php @@ -22,7 +22,7 @@ final class BlockContext implements BlockContextInterface */ public function __construct( private BlockInterface $block, - private array $settings = [] + private array $settings = [], ) { } @@ -39,7 +39,7 @@ public function getSettings(): array public function getSetting(string $name): mixed { if (!\array_key_exists($name, $this->settings)) { - throw new \RuntimeException(sprintf('Unable to find the option `%s` (%s) - define the option in the related BlockServiceInterface', $name, $this->block->getType() ?? '')); + throw new \RuntimeException(\sprintf('Unable to find the option `%s` (%s) - define the option in the related BlockServiceInterface', $name, $this->block->getType() ?? '')); } return $this->settings[$name]; @@ -48,7 +48,7 @@ public function getSetting(string $name): mixed public function setSetting(string $name, mixed $value): BlockContextInterface { if (!\array_key_exists($name, $this->settings)) { - throw new \RuntimeException(sprintf('It\'s not possible add non existing setting `%s`.', $name)); + throw new \RuntimeException(\sprintf('It\'s not possible add non existing setting `%s`.', $name)); } $this->settings[$name] = $value; diff --git a/src/Block/BlockContextManager.php b/src/Block/BlockContextManager.php index 1a311978..7fcf0ec2 100644 --- a/src/Block/BlockContextManager.php +++ b/src/Block/BlockContextManager.php @@ -39,7 +39,7 @@ final class BlockContextManager implements BlockContextManagerInterface public function __construct( private BlockLoaderInterface $blockLoader, private BlockServiceManagerInterface $blockService, - ?LoggerInterface $logger = null + ?LoggerInterface $logger = null, ) { $this->logger = $logger ?? new NullLogger(); } @@ -87,7 +87,7 @@ public function get($meta, array $settings = []): BlockContextInterface try { $settings = $this->resolve($block, array_merge($block->getSettings(), $settings)); } catch (ExceptionInterface $e) { - $this->logger->error(sprintf( + $this->logger->error(\sprintf( '[cms::blockContext] block.id=%s - error while resolving options - %s', $block->getId() ?? '', $e->getMessage() diff --git a/src/Block/BlockLoaderChain.php b/src/Block/BlockLoaderChain.php index b6f133b9..e45bc813 100644 --- a/src/Block/BlockLoaderChain.php +++ b/src/Block/BlockLoaderChain.php @@ -44,7 +44,7 @@ public function exists(string $type): bool public function load($configuration): BlockInterface { if (!\is_string($configuration) && !\is_array($configuration)) { - throw new \TypeError(sprintf( + throw new \TypeError(\sprintf( 'Argument 1 passed to %s must be of type string or array, %s given', __METHOD__, \gettype($configuration) @@ -63,7 +63,7 @@ public function load($configuration): BlockInterface public function support($configuration): bool { if (!\is_string($configuration) && !\is_array($configuration)) { - throw new \TypeError(sprintf( + throw new \TypeError(\sprintf( 'Argument 1 passed to %s must be of type string or array, %s given', __METHOD__, \gettype($configuration) diff --git a/src/Block/BlockRenderer.php b/src/Block/BlockRenderer.php index 7547c627..f355a83f 100644 --- a/src/Block/BlockRenderer.php +++ b/src/Block/BlockRenderer.php @@ -25,7 +25,7 @@ final class BlockRenderer implements BlockRendererInterface public function __construct( private BlockServiceManagerInterface $blockServiceManager, private StrategyManagerInterface $exceptionStrategyManager, - private ?LoggerInterface $logger = null + private ?LoggerInterface $logger = null, ) { } @@ -35,7 +35,7 @@ public function render(BlockContextInterface $blockContext, ?Response $response if (null !== $this->logger) { $this->logger->info( - sprintf('[cms::renderBlock] block.id=%d, block.type=%s', $block->getId() ?? '', $block->getType() ?? '') + \sprintf('[cms::renderBlock] block.id=%d, block.type=%s', $block->getId() ?? '', $block->getType() ?? '') ); } @@ -46,7 +46,7 @@ public function render(BlockContextInterface $blockContext, ?Response $response $response = $service->execute($blockContext, $response ?? new Response()); } catch (\Throwable $exception) { if (null !== $this->logger) { - $this->logger->error(sprintf( + $this->logger->error(\sprintf( '[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId() ?? '', $exception->getMessage() diff --git a/src/Block/BlockServiceManager.php b/src/Block/BlockServiceManager.php index f88d1dd2..f2bd8d1b 100644 --- a/src/Block/BlockServiceManager.php +++ b/src/Block/BlockServiceManager.php @@ -39,7 +39,7 @@ final class BlockServiceManager implements BlockServiceManagerInterface */ public function __construct( private ContainerInterface $container, - private array $containerTypes + private array $containerTypes, ) { } @@ -74,7 +74,7 @@ public function has(string $name): bool public function add(string $name, $service, array $contexts = []): void { if (!\is_string($service) && !$service instanceof BlockServiceInterface) { - throw new \TypeError(sprintf( + throw new \TypeError(\sprintf( 'Argument 2 passed to %s() must be of type string or an object implementing %s, %s given', __METHOD__, BlockServiceInterface::class, @@ -160,13 +160,13 @@ public function validate(ErrorElement $errorElement, BlockInterface $block): voi private function load(string $type): BlockServiceInterface { if (!$this->has($type)) { - throw new BlockServiceNotFoundException(sprintf('The block service `%s` does not exist', $type)); + throw new BlockServiceNotFoundException(\sprintf('The block service `%s` does not exist', $type)); } if (!$this->services[$type] instanceof BlockServiceInterface) { $blockService = $this->container->get($type); if (!$blockService instanceof BlockServiceInterface) { - throw new BlockServiceNotFoundException(sprintf('The service %s does not implement BlockServiceInterface', $type)); + throw new BlockServiceNotFoundException(\sprintf('The service %s does not implement BlockServiceInterface', $type)); } $this->services[$type] = $blockService; diff --git a/src/Block/Loader/ServiceLoader.php b/src/Block/Loader/ServiceLoader.php index 08307cb7..44ff7ecf 100644 --- a/src/Block/Loader/ServiceLoader.php +++ b/src/Block/Loader/ServiceLoader.php @@ -39,7 +39,7 @@ public function exists(string $type): bool public function load($configuration): BlockInterface { if (!\is_string($configuration) && !\is_array($configuration)) { - throw new \TypeError(sprintf( + throw new \TypeError(\sprintf( 'Argument 1 passed to %s must be of type string or array, %s given', __METHOD__, \gettype($configuration) @@ -53,7 +53,7 @@ public function load($configuration): BlockInterface } if (!\in_array($configuration['type'], $this->types, true)) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'The block type "%s" does not exist', $configuration['type'] )); @@ -73,7 +73,7 @@ public function load($configuration): BlockInterface public function support($configuration): bool { if (!\is_string($configuration) && !\is_array($configuration)) { - throw new \TypeError(sprintf( + throw new \TypeError(\sprintf( 'Argument 1 passed to %s must be of type string or array, %s given', __METHOD__, \gettype($configuration) diff --git a/src/Block/Service/MenuBlockService.php b/src/Block/Service/MenuBlockService.php index 646264d7..09f68928 100644 --- a/src/Block/Service/MenuBlockService.php +++ b/src/Block/Service/MenuBlockService.php @@ -33,7 +33,7 @@ final class MenuBlockService extends AbstractMenuBlockService public function __construct( Environment $twig, private MenuProviderInterface $menuProvider, - private MenuRegistryInterface $menuRegistry + private MenuRegistryInterface $menuRegistry, ) { parent::__construct($twig); } diff --git a/src/Command/DebugBlocksCommand.php b/src/Command/DebugBlocksCommand.php index e16fe5b4..6c866660 100644 --- a/src/Command/DebugBlocksCommand.php +++ b/src/Command/DebugBlocksCommand.php @@ -51,20 +51,20 @@ public function execute(InputInterface $input, OutputInterface $output): int $title = ''; if ($service instanceof EditableBlockService) { - $title = sprintf(' (%s)', $service->getMetadata()->getTitle()); + $title = \sprintf(' (%s)', $service->getMetadata()->getTitle()); } - $output->writeln(sprintf('>> %s%s', $code, $title)); + $output->writeln(\sprintf('>> %s%s', $code, $title)); $resolver = new OptionsResolver(); $service->configureSettings($resolver); try { foreach ($resolver->resolve() as $key => $val) { - $output->writeln(sprintf(' %-30s%s', $key, json_encode($val, \JSON_THROW_ON_ERROR))); + $output->writeln(\sprintf(' %-30s%s', $key, json_encode($val, \JSON_THROW_ON_ERROR))); } } catch (MissingOptionsException) { foreach ($resolver->getDefinedOptions() as $option) { - $output->writeln(sprintf(' %s', $option)); + $output->writeln(\sprintf(' %s', $option)); } } } diff --git a/src/DependencyInjection/Compiler/TweakCompilerPass.php b/src/DependencyInjection/Compiler/TweakCompilerPass.php index 165895a0..208b26a1 100644 --- a/src/DependencyInjection/Compiler/TweakCompilerPass.php +++ b/src/DependencyInjection/Compiler/TweakCompilerPass.php @@ -60,7 +60,7 @@ public function process(ContainerBuilder $container): void foreach ($container->findTaggedServiceIds('knp_menu.menu') as $serviceId => $tags) { foreach ($tags as $attributes) { if (!isset($attributes['alias'])) { - throw new \InvalidArgumentException(sprintf('The alias is not defined in the "knp_menu.menu" tag for the service "%s"', $serviceId)); + throw new \InvalidArgumentException(\sprintf('The alias is not defined in the "knp_menu.menu" tag for the service "%s"', $serviceId)); } $registry->addMethodCall('add', [$attributes['alias']]); } diff --git a/src/Exception/Renderer/InlineDebugRenderer.php b/src/Exception/Renderer/InlineDebugRenderer.php index 8215dbbb..559358f6 100644 --- a/src/Exception/Renderer/InlineDebugRenderer.php +++ b/src/Exception/Renderer/InlineDebugRenderer.php @@ -29,7 +29,7 @@ public function __construct( private Environment $twig, private string $template, private bool $debug, - private bool $forceStyle = true + private bool $forceStyle = true, ) { } diff --git a/src/Exception/Renderer/InlineRenderer.php b/src/Exception/Renderer/InlineRenderer.php index cff082d1..8796825f 100644 --- a/src/Exception/Renderer/InlineRenderer.php +++ b/src/Exception/Renderer/InlineRenderer.php @@ -26,7 +26,7 @@ final class InlineRenderer implements RendererInterface { public function __construct( private Environment $twig, - private string $template + private string $template, ) { } diff --git a/src/Exception/Strategy/StrategyManager.php b/src/Exception/Strategy/StrategyManager.php index c48673c7..4eeeda9f 100644 --- a/src/Exception/Strategy/StrategyManager.php +++ b/src/Exception/Strategy/StrategyManager.php @@ -45,7 +45,7 @@ public function __construct( private array $filters, private array $renderers, private array $blockFilters, - private array $blockRenderers + private array $blockRenderers, ) { } @@ -57,7 +57,7 @@ public function __construct( public function setDefaultFilter(string $name): void { if (!\array_key_exists($name, $this->filters)) { - throw new \InvalidArgumentException(sprintf('Cannot set default exception filter "%s". It does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Cannot set default exception filter "%s". It does not exist.', $name)); } $this->defaultFilter = $name; @@ -71,7 +71,7 @@ public function setDefaultFilter(string $name): void public function setDefaultRenderer(string $name): void { if (!\array_key_exists($name, $this->renderers)) { - throw new \InvalidArgumentException(sprintf('Cannot set default exception renderer "%s". It does not exist.', $name)); + throw new \InvalidArgumentException(\sprintf('Cannot set default exception renderer "%s". It does not exist.', $name)); } $this->defaultRenderer = $name; @@ -119,7 +119,7 @@ public function getBlockRenderer(BlockInterface $block): RendererInterface $service = $this->container->get($this->renderers[$name]); if (!$service instanceof RendererInterface) { - throw new \InvalidArgumentException(sprintf('The service "%s" is not an exception renderer.', $name)); + throw new \InvalidArgumentException(\sprintf('The service "%s" is not an exception renderer.', $name)); } return $service; @@ -145,7 +145,7 @@ public function getBlockFilter(BlockInterface $block): FilterInterface $service = $this->container->get($this->filters[$name]); if (!$service instanceof FilterInterface) { - throw new \InvalidArgumentException(sprintf('The service "%s" is not an exception filter.', $name)); + throw new \InvalidArgumentException(\sprintf('The service "%s" is not an exception filter.', $name)); } return $service; diff --git a/src/Form/Type/ServiceListType.php b/src/Form/Type/ServiceListType.php index 86b6d7eb..4002fd7e 100644 --- a/src/Form/Type/ServiceListType.php +++ b/src/Form/Type/ServiceListType.php @@ -54,9 +54,9 @@ public function configureOptions(OptionsResolver $resolver): void $types = []; foreach ($manager->getServicesByContext($options['context'], $options['include_containers']) as $code => $service) { if ($service instanceof EditableBlockService) { - $types[sprintf('%s - %s', $service->getMetadata()->getTitle(), $code)] = $code; + $types[\sprintf('%s - %s', $service->getMetadata()->getTitle(), $code)] = $code; } else { - $types[sprintf('%s', $code)] = $code; + $types[\sprintf('%s', $code)] = $code; } } diff --git a/src/Meta/Metadata.php b/src/Meta/Metadata.php index 009ef38e..01653040 100644 --- a/src/Meta/Metadata.php +++ b/src/Meta/Metadata.php @@ -26,7 +26,7 @@ public function __construct( private ?string $description = null, private ?string $image = null, private ?string $domain = null, - private array $options = [] + private array $options = [], ) { } diff --git a/src/Model/BaseBlock.php b/src/Model/BaseBlock.php index e6198e69..f4a3a02c 100644 --- a/src/Model/BaseBlock.php +++ b/src/Model/BaseBlock.php @@ -75,7 +75,7 @@ public function __construct() public function __toString(): string { - return sprintf('%s ~ #%s', $this->getName() ?? '', $this->getId() ?? ''); + return \sprintf('%s ~ #%s', $this->getName() ?? '', $this->getId() ?? ''); } public function setName(string $name): void diff --git a/src/Profiler/DataCollector/BlockDataCollector.php b/src/Profiler/DataCollector/BlockDataCollector.php index abfd8b74..c12a8dd8 100644 --- a/src/Profiler/DataCollector/BlockDataCollector.php +++ b/src/Profiler/DataCollector/BlockDataCollector.php @@ -31,7 +31,7 @@ final class BlockDataCollector extends DataCollector */ public function __construct( private BlockHelper $blocksHelper, - private array $containerTypes + private array $containerTypes, ) { $this->reset(); } diff --git a/src/Templating/Helper/BlockHelper.php b/src/Templating/Helper/BlockHelper.php index 74946d1f..5fe3e968 100644 --- a/src/Templating/Helper/BlockHelper.php +++ b/src/Templating/Helper/BlockHelper.php @@ -65,7 +65,7 @@ public function __construct( private BlockRendererInterface $blockRenderer, private BlockContextManagerInterface $blockContextManager, private EventDispatcherInterface $eventDispatcher, - private ?Stopwatch $stopwatch = null + private ?Stopwatch $stopwatch = null, ) { } @@ -79,7 +79,7 @@ public function includeJavascripts($media, $basePath = '') { $html = ''; foreach ($this->assets['js'] as $javascript) { - $html .= "\n".sprintf('', $basePath, $javascript); + $html .= "\n".\sprintf('', $basePath, $javascript); } return $html; @@ -97,10 +97,10 @@ public function includeStylesheets($media, $basePath = '') return ''; } - $html = sprintf(""; @@ -113,7 +113,7 @@ public function includeStylesheets($media, $basePath = '') */ public function renderEvent(string $name, array $options = []): string { - $eventName = sprintf('sonata.block.event.%s', $name); + $eventName = \sprintf('sonata.block.event.%s', $name); $event = $this->eventDispatcher->dispatch(new BlockEvent($options), $eventName); @@ -188,7 +188,7 @@ private function stopTracing(BlockInterface $block, array $stats): void $event = $this->traces[$block->getId() ?? '']; if (!$event instanceof StopwatchEvent) { throw new \InvalidArgumentException( - sprintf('The block %s has no stopwatch event to stop.', $block->getId() ?? '') + \sprintf('The block %s has no stopwatch event to stop.', $block->getId() ?? '') ); } @@ -250,7 +250,7 @@ private function startTracing(BlockInterface $block): array { if (null !== $this->stopwatch) { $this->traces[$block->getId() ?? ''] = $this->stopwatch->start( - sprintf( + \sprintf( '%s (id: %s, type: %s)', $block->getName() ?? '', $block->getId() ?? '',