diff --git a/CHANGELOG.md b/CHANGELOG.md index 86b86288b..76dabfbd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [4.14.0](https://github.com/sonata-project/SonataMediaBundle/compare/4.13.0...4.14.0) - 2024-08-27 +### Added +- [[#2461](https://github.com/sonata-project/SonataMediaBundle/pull/2461)] Support for psr/http-message 2 ([@VincentLanglet](https://github.com/VincentLanglet)) + +### Fixed +- [[#2455](https://github.com/sonata-project/SonataMediaBundle/pull/2455)] Symfony 7.1 deprecation about `Symfony\Component\HttpKernel\DependencyInjection\Extension` usage ([@VincentLanglet](https://github.com/VincentLanglet)) +- [[#2452](https://github.com/sonata-project/SonataMediaBundle/pull/2452)] Remove format restriction on `FileThumbnail` service ([@VincentLanglet](https://github.com/VincentLanglet)) + ## [4.13.0](https://github.com/sonata-project/SonataMediaBundle/compare/4.12.0...4.13.0) - 2024-03-17 ### Added - [[#2448](https://github.com/sonata-project/SonataMediaBundle/pull/2448)] Compatibility with ORM 3 ([@dmaicher](https://github.com/dmaicher)) diff --git a/composer.json b/composer.json index 3d86ca377..89243dab9 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "nyholm/psr7": "^1.4", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", + "psr/http-message": "^1.0 || ^2.0", "psr/log": "^2.0 || ^3.0", "sonata-project/doctrine-extensions": "^1.13 || ^2.0", "sonata-project/form-extensions": "^1.4 || ^2.0", diff --git a/src/Action/MediaDownloadAction.php b/src/Action/MediaDownloadAction.php index 483eb408e..a30495667 100644 --- a/src/Action/MediaDownloadAction.php +++ b/src/Action/MediaDownloadAction.php @@ -41,7 +41,7 @@ public function __invoke(Request $request, $id, string $format = MediaProviderIn $media = $this->mediaManager->find($id); if (null === $media) { - throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id)); + throw new NotFoundHttpException(\sprintf('unable to find the media with the id : %s', $id)); } if (!$this->pool->getDownloadStrategy($media)->isGranted($media, $request)) { diff --git a/src/CDN/CloudFrontVersion3.php b/src/CDN/CloudFrontVersion3.php index f90c2ee95..cfacb509d 100644 --- a/src/CDN/CloudFrontVersion3.php +++ b/src/CDN/CloudFrontVersion3.php @@ -66,7 +66,7 @@ public function __construct( public function getPath(string $relativePath, bool $isFlushable = false): string { - return sprintf('%s/%s', $this->path, ltrim($relativePath, '/')); + return \sprintf('%s/%s', $this->path, ltrim($relativePath, '/')); } public function flushByString(string $string): string @@ -115,7 +115,7 @@ public function flushPaths(array $paths): string } if (!\in_array($status, self::AVAILABLE_STATUSES, true)) { - throw new \RuntimeException(sprintf('Unable to determine the flush status from the given response: "%s".', $status)); + throw new \RuntimeException(\sprintf('Unable to determine the flush status from the given response: "%s".', $status)); } $id = $invalidation['Id'] ?? null; @@ -126,7 +126,7 @@ public function flushPaths(array $paths): string return $id; } catch (CloudFrontException $ex) { - throw new \RuntimeException(sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex); + throw new \RuntimeException(\sprintf('Unable to flush paths "%s".', implode('", "', $paths)), 0, $ex); } } @@ -148,7 +148,7 @@ public function getFlushStatus(string $identifier): int throw new \RuntimeException('Unable to determine the flush status from the given response.'); } catch (CloudFrontException $ex) { - throw new \RuntimeException(sprintf('Unable to retrieve flush status for identifier %s.', $identifier), 0, $ex); + throw new \RuntimeException(\sprintf('Unable to retrieve flush status for identifier %s.', $identifier), 0, $ex); } } diff --git a/src/CDN/Server.php b/src/CDN/Server.php index 3a913467d..9c0b0512e 100644 --- a/src/CDN/Server.php +++ b/src/CDN/Server.php @@ -24,7 +24,7 @@ public function __construct(string $path) public function getPath(string $relativePath, bool $isFlushable = false): string { - return sprintf('%s/%s', $this->path, ltrim($relativePath, '/')); + return \sprintf('%s/%s', $this->path, ltrim($relativePath, '/')); } public function flushByString(string $string): string diff --git a/src/Command/AddMassMediaCommand.php b/src/Command/AddMassMediaCommand.php index da18fe3cc..1a4b4e217 100644 --- a/src/Command/AddMassMediaCommand.php +++ b/src/Command/AddMassMediaCommand.php @@ -101,7 +101,7 @@ private function getFilePointer(InputInterface $input, OutputInterface $output) $filePointer = fopen($file, 'r'); if (false === $filePointer) { - throw new \RuntimeException(sprintf('The provided CSV file %s could not be opened', $file)); + throw new \RuntimeException(\sprintf('The provided CSV file %s could not be opened', $file)); } return $filePointer; @@ -120,9 +120,9 @@ private function insertMedia(array $data, OutputInterface $output): void try { $this->mediaManager->save($media); - $output->writeln(sprintf(' > %s - %s', $media->getId() ?? '', $media->getName() ?? '')); + $output->writeln(\sprintf(' > %s - %s', $media->getId() ?? '', $media->getName() ?? '')); } catch (\Exception $e) { - $output->writeln(sprintf('%s : %s', $e->getMessage(), json_encode($data, \JSON_THROW_ON_ERROR))); + $output->writeln(\sprintf('%s : %s', $e->getMessage(), json_encode($data, \JSON_THROW_ON_ERROR))); } } } diff --git a/src/Command/AddMediaCommand.php b/src/Command/AddMediaCommand.php index 8486436be..d4cf5fcad 100644 --- a/src/Command/AddMediaCommand.php +++ b/src/Command/AddMediaCommand.php @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $context = $input->getArgument('context'); $binaryContent = $input->getArgument('binaryContent'); - $output->writeln(sprintf('Add a new media - context: %s, provider: %s, content: %s', $context, $provider, $binaryContent)); + $output->writeln(\sprintf('Add a new media - context: %s, provider: %s, content: %s', $context, $provider, $binaryContent)); $media = $this->mediaManager->create(); $media->setBinaryContent($binaryContent); diff --git a/src/Command/CleanMediaCommand.php b/src/Command/CleanMediaCommand.php index 85bec1b96..00cbf79a4 100755 --- a/src/Command/CleanMediaCommand.php +++ b/src/Command/CleanMediaCommand.php @@ -64,16 +64,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int throw new \RuntimeException('Unable to find upload directory, did you configure it?'); } - $output->writeln(sprintf('Scanning upload directory: %s', $baseDirectory)); + $output->writeln(\sprintf('Scanning upload directory: %s', $baseDirectory)); foreach ($this->mediaPool->getContexts() as $contextName => $context) { if (!$filesystem->exists($baseDirectory.'/'.$contextName)) { - $output->writeln(sprintf("'%s' does not exist", $baseDirectory.'/'.$contextName)); + $output->writeln(\sprintf("'%s' does not exist", $baseDirectory.'/'.$contextName)); continue; } - $output->writeln(sprintf('Context: %s', $contextName)); + $output->writeln(\sprintf('Context: %s', $contextName)); $files = $finder->files()->in($baseDirectory.'/'.$contextName); @@ -82,7 +82,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$this->mediaExists($filename, $contextName)) { if ($dryRun) { - $output->writeln(sprintf("'%s' is orphanend", $filename)); + $output->writeln(\sprintf("'%s' is orphanend", $filename)); } else { try { $realPath = $file->getRealPath(); @@ -91,13 +91,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int $filesystem->remove($realPath); } - $output->writeln(sprintf("'%s' was successfully removed", $filename)); + $output->writeln(\sprintf("'%s' was successfully removed", $filename)); } catch (IOException $ioe) { - $output->writeln(sprintf('%s', $ioe->getMessage())); + $output->writeln(\sprintf('%s', $ioe->getMessage())); } } } elseif ($verbose) { - $output->writeln(sprintf("'%s' found", $filename)); + $output->writeln(\sprintf("'%s' found", $filename)); } } } diff --git a/src/Command/FixMediaContextCommand.php b/src/Command/FixMediaContextCommand.php index 48613d7b4..f152c555c 100755 --- a/src/Command/FixMediaContextCommand.php +++ b/src/Command/FixMediaContextCommand.php @@ -48,7 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $defaultContext = $this->contextManager->find($context); if (null === $defaultContext) { - $output->writeln(sprintf(" > default context for '%s' is missing, creating one", $context)); + $output->writeln(\sprintf(" > default context for '%s' is missing, creating one", $context)); $defaultContext = $this->contextManager->create(); $defaultContext->setId($context); $defaultContext->setName(ucfirst($context)); diff --git a/src/Command/RefreshMetadataCommand.php b/src/Command/RefreshMetadataCommand.php index b24e1cba9..1108049dc 100644 --- a/src/Command/RefreshMetadataCommand.php +++ b/src/Command/RefreshMetadataCommand.php @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'context' => $context, ]); - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Loaded %s medias for generating thumbs (provider: %s, context: %s)', \count($medias), $provider->getName(), @@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int )); foreach ($medias as $media) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Refresh media %s - %s', $media->getName() ?? '', $media->getId() ?? '' @@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $provider->updateMetadata($media, false); } catch (\Exception $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable to update metadata, media: %s - %s ', $media->getId() ?? '', $e->getMessage() @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $this->mediaManager->save($media); } catch (\Exception $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable saving media, media: %s - %s ', $media->getId() ?? '', $e->getMessage() diff --git a/src/Command/RemoveThumbsCommand.php b/src/Command/RemoveThumbsCommand.php index 6acc6a90e..837f20693 100644 --- a/src/Command/RemoveThumbsCommand.php +++ b/src/Command/RemoveThumbsCommand.php @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $batchOffset ); } catch (\Exception $e) { - $this->log($output, sprintf('Error: %s', $e->getMessage())); + $this->log($output, \sprintf('Error: %s', $e->getMessage())); break; } @@ -98,7 +98,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $totalMediasCount += $batchMediasCount; - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Loaded %s medias (batch #%d, offset %d) for removing thumbs (provider: %s, format: %s)', $batchMediasCount, $batchCounter, @@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $this->log($output, sprintf('Done (total medias processed: %s).', $totalMediasCount)); + $this->log($output, \sprintf('Done (total medias processed: %s).', $totalMediasCount)); return 0; } @@ -181,7 +181,7 @@ private function getFormat(InputInterface $input, OutputInterface $output, Media private function processMedia(OutputInterface $output, MediaInterface $media, MediaProviderInterface $provider, string $context, string $format): bool { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Deleting thumbs for %s - %s', $media->getName() ?? '', $media->getId() ?? '' @@ -194,7 +194,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me $provider->removeThumbnails($media, $format); } catch (\Exception $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable to remove thumbnails, media: %s - %s ', $media->getId() ?? '', $e->getMessage() diff --git a/src/Command/SyncThumbsCommand.php b/src/Command/SyncThumbsCommand.php index 702f88424..57e3b304d 100644 --- a/src/Command/SyncThumbsCommand.php +++ b/src/Command/SyncThumbsCommand.php @@ -91,7 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $batchOffset ); } catch (\Exception $e) { - $this->log($output, sprintf('Error: %s', $e->getMessage())); + $this->log($output, \sprintf('Error: %s', $e->getMessage())); break; } @@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $totalMediasCount += $batchMediasCount; - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Loaded %s medias (batch #%d, offset %d) for generating thumbs (provider: %s, context: %s)', $batchMediasCount, $batchCounter, @@ -130,14 +130,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int } } - $this->log($output, sprintf('Done (total medias processed: %s).', $totalMediasCount)); + $this->log($output, \sprintf('Done (total medias processed: %s).', $totalMediasCount)); return 0; } private function processMedia(OutputInterface $output, MediaInterface $media, MediaProviderInterface $provider): bool { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Generating thumbs for %s - %s', $media->getName() ?? '', $media->getId() ?? '' @@ -146,7 +146,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me try { $provider->removeThumbnails($media); } catch (\Exception $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable to remove old thumbnails, media: %s - %s ', $media->getId() ?? '', $e->getMessage() @@ -158,7 +158,7 @@ private function processMedia(OutputInterface $output, MediaInterface $media, Me try { $provider->generateThumbnails($media); } catch (\Exception $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable to generate new thumbnails, media: %s - %s ', $media->getId() ?? '', $e->getMessage() diff --git a/src/Command/UpdateCdnStatusCommand.php b/src/Command/UpdateCdnStatusCommand.php index 53c8360f2..1279665a6 100644 --- a/src/Command/UpdateCdnStatusCommand.php +++ b/src/Command/UpdateCdnStatusCommand.php @@ -83,13 +83,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int 'cdnIsFlushable' => true, ]); - $this->log($output, sprintf('Loaded %s media for CDN status update (provider: %s, context: %s)', \count($medias), $provider->getName(), $context)); + $this->log($output, \sprintf('Loaded %s media for CDN status update (provider: %s, context: %s)', \count($medias), $provider->getName(), $context)); foreach ($medias as $media) { $cdn = $provider->getCdn(); $flushIdentifier = $media->getCdnFlushIdentifier(); - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Refresh CDN status for media "%s" (%s) ', $media->getName() ?? '', $media->getId() ?? '' @@ -118,15 +118,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) { if ($previousStatus === $cdnStatus) { - $this->log($output, sprintf('No changes (%u)', $cdnStatus)); + $this->log($output, \sprintf('No changes (%u)', $cdnStatus)); } elseif (CDNInterface::STATUS_OK === $cdnStatus) { - $this->log($output, sprintf('Flush completed (%u => %u)', $previousStatus ?? 'null', $cdnStatus)); + $this->log($output, \sprintf('Flush completed (%u => %u)', $previousStatus ?? 'null', $cdnStatus)); } else { - $this->log($output, sprintf('Updated status (%u => %u)', $previousStatus ?? 'null', $cdnStatus)); + $this->log($output, \sprintf('Updated status (%u => %u)', $previousStatus ?? 'null', $cdnStatus)); } } } catch (\Throwable $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable update CDN status, media: %s - %s ', $media->getId() ?? '', $e->getMessage() @@ -138,7 +138,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $this->mediaManager->save($media); } catch (\Throwable $e) { - $this->log($output, sprintf( + $this->log($output, \sprintf( 'Unable to update medium: %s - %s ', $media->getId() ?? '', $e->getMessage() diff --git a/src/DependencyInjection/Compiler/AddProviderCompilerPass.php b/src/DependencyInjection/Compiler/AddProviderCompilerPass.php index 703242833..802d8affc 100644 --- a/src/DependencyInjection/Compiler/AddProviderCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddProviderCompilerPass.php @@ -91,7 +91,7 @@ private function applyFormats(ContainerBuilder $container, array $config): void $definition = $container->getDefinition($id); foreach ($context['formats'] as $format => $formatConfig) { - $definition->addMethodCall('addFormat', [sprintf('%s_%s', $name, $format), $formatConfig]); + $definition->addMethodCall('addFormat', [\sprintf('%s_%s', $name, $format), $formatConfig]); } } } diff --git a/src/DependencyInjection/SonataMediaExtension.php b/src/DependencyInjection/SonataMediaExtension.php index da667c1b4..224bddd44 100644 --- a/src/DependencyInjection/SonataMediaExtension.php +++ b/src/DependencyInjection/SonataMediaExtension.php @@ -72,14 +72,14 @@ public function load(array $configs, ContainerBuilder $container): void } if (!\array_key_exists($config['default_context'], $config['contexts'])) { - throw new \InvalidArgumentException(sprintf('SonataMediaBundle - Invalid default context : %s, available : %s', $config['default_context'], json_encode(array_keys($config['contexts']), \JSON_THROW_ON_ERROR))); + throw new \InvalidArgumentException(\sprintf('SonataMediaBundle - Invalid default context : %s, available : %s', $config['default_context'], json_encode(array_keys($config['contexts']), \JSON_THROW_ON_ERROR))); } - $loader->load(sprintf('%s.php', $config['db_driver'])); + $loader->load(\sprintf('%s.php', $config['db_driver'])); if (isset($bundles['SonataAdminBundle'])) { $loader->load('controllers.php'); - $loader->load(sprintf('%s_admin.php', $config['db_driver'])); + $loader->load(\sprintf('%s_admin.php', $config['db_driver'])); $sonataRoles = []; if (isset($this->sonataAdminConfig['security']['role_admin'])) { diff --git a/src/Filesystem/Replicate.php b/src/Filesystem/Replicate.php index ca6041b5d..663d6e060 100644 --- a/src/Filesystem/Replicate.php +++ b/src/Filesystem/Replicate.php @@ -42,7 +42,7 @@ public function delete($key): bool try { $this->secondary->delete($key); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); $ok = false; } @@ -50,7 +50,7 @@ public function delete($key): bool try { $this->primary->delete($key); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); $ok = false; } @@ -95,7 +95,7 @@ public function write($key, $content) try { $return = $this->primary->write($key, $content); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); $ok = false; } @@ -103,7 +103,7 @@ public function write($key, $content) try { $return = $this->secondary->write($key, $content); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); $ok = false; } @@ -128,7 +128,7 @@ public function rename($sourceKey, $targetKey): bool try { $this->primary->rename($sourceKey, $targetKey); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to rename %s, error: %s', $sourceKey, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to rename %s, error: %s', $sourceKey, $e->getMessage())); $ok = false; } @@ -136,7 +136,7 @@ public function rename($sourceKey, $targetKey): bool try { $this->secondary->rename($sourceKey, $targetKey); } catch (\Exception $e) { - $this->logger->critical(sprintf('Unable to rename %s, error: %s', $sourceKey, $e->getMessage())); + $this->logger->critical(\sprintf('Unable to rename %s, error: %s', $sourceKey, $e->getMessage())); $ok = false; } @@ -210,7 +210,7 @@ public function createFile($key, Filesystem $filesystem): File return $this->secondary->createFile($key, $filesystem); } - throw new \LogicException(sprintf('None of the adapters implement %s.', FileFactory::class)); + throw new \LogicException(\sprintf('None of the adapters implement %s.', FileFactory::class)); } /** @@ -226,7 +226,7 @@ public function createStream($key): Stream return $this->secondary->createStream($key); } - throw new \LogicException(sprintf('None of the adapters implement %s.', StreamFactory::class)); + throw new \LogicException(\sprintf('None of the adapters implement %s.', StreamFactory::class)); } /** @@ -237,7 +237,7 @@ public function createStream($key): Stream public function listDirectory(string $directory = ''): array { if (!method_exists($this->primary, 'listDirectory')) { - throw new \BadMethodCallException(sprintf( + throw new \BadMethodCallException(\sprintf( 'Method "%s()" is not supported by the primary adapter "%s".', __METHOD__, $this->primary::class diff --git a/src/Generator/IdGenerator.php b/src/Generator/IdGenerator.php index 6330a950b..28c5a92dd 100644 --- a/src/Generator/IdGenerator.php +++ b/src/Generator/IdGenerator.php @@ -28,7 +28,7 @@ public function generatePath(MediaInterface $media): string $id = $media->getId(); if (!is_numeric($id)) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'Unable to generate path for media without numeric id using %s.', self::class )); @@ -37,7 +37,7 @@ public function generatePath(MediaInterface $media): string $context = $media->getContext(); if (null === $context) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'Unable to generate path for media without context using %s.', self::class )); @@ -46,6 +46,6 @@ public function generatePath(MediaInterface $media): string $repFirstLevel = (int) ($id / $this->firstLevel); $repSecondLevel = (int) (($id - ($repFirstLevel * $this->firstLevel)) / $this->secondLevel); - return sprintf('%s/%04s/%02s', $context, $repFirstLevel + 1, $repSecondLevel + 1); + return \sprintf('%s/%04s/%02s', $context, $repFirstLevel + 1, $repSecondLevel + 1); } } diff --git a/src/Generator/PathGenerator.php b/src/Generator/PathGenerator.php index 4745539e6..d106f4417 100644 --- a/src/Generator/PathGenerator.php +++ b/src/Generator/PathGenerator.php @@ -32,12 +32,12 @@ public function generatePath(MediaInterface $media): string $context = $media->getContext(); if (null === $context) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'Unable to generate path for media without context using %s.', self::class )); } - return '' !== $path ? sprintf('%s/%s', $context, $path) : $context; + return '' !== $path ? \sprintf('%s/%s', $context, $path) : $context; } } diff --git a/src/Generator/UuidGenerator.php b/src/Generator/UuidGenerator.php index 73e1c3a0e..ba352b645 100644 --- a/src/Generator/UuidGenerator.php +++ b/src/Generator/UuidGenerator.php @@ -23,12 +23,12 @@ public function generatePath(MediaInterface $media): string $context = $media->getContext(); if (null === $context) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'Unable to generate path for media without context using %s.', self::class )); } - return sprintf('%s/%04s/%02s', $context, substr($id, 0, 4), substr($id, 4, 2)); + return \sprintf('%s/%04s/%02s', $context, substr($id, 0, 4), substr($id, 4, 2)); } } diff --git a/src/Listener/ORM/MediaEventSubscriber.php b/src/Listener/ORM/MediaEventSubscriber.php index 17053adb6..2c44f0ed7 100644 --- a/src/Listener/ORM/MediaEventSubscriber.php +++ b/src/Listener/ORM/MediaEventSubscriber.php @@ -97,7 +97,7 @@ private function getRootCategory(MediaInterface $media): CategoryInterface $context = $media->getContext(); if (null === $context) { - throw new \RuntimeException(sprintf('There is no context on media %s', $media->getId() ?? '')); + throw new \RuntimeException(\sprintf('There is no context on media %s', $media->getId() ?? '')); } if (null !== $this->rootCategories) { @@ -110,6 +110,6 @@ private function getRootCategory(MediaInterface $media): CategoryInterface } } - throw new \RuntimeException(sprintf('There is no main category related to context: %s', $context)); + throw new \RuntimeException(\sprintf('There is no main category related to context: %s', $context)); } } diff --git a/src/Messenger/GenerateThumbnailsHandler.php b/src/Messenger/GenerateThumbnailsHandler.php index 004d1a143..3db602340 100644 --- a/src/Messenger/GenerateThumbnailsHandler.php +++ b/src/Messenger/GenerateThumbnailsHandler.php @@ -40,19 +40,19 @@ public function __invoke(GenerateThumbnailsMessage $message): void $media = $this->mediaManager->find($mediaId); if (null === $media) { - throw new UnrecoverableMessageHandlingException(sprintf('Media "%s" not found.', $mediaId)); + throw new UnrecoverableMessageHandlingException(\sprintf('Media "%s" not found.', $mediaId)); } $providerName = $media->getProviderName(); if (null === $providerName) { - throw new UnrecoverableMessageHandlingException(sprintf('Media "%s" does not have a provider name.', $mediaId)); + throw new UnrecoverableMessageHandlingException(\sprintf('Media "%s" does not have a provider name.', $mediaId)); } try { $provider = $this->pool->getProvider($providerName); } catch (\Exception) { - throw new UnrecoverableMessageHandlingException(sprintf('Provider "%s" not found.', $providerName)); + throw new UnrecoverableMessageHandlingException(\sprintf('Provider "%s" not found.', $providerName)); } $this->thumbnail->generate($provider, $media); diff --git a/src/Metadata/AmazonMetadataBuilder.php b/src/Metadata/AmazonMetadataBuilder.php index 1ace578bd..720c01403 100644 --- a/src/Metadata/AmazonMetadataBuilder.php +++ b/src/Metadata/AmazonMetadataBuilder.php @@ -114,7 +114,7 @@ private function getContentType(string $filename): array $mimeType = current($mimeTypes); if (false === $mimeType) { - throw new \RuntimeException(sprintf('Unable to determine the mime type for file %s', $filename)); + throw new \RuntimeException(\sprintf('Unable to determine the mime type for file %s', $filename)); } return ['contentType' => $mimeType]; diff --git a/src/Model/Gallery.php b/src/Model/Gallery.php index a53cf154b..13cc34532 100644 --- a/src/Model/Gallery.php +++ b/src/Model/Gallery.php @@ -148,7 +148,7 @@ public function reorderGalleryItems(): void $iterator = $this->getGalleryItems()->getIterator(); if (!$iterator instanceof \ArrayIterator) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'The gallery %s cannot be reordered, $galleryItems should implement %s', $this->getId() ?? '', \ArrayIterator::class diff --git a/src/Provider/BaseVideoProvider.php b/src/Provider/BaseVideoProvider.php index bc6461594..95bd88bbd 100644 --- a/src/Provider/BaseVideoProvider.php +++ b/src/Provider/BaseVideoProvider.php @@ -81,7 +81,7 @@ final public function generatePublicUrl(MediaInterface $media, string $format): throw new \InvalidArgumentException('Unable to generate public url for media without id.'); } - return $this->getCdn()->getPath(sprintf( + return $this->getCdn()->getPath(\sprintf( '%s/thumb_%s_%s.jpg', $this->generatePath($media), $id, @@ -97,7 +97,7 @@ final public function generatePrivateUrl(MediaInterface $media, string $format): throw new \InvalidArgumentException('Unable to generate public url for media without id.'); } - return sprintf( + return \sprintf( '%s/thumb_%s_%s.jpg', $this->generatePath($media), $id, @@ -171,7 +171,7 @@ protected function getMetadata(MediaInterface $media, string $url) $response = $this->sendRequest('GET', $url); } catch (\RuntimeException $exception) { throw new \RuntimeException( - sprintf('Unable to retrieve the video information for: %s', $url), + \sprintf('Unable to retrieve the video information for: %s', $url), (int) $exception->getCode(), $exception ); @@ -180,7 +180,7 @@ protected function getMetadata(MediaInterface $media, string $url) $metadata = json_decode($response, true, 512, \JSON_THROW_ON_ERROR); if (null === $metadata) { - throw new \RuntimeException(sprintf('Unable to decode the video information for: %s', $url)); + throw new \RuntimeException(\sprintf('Unable to decode the video information for: %s', $url)); } return $metadata; @@ -209,7 +209,7 @@ protected function getBoxHelperProperties(MediaInterface $media, string $format, $settings = $this->getFormat($format); if (false === $settings) { - throw new \RuntimeException(sprintf('Unable to retrieve format settings for format %s.', $format)); + throw new \RuntimeException(\sprintf('Unable to retrieve format settings for format %s.', $format)); } } diff --git a/src/Provider/DailyMotionProvider.php b/src/Provider/DailyMotionProvider.php index 7fa721a94..1277dac94 100644 --- a/src/Provider/DailyMotionProvider.php +++ b/src/Provider/DailyMotionProvider.php @@ -91,7 +91,7 @@ public function getProviderMetadata(): MetadataInterface public function updateMetadata(MediaInterface $media, bool $force = false): void { - $url = sprintf('http://www.dailymotion.com/services/oembed?url=%s&format=json', $this->getReferenceUrl($media)); + $url = \sprintf('http://www.dailymotion.com/services/oembed?url=%s&format=json', $this->getReferenceUrl($media)); try { $metadata = $this->getMetadata($media, $url); @@ -126,7 +126,7 @@ public function getReferenceUrl(MediaInterface $media): string throw new \InvalidArgumentException('Unable to generate reference url for media without provider reference.'); } - return sprintf('http://www.dailymotion.com/video/%s', $providerReference); + return \sprintf('http://www.dailymotion.com/video/%s', $providerReference); } protected function doTransform(MediaInterface $media): void diff --git a/src/Provider/FileProvider.php b/src/Provider/FileProvider.php index 274b3dac9..846e06d71 100644 --- a/src/Provider/FileProvider.php +++ b/src/Provider/FileProvider.php @@ -72,7 +72,7 @@ public function getReferenceImage(MediaInterface $media): string throw new \InvalidArgumentException('Unable to generate reference image for media without provider reference.'); } - return sprintf('%s/%s', $this->generatePath($media), $providerReference); + return \sprintf('%s/%s', $this->generatePath($media), $providerReference); } public function getReferenceFile(MediaInterface $media): GaufretteFile @@ -168,7 +168,7 @@ public function updateMetadata(MediaInterface $media, bool $force = true): void $path = tempnam(sys_get_temp_dir(), 'sonata_update_metadata_'); if (false === $path) { - throw new \InvalidArgumentException(sprintf('Unable to generate temporary file name for media %s.', $media->getId() ?? '')); + throw new \InvalidArgumentException(\sprintf('Unable to generate temporary file name for media %s.', $media->getId() ?? '')); } $fileObject = new \SplFileObject($path, 'w'); @@ -212,7 +212,7 @@ public function getDownloadResponse(MediaInterface $media, string $format, strin // build the default headers $headers = array_merge([ 'Content-Type' => $media->getContentType(), - 'Content-Disposition' => sprintf('attachment; filename="%s"', $media->getMetadataValue('filename')), + 'Content-Disposition' => \sprintf('attachment; filename="%s"', $media->getMetadataValue('filename')), ], $headers); if (!\in_array($mode, ['http', 'X-Sendfile', 'X-Accel-Redirect'], true)) { @@ -234,7 +234,7 @@ public function getDownloadResponse(MediaInterface $media, string $format, strin $adapter = $this->getFilesystem()->getAdapter(); if (!$adapter instanceof Local) { - throw new \RuntimeException(sprintf('Cannot use X-Sendfile or X-Accel-Redirect with non %s.', Local::class)); + throw new \RuntimeException(\sprintf('Cannot use X-Sendfile or X-Accel-Redirect with non %s.', Local::class)); } $directory = $adapter->getDirectory(); @@ -244,7 +244,7 @@ public function getDownloadResponse(MediaInterface $media, string $format, strin } return new BinaryFileResponse( - sprintf('%s/%s', $directory, $this->generatePrivateUrl($media, $format)), + \sprintf('%s/%s', $directory, $this->generatePrivateUrl($media, $format)), 200, $headers ); @@ -263,7 +263,7 @@ public function validate(ErrorElement $errorElement, MediaInterface $media): voi } elseif ($binaryContent instanceof File) { $fileName = $binaryContent->getFilename(); } else { - throw new \RuntimeException(sprintf('Invalid binary content type: %s', $binaryContent::class)); + throw new \RuntimeException(\sprintf('Invalid binary content type: %s', $binaryContent::class)); } if ($binaryContent instanceof UploadedFile && 0 === $binaryContent->getSize()) { @@ -302,7 +302,7 @@ protected function fixBinaryContent(MediaInterface $media): void // if the binary content is a filename => convert to a valid File if (!is_file($media->getBinaryContent())) { - throw new \RuntimeException(sprintf('The file does not exist: %s', $media->getBinaryContent())); + throw new \RuntimeException(\sprintf('The file does not exist: %s', $media->getBinaryContent())); } $binaryContent = new File($media->getBinaryContent()); @@ -363,14 +363,14 @@ protected function setFileContents(MediaInterface $media, ?string $contents = nu $providerReference = $media->getProviderReference(); if (null === $providerReference) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'Unable to generate path to file without provider reference for media "%s".', (string) $media )); } $file = $this->getFilesystem()->get( - sprintf('%s/%s', $this->generatePath($media), $providerReference), + \sprintf('%s/%s', $this->generatePath($media), $providerReference), true ); @@ -388,7 +388,7 @@ protected function setFileContents(MediaInterface $media, ?string $contents = nu $fileContents = file_get_contents($path); if (false === $fileContents) { - throw new \RuntimeException(sprintf('Unable to get file contents for media %s', $media->getId() ?? '')); + throw new \RuntimeException(\sprintf('Unable to get file contents for media %s', $media->getId() ?? '')); } $file->setContent($fileContents, $metadata); diff --git a/src/Provider/ImageProvider.php b/src/Provider/ImageProvider.php index 2fa4cb9f3..e2bf77e0e 100644 --- a/src/Provider/ImageProvider.php +++ b/src/Provider/ImageProvider.php @@ -62,7 +62,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array } else { $resizerFormat = $this->getFormat($format); if (false === $resizerFormat) { - throw new \RuntimeException(sprintf('The image format "%s" is not defined. + throw new \RuntimeException(\sprintf('The image format "%s" is not defined. Is the format registered in your ``sonata_media`` configuration?', $format)); } @@ -90,7 +90,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array $settings = $this->getFormat($formatName); if (false === $settings) { - throw new \RuntimeException(sprintf('The image format "%s" is not defined. + throw new \RuntimeException(\sprintf('The image format "%s" is not defined. Is the format registered in your ``sonata_media`` configuration?', $formatName)); } @@ -101,7 +101,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array $src = $this->generatePublicUrl($media, $formatName); $mediaQuery = \is_string($key) ? $key - : sprintf('(max-width: %dpx)', $this->resizer->getBox($media, $settings)->getWidth()); + : \sprintf('(max-width: %dpx)', $this->resizer->getBox($media, $settings)->getWidth()); $pictureParams['source'][] = ['media' => $mediaQuery, 'srcset' => $src]; } @@ -119,7 +119,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array $settings = $this->getFormat($formatName); if (false === $settings) { - throw new \RuntimeException(sprintf('The image format "%s" is not defined. + throw new \RuntimeException(\sprintf('The image format "%s" is not defined. Is the format registered in your ``sonata_media`` configuration?', $formatName)); } @@ -132,7 +132,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array $settings = $this->getFormat($format); if (false === $settings) { - throw new \RuntimeException(sprintf('The image format "%s" is not defined. + throw new \RuntimeException(\sprintf('The image format "%s" is not defined. Is the format registered in your ``sonata_media`` configuration?', $format)); } @@ -154,12 +154,12 @@ public function getHelperProperties(MediaInterface $media, string $format, array $width = $this->resizer->getBox($media, $settings)->getWidth(); - $srcSet[] = sprintf('%s %dw', $this->generatePublicUrl($media, $providerFormat), $width); + $srcSet[] = \sprintf('%s %dw', $this->generatePublicUrl($media, $providerFormat), $width); } } // The reference format is not in the formats list - $srcSet[] = sprintf( + $srcSet[] = \sprintf( '%s %dw', $this->generatePublicUrl($media, MediaProviderInterface::FORMAT_REFERENCE), $media->getBox()->getWidth() @@ -168,7 +168,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array $params['srcset'] = implode(', ', $srcSet); } - $params['sizes'] = sprintf('(max-width: %1$dpx) 100vw, %1$dpx', $mediaWidth); + $params['sizes'] = \sprintf('(max-width: %1$dpx) 100vw, %1$dpx', $mediaWidth); } return array_merge($params, $options); @@ -182,7 +182,7 @@ public function updateMetadata(MediaInterface $media, bool $force = true): void $path = tempnam(sys_get_temp_dir(), 'sonata_update_metadata'); if (false === $path) { - throw new \LogicException(sprintf('Unable to update metadata for media %s.', $media->getId() ?? '')); + throw new \LogicException(\sprintf('Unable to update metadata for media %s.', $media->getId() ?? '')); } $fileObject = new \SplFileObject($path, 'w'); @@ -268,7 +268,7 @@ protected function doTransform(MediaInterface $media): void if (null === $extension || !\in_array(strtolower($extension), $this->allowedExtensions, true)) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); - throw new UploadException(sprintf( + throw new UploadException(\sprintf( 'The image extension "%s" is not one of the allowed (%s).', $extension ?? '', '"'.implode('", "', $this->allowedExtensions).'"' @@ -280,7 +280,7 @@ protected function doTransform(MediaInterface $media): void if (null === $mimeType || !\in_array(strtolower($mimeType), $this->allowedMimeTypes, true)) { $media->setProviderStatus(MediaInterface::STATUS_ERROR); - throw new UploadException(sprintf( + throw new UploadException(\sprintf( 'The image mime type "%s" is not one of the allowed (%s).', $mimeType ?? '', '"'.implode('", "', $this->allowedMimeTypes).'"' diff --git a/src/Provider/Pool.php b/src/Provider/Pool.php index e768dc13f..5693f3e60 100644 --- a/src/Provider/Pool.php +++ b/src/Provider/Pool.php @@ -63,11 +63,11 @@ public function getProvider(?string $name): MediaProviderInterface } if ([] === $this->providers) { - throw new \RuntimeException(sprintf('Unable to retrieve provider named "%s" since there are no providers configured yet.', $name)); + throw new \RuntimeException(\sprintf('Unable to retrieve provider named "%s" since there are no providers configured yet.', $name)); } if (!isset($this->providers[$name])) { - throw new \InvalidArgumentException(sprintf('Unable to retrieve the provider named "%s". Available providers are %s.', $name, '"'.implode('", "', $this->getProviderList()).'"')); + throw new \InvalidArgumentException(\sprintf('Unable to retrieve the provider named "%s". Available providers are %s.', $name, '"'.implode('", "', $this->getProviderList()).'"')); } return $this->providers[$name]; @@ -141,7 +141,7 @@ public function hasContext(string $name): bool public function getContext(string $name): array { if (!$this->hasContext($name)) { - throw new \LogicException(sprintf('Pool does not have context %s, did you configure all your contexts?', $name)); + throw new \LogicException(\sprintf('Pool does not have context %s, did you configure all your contexts?', $name)); } return $this->contexts[$name]; @@ -217,19 +217,19 @@ public function getDownloadStrategy(MediaInterface $media): DownloadStrategyInte $mediaContext = $media->getContext(); if (null === $mediaContext) { - throw new \RuntimeException(sprintf('Media %s does not have context', $media->getId() ?? '')); + throw new \RuntimeException(\sprintf('Media %s does not have context', $media->getId() ?? '')); } $download = $this->getContext($mediaContext)['download']; if (!isset($download['strategy'])) { - throw new \RuntimeException(sprintf('Unable to retrieve the download strategy from context %s.', $mediaContext)); + throw new \RuntimeException(\sprintf('Unable to retrieve the download strategy from context %s.', $mediaContext)); } $strategy = $download['strategy']; if (!isset($this->downloadStrategies[$strategy])) { - throw new \RuntimeException(sprintf('Unable to retrieve the download security %s', $strategy)); + throw new \RuntimeException(\sprintf('Unable to retrieve the download security %s', $strategy)); } return $this->downloadStrategies[$strategy]; @@ -243,13 +243,13 @@ public function getDownloadMode(MediaInterface $media): string $mediaContext = $media->getContext(); if (null === $mediaContext) { - throw new \RuntimeException(sprintf('Media %s does not have context', $media->getId() ?? '')); + throw new \RuntimeException(\sprintf('Media %s does not have context', $media->getId() ?? '')); } $download = $this->getContext($mediaContext)['download']; if (!isset($download['mode'])) { - throw new \RuntimeException(sprintf('Unable to retrieve the download mode from context %s.', $mediaContext)); + throw new \RuntimeException(\sprintf('Unable to retrieve the download mode from context %s.', $mediaContext)); } return $download['mode']; diff --git a/src/Provider/VimeoProvider.php b/src/Provider/VimeoProvider.php index 37100ae82..c476b8d22 100644 --- a/src/Provider/VimeoProvider.php +++ b/src/Provider/VimeoProvider.php @@ -85,7 +85,7 @@ public function getProviderMetadata(): MetadataInterface public function updateMetadata(MediaInterface $media, bool $force = false): void { - $url = sprintf('https://vimeo.com/api/oembed.json?url=%s', $this->getReferenceUrl($media)); + $url = \sprintf('https://vimeo.com/api/oembed.json?url=%s', $this->getReferenceUrl($media)); try { $metadata = $this->getMetadata($media, $url); @@ -125,7 +125,7 @@ public function getReferenceUrl(MediaInterface $media): string throw new \InvalidArgumentException('Unable to generate reference url for media without provider reference.'); } - return sprintf('https://vimeo.com/%s', $providerReference); + return \sprintf('https://vimeo.com/%s', $providerReference); } protected function fixBinaryContent(MediaInterface $media): void diff --git a/src/Provider/YouTubeProvider.php b/src/Provider/YouTubeProvider.php index fb202c3cf..c1703b25e 100644 --- a/src/Provider/YouTubeProvider.php +++ b/src/Provider/YouTubeProvider.php @@ -195,7 +195,7 @@ public function getHelperProperties(MediaInterface $media, string $format, array public function updateMetadata(MediaInterface $media, bool $force = false): void { - $url = sprintf('https://www.youtube.com/oembed?url=%s&format=json', $this->getReferenceUrl($media)); + $url = \sprintf('https://www.youtube.com/oembed?url=%s&format=json', $this->getReferenceUrl($media)); try { $metadata = $this->getMetadata($media, $url); @@ -231,7 +231,7 @@ public function getReferenceUrl(MediaInterface $media): string throw new \InvalidArgumentException('Unable to generate reference url for media without provider reference.'); } - return sprintf('https://www.youtube.com/watch?v=%s', $providerReference); + return \sprintf('https://www.youtube.com/watch?v=%s', $providerReference); } protected function doTransform(MediaInterface $media): void diff --git a/src/Resizer/CropResizer.php b/src/Resizer/CropResizer.php index f72764679..61888fb35 100755 --- a/src/Resizer/CropResizer.php +++ b/src/Resizer/CropResizer.php @@ -38,7 +38,7 @@ public function __construct( public function resize(MediaInterface $media, File $in, File $out, string $format, array $settings): void { if (!isset($settings['width'])) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'The "width" parameter is missing in context "%s" for provider "%s".', $media->getContext() ?? '', $media->getProviderName() ?? '' @@ -46,7 +46,7 @@ public function resize(MediaInterface $media, File $in, File $out, string $forma } if (!isset($settings['height'])) { - throw new \InvalidArgumentException(sprintf( + throw new \InvalidArgumentException(\sprintf( 'The "height" parameter is missing in context "%s" for provider "%s".', $media->getContext() ?? '', $media->getProviderName() ?? '' diff --git a/src/Resizer/SimpleResizer.php b/src/Resizer/SimpleResizer.php index 1ea98ae2c..9e312866a 100644 --- a/src/Resizer/SimpleResizer.php +++ b/src/Resizer/SimpleResizer.php @@ -33,7 +33,7 @@ public function __construct( public function resize(MediaInterface $media, File $in, File $out, string $format, array $settings): void { if (!isset($settings['width']) && !isset($settings['height'])) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'Width or height parameter is missing in context "%s" for provider "%s"', $media->getContext() ?? '', $media->getProviderName() ?? '' @@ -57,7 +57,7 @@ public function getBox(MediaInterface $media, array $settings): Box $height = $settings['height']; if (null === $width && null === $height) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'Width/Height parameter is missing in context "%s" for provider "%s". Please add at least one parameter.', $media->getContext() ?? '', $media->getProviderName() ?? '' diff --git a/src/Resizer/SquareResizer.php b/src/Resizer/SquareResizer.php index a2ab5ed56..ee92e2dbd 100755 --- a/src/Resizer/SquareResizer.php +++ b/src/Resizer/SquareResizer.php @@ -40,7 +40,7 @@ public function __construct( public function resize(MediaInterface $media, File $in, File $out, string $format, array $settings): void { if (!isset($settings['width'])) { - throw new \RuntimeException(sprintf( + throw new \RuntimeException(\sprintf( 'Width parameter is missing in context "%s" for provider "%s"', $media->getContext() ?? '', $media->getProviderName() ?? '' diff --git a/src/Thumbnail/FormatThumbnail.php b/src/Thumbnail/FormatThumbnail.php index 8eeb8b87c..662a629e6 100644 --- a/src/Thumbnail/FormatThumbnail.php +++ b/src/Thumbnail/FormatThumbnail.php @@ -43,7 +43,7 @@ public function hasResizer(string $id): bool public function getResizer(string $id): ResizerInterface { if (!isset($this->resizers[$id])) { - throw new \LogicException(sprintf('Resizer with id: "%s" is not attached.', $id)); + throw new \LogicException(\sprintf('Resizer with id: "%s" is not attached.', $id)); } return $this->resizers[$id]; @@ -61,7 +61,7 @@ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterfa throw new \InvalidArgumentException('Unable to generate public url for image without id.'); } - return sprintf('%s/thumb_%s_%s.%s', $provider->generatePath($media), $id, $format, $this->getExtension($media)); + return \sprintf('%s/thumb_%s_%s.%s', $provider->generatePath($media), $id, $format, $this->getExtension($media)); } public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterface $media, string $format): string @@ -76,7 +76,7 @@ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterf throw new \InvalidArgumentException('Unable to generate private url for image without id.'); } - return sprintf('%s/thumb_%s_%s.%s', $provider->generatePath($media), $id, $format, $this->getExtension($media)); + return \sprintf('%s/thumb_%s_%s.%s', $provider->generatePath($media), $id, $format, $this->getExtension($media)); } public function generate(MediaProviderInterface $provider, MediaInterface $media): void diff --git a/tests/App/Provider/TestProvider.php b/tests/App/Provider/TestProvider.php index cfef283b1..84fedcde8 100644 --- a/tests/App/Provider/TestProvider.php +++ b/tests/App/Provider/TestProvider.php @@ -63,7 +63,7 @@ public function getReferenceImage(MediaInterface $media): string throw new \InvalidArgumentException('Unable to generate reference image for media without provider reference.'); } - $this->prevReferenceImage = sprintf('%s/%s', $this->generatePath($media), $providerReference); + $this->prevReferenceImage = \sprintf('%s/%s', $this->generatePath($media), $providerReference); return $this->prevReferenceImage; } diff --git a/tests/Command/CleanMediaCommandTest.php b/tests/Command/CleanMediaCommandTest.php index 35aa40205..032dc6ae3 100755 --- a/tests/Command/CleanMediaCommandTest.php +++ b/tests/Command/CleanMediaCommandTest.php @@ -238,7 +238,7 @@ private function assertOutputFoundInContext( } } - static::assertTrue($found, sprintf( + static::assertTrue($found, \sprintf( 'Unable to find "%s" in "%s" with extractor "%s"', implode('", "', $expected), $output, diff --git a/tests/Fixtures/FilesystemTestCase.php b/tests/Fixtures/FilesystemTestCase.php index 4bdbcc0ee..933f38090 100644 --- a/tests/Fixtures/FilesystemTestCase.php +++ b/tests/Fixtures/FilesystemTestCase.php @@ -99,11 +99,11 @@ protected function tearDown(): void protected function assertFilePermissions(int $expectedFilePerms, string $filePath): void { - $actualFilePerms = (int) substr(sprintf('%o', fileperms($filePath)), -3); + $actualFilePerms = (int) substr(\sprintf('%o', fileperms($filePath)), -3); static::assertSame( $expectedFilePerms, $actualFilePerms, - sprintf('File permissions for %s must be %s. Actual %s', $filePath, $expectedFilePerms, $actualFilePerms) + \sprintf('File permissions for %s must be %s. Actual %s', $filePath, $expectedFilePerms, $actualFilePerms) ); } diff --git a/tests/Metadata/ProxyMetadataBuilderTest.php b/tests/Metadata/ProxyMetadataBuilderTest.php index 50498b164..fc55ce850 100644 --- a/tests/Metadata/ProxyMetadataBuilderTest.php +++ b/tests/Metadata/ProxyMetadataBuilderTest.php @@ -70,6 +70,7 @@ public function testProxyAmazon(): void ], 'region' => 'us-west-1', 'version' => '2006-03-01', + 'suppress_php_deprecation_warning' => true, ]); $adapter = new AwsS3($amazonclient, ''); $media = new Media(); @@ -137,6 +138,7 @@ public function testProxyReplicateWithAmazon(): void ], 'region' => 'us-west-1', 'version' => '2006-03-01', + 'suppress_php_deprecation_warning' => true, ]); $adapter = new Replicate( new AwsS3($amazonclient, ''),