From 2a69c86f79dc60fc993c91b8e794db2f2360baec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Vanvelthem?= Date: Sat, 5 Jan 2019 13:11:40 +0100 Subject: [PATCH] Prep 0.8.7 --- CHANGELOG.md | 14 ++++++++++++++ src/Video/Adapter/FFMpegAdapter.php | 6 ++++-- src/Video/Config/FFMpegConfig.php | 2 +- src/Video/Config/FFMpegConfigFactory.php | 6 ++---- src/Video/Config/FFProbeConfigFactory.php | 6 ++---- src/Video/Filter/SelectFilter.php | 2 +- src/Video/VideoAnalyzer.php | 2 +- src/Video/VideoConvertParamsInterface.php | 6 ++++-- src/Video/VideoConverter.php | 4 ++-- src/Video/VideoInfoReader.php | 2 +- src/Video/VideoThumbGenerator.php | 2 +- src/Video/VideoThumbParamsInterface.php | 6 ++++-- 12 files changed, 37 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 735af7b..d895c2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 0.8.7 (2019-01-05) + +### Fixed + +- Minor fix: `ConverterAdapterInterface` allowed `null` input file. + +### Changed + +- Minor phpdoc typehints tuning + +### Q&A + +- Added psalm to Q&A checks + ## 0.8.6 (2018-12-27) ### Improvement diff --git a/src/Video/Adapter/FFMpegAdapter.php b/src/Video/Adapter/FFMpegAdapter.php index 8e40f30..5c7062e 100644 --- a/src/Video/Adapter/FFMpegAdapter.php +++ b/src/Video/Adapter/FFMpegAdapter.php @@ -193,12 +193,14 @@ public function getMappedConversionParams(VideoConvertParamsInterface $conversio */ public function getCliCommand(array $arguments, string $inputFile, $outputFile = null, array $prependArguments = []): array { - $outputArg = ''; + $outputArg = null; if ($outputFile instanceof UnescapedFileInterface) { $outputArg = $outputFile->getFile(); } elseif (is_string($outputFile)) { $outputArg = $outputFile; - } elseif ($outputFile !== null) { + } + + if ($outputArg === null) { throw new InvalidArgumentException(sprintf( 'Output file must be either a non empty string, null or PlatformNullFile (type %s)', gettype($outputFile) diff --git a/src/Video/Config/FFMpegConfig.php b/src/Video/Config/FFMpegConfig.php index f20ee06..324dd70 100644 --- a/src/Video/Config/FFMpegConfig.php +++ b/src/Video/Config/FFMpegConfig.php @@ -22,7 +22,7 @@ class FFMpegConfig implements FFMpegConfigInterface /** @var int|null */ protected $threads; - /** @var FFMpegAdapter */ + /** @var FFMpegAdapter|null */ protected $ffmpegAdapter; /** @var ProcessParams */ diff --git a/src/Video/Config/FFMpegConfigFactory.php b/src/Video/Config/FFMpegConfigFactory.php index dc6236d..a42ca6d 100644 --- a/src/Video/Config/FFMpegConfigFactory.php +++ b/src/Video/Config/FFMpegConfigFactory.php @@ -4,9 +4,7 @@ namespace Soluble\MediaTools\Video\Config; -use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; -use Psr\Container\NotFoundExceptionInterface; use Soluble\MediaTools\Common\Config\SafeConfigReader; use Soluble\MediaTools\Common\Exception\InvalidConfigException; @@ -36,7 +34,7 @@ public function __invoke(ContainerInterface $container): FFMpegConfigInterface { try { $containerConfig = $container->get($this->entryName); - } catch (NotFoundExceptionInterface | ContainerExceptionInterface $e) { + } catch (\Throwable $e) { throw new InvalidConfigException( sprintf('Cannot resolve container entry \'%s\' ($entryName).', $this->entryName) ); @@ -50,7 +48,7 @@ public function __invoke(ContainerInterface $container): FFMpegConfigInterface ); } - $scr = new SafeConfigReader($config, $this->configKey ?? ''); + $scr = new SafeConfigReader($config, $this->configKey ?: ''); return new FFMpegConfig( $scr->getNullableString('ffmpeg.binary', null), diff --git a/src/Video/Config/FFProbeConfigFactory.php b/src/Video/Config/FFProbeConfigFactory.php index f02f7d6..be534fc 100644 --- a/src/Video/Config/FFProbeConfigFactory.php +++ b/src/Video/Config/FFProbeConfigFactory.php @@ -4,9 +4,7 @@ namespace Soluble\MediaTools\Video\Config; -use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerInterface; -use Psr\Container\NotFoundExceptionInterface; use Soluble\MediaTools\Common\Config\SafeConfigReader; use Soluble\MediaTools\Common\Exception\InvalidConfigException; @@ -36,7 +34,7 @@ public function __invoke(ContainerInterface $container): FFProbeConfigInterface { try { $containerConfig = $container->get($this->entryName); - } catch (NotFoundExceptionInterface | ContainerExceptionInterface $e) { + } catch (\Throwable $e) { throw new InvalidConfigException( sprintf('Cannot resolve container entry \'%s\' ($entryName).', $this->entryName) ); @@ -50,7 +48,7 @@ public function __invoke(ContainerInterface $container): FFProbeConfigInterface ); } - $scr = new SafeConfigReader($config, $this->configKey ?? ''); + $scr = new SafeConfigReader($config, $this->configKey ?: ''); return new FFProbeConfig( $scr->getNullableString('ffprobe.binary', null), diff --git a/src/Video/Filter/SelectFilter.php b/src/Video/Filter/SelectFilter.php index 769d460..d225131 100644 --- a/src/Video/Filter/SelectFilter.php +++ b/src/Video/Filter/SelectFilter.php @@ -28,7 +28,7 @@ public function getFFmpegCLIValue(): string { return sprintf( 'select=%s', - str_replace('"', '\"', $this->expression ?? '') + str_replace('"', '\"', $this->expression ?: '') ); } } diff --git a/src/Video/VideoAnalyzer.php b/src/Video/VideoAnalyzer.php index 6572fff..42dff97 100644 --- a/src/Video/VideoAnalyzer.php +++ b/src/Video/VideoAnalyzer.php @@ -21,7 +21,7 @@ class VideoAnalyzer implements VideoAnalyzerInterface /** @var FFMpegConfigInterface */ protected $ffmpegConfig; - /** @var LoggerInterface|NullLogger */ + /** @var LoggerInterface */ protected $logger; public function __construct(FFMpegConfigInterface $ffmpegConfig, ?LoggerInterface $logger = null) diff --git a/src/Video/VideoConvertParamsInterface.php b/src/Video/VideoConvertParamsInterface.php index 16a8e23..2b9ff97 100644 --- a/src/Video/VideoConvertParamsInterface.php +++ b/src/Video/VideoConvertParamsInterface.php @@ -5,8 +5,10 @@ namespace Soluble\MediaTools\Video; use Soluble\MediaTools\Common\Service\ActionParamInterface; +use Soluble\MediaTools\Video\Adapter\FFMpegCLIValueInterface; use Soluble\MediaTools\Video\Exception\InvalidArgumentException; use Soluble\MediaTools\Video\Exception\UnsetParamException; +use Soluble\MediaTools\Video\Filter\Type\VideoFilterInterface; interface VideoConvertParamsInterface extends ActionParamInterface { @@ -87,8 +89,8 @@ interface VideoConvertParamsInterface extends ActionParamInterface /** * Set a built-in param... * - * @param string $paramName a param that must exist in builtInParams - * @param mixed $paramValue + * @param string $paramName a param that must exist in builtInParams + * @param bool|string|int|VideoFilterInterface|FFMpegCLIValueInterface $paramValue * * @throws InvalidArgumentException in case of unsupported builtin param */ diff --git a/src/Video/VideoConverter.php b/src/Video/VideoConverter.php index e700629..ab1a16b 100644 --- a/src/Video/VideoConverter.php +++ b/src/Video/VideoConverter.php @@ -39,7 +39,7 @@ public function __construct(FFMpegConfigInterface $ffmpegConfig, ?LoggerInterfac { $this->ffmpegConfig = $ffmpegConfig; - $this->logger = $logger ?: new NullLogger(); + $this->logger = $logger ?? new NullLogger(); } /** @@ -72,7 +72,7 @@ public function getSymfonyProcess(string $inputFile, $outputFile, VideoConvertPa try { $ffmpegCmd = $adapter->getCliCommand($arguments, $inputFile, $outputFile); } catch (CommonException\InvalidArgumentException $e) { - throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e); + throw new InvalidArgumentException($e->getMessage(), (int) $e->getCode(), $e); } $pp = $processParams ?? $this->ffmpegConfig->getProcessParams(); diff --git a/src/Video/VideoInfoReader.php b/src/Video/VideoInfoReader.php index df0be0b..a96b327 100644 --- a/src/Video/VideoInfoReader.php +++ b/src/Video/VideoInfoReader.php @@ -28,7 +28,7 @@ class VideoInfoReader implements VideoInfoReaderInterface /** @var FFProbeConfigInterface */ protected $ffprobeConfig; - /** @var LoggerInterface|NullLogger */ + /** @var LoggerInterface */ protected $logger; public function __construct(FFProbeConfigInterface $ffProbeConfig, ?LoggerInterface $logger = null) diff --git a/src/Video/VideoThumbGenerator.php b/src/Video/VideoThumbGenerator.php index 69baeb5..c6e7e11 100644 --- a/src/Video/VideoThumbGenerator.php +++ b/src/Video/VideoThumbGenerator.php @@ -42,7 +42,7 @@ class VideoThumbGenerator implements VideoThumbGeneratorInterface /** @var int */ protected $defaultQualityScale; - /** @var LoggerInterface|NullLogger */ + /** @var LoggerInterface */ protected $logger; public function __construct(FFMpegConfigInterface $ffmpegConfig, ?LoggerInterface $logger = null, int $defaultQualityScale = self::DEFAULT_QUALITY_SCALE) diff --git a/src/Video/VideoThumbParamsInterface.php b/src/Video/VideoThumbParamsInterface.php index 4792299..b0bf10c 100644 --- a/src/Video/VideoThumbParamsInterface.php +++ b/src/Video/VideoThumbParamsInterface.php @@ -5,7 +5,9 @@ namespace Soluble\MediaTools\Video; use Soluble\MediaTools\Common\Service\ActionParamInterface; +use Soluble\MediaTools\Video\Adapter\FFMpegCLIValueInterface; use Soluble\MediaTools\Video\Exception\InvalidArgumentException; +use Soluble\MediaTools\Video\Filter\Type\VideoFilterInterface; interface VideoThumbParamsInterface extends ActionParamInterface { @@ -31,8 +33,8 @@ interface VideoThumbParamsInterface extends ActionParamInterface /** * Set a built-in param... * - * @param string $paramName a param that must exist in builtInParams - * @param mixed $paramValue + * @param string $paramName a param that must exist in builtInParams + * @param bool|string|int|VideoFilterInterface|FFMpegCLIValueInterface $paramValue * * @throws InvalidArgumentException in case of unsupported builtin param */