diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 57344cb..5288a1d 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -18,6 +18,7 @@ ->setRiskyAllowed(true) ->setRules([ '@PSR12' => true, + '@Symfony' => true, 'declare_strict_types' => true, 'header_comment' => ['header' => $licence], ]) diff --git a/config/services.php b/config/services.php index c53ab81..213c580 100644 --- a/config/services.php +++ b/config/services.php @@ -14,15 +14,14 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; use Sensiolabs\MinifyBundle\AssetMapper\MinifierCompiler; -use Sensiolabs\MinifyBundle\Command\MinifyInstallCommand; use Sensiolabs\MinifyBundle\Command\MinifyAssetCommand; +use Sensiolabs\MinifyBundle\Command\MinifyInstallCommand; use Sensiolabs\MinifyBundle\Minifier\MinifierInterface; use Sensiolabs\MinifyBundle\Minify; use Sensiolabs\MinifyBundle\MinifyFactory; use Sensiolabs\MinifyBundle\MinifyInstaller; return static function (ContainerConfigurator $container) { - $container->services() ->set('.sensiolabs_minify.minifier.minify_installer', MinifyInstaller::class) diff --git a/src/AssetMapper/MinifierCompiler.php b/src/AssetMapper/MinifierCompiler.php index a30be60..9c4e72d 100644 --- a/src/AssetMapper/MinifierCompiler.php +++ b/src/AssetMapper/MinifierCompiler.php @@ -25,7 +25,6 @@ final class MinifierCompiler implements AssetCompilerInterface { /** - * @param MinifierInterface $minify * @param list $extensions * @param list $ignorePaths */ @@ -58,10 +57,10 @@ public function supports(MappedAsset $asset): bool public function compile(string $content, MappedAsset $asset, AssetMapperInterface $assetMapper): string { - $type = match($extension = $asset->publicExtension) { + $type = match ($extension = $asset->publicExtension) { 'css', 'scss' => 'css', 'js' => 'js', - default => throw new RuntimeException(sprintf('Invalid type "%s".', $extension)) + default => throw new RuntimeException(sprintf('Invalid type "%s".', $extension)), }; return $this->minify->minify($content, $type); diff --git a/src/Command/MinifyAssetCommand.php b/src/Command/MinifyAssetCommand.php index 959697b..fb532fb 100644 --- a/src/Command/MinifyAssetCommand.php +++ b/src/Command/MinifyAssetCommand.php @@ -79,6 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } if (!$fs->exists($inputArg)) { $io->error(sprintf('Cannot read file "%s".', $inputArg)); + return Command::FAILURE; } @@ -96,6 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (null === $outputArg) { $io->text($output); + return Command::SUCCESS; } @@ -104,6 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $fs->dumpFile($outputArg, $output); } catch (IOException) { $io->error(sprintf('Cannot write to file "%s".', $outputArg)); + return Command::FAILURE; } diff --git a/src/Minifier/MinifierInstallerInterface.php b/src/Minifier/MinifierInstallerInterface.php index 94dae68..79a83c6 100644 --- a/src/Minifier/MinifierInstallerInterface.php +++ b/src/Minifier/MinifierInstallerInterface.php @@ -29,12 +29,12 @@ interface MinifierInstallerInterface public function install(string $version = self::VERSION_LATEST, bool $force = false): void; /** - * @return bool Whether the binary is installed + * @return bool Whether the binary is installed */ public function isInstalled(): bool; /** - * @return string The path to the installed binary + * @return string The path to the installed binary */ public function getInstallBinaryPath(): string; } diff --git a/src/Minifier/MinifierInterface.php b/src/Minifier/MinifierInterface.php index b477ac5..a855ffa 100644 --- a/src/Minifier/MinifierInterface.php +++ b/src/Minifier/MinifierInterface.php @@ -22,9 +22,7 @@ interface MinifierInterface public const TYPE_JS = 'js'; /** - * @param string $input * @param self::TYPE_CSS|self::TYPE_JS $type - * @return string */ public function minify(string $input, string $type): string; } diff --git a/src/MinifyInstaller.php b/src/MinifyInstaller.php index 18aac31..b5bafef 100644 --- a/src/MinifyInstaller.php +++ b/src/MinifyInstaller.php @@ -122,5 +122,4 @@ private function getReleaseAsset(string $version): array throw new InstallException(sprintf('Unable to find a binary for release "%s".', $version)); } - } diff --git a/src/SensiolabsMinifyBundle.php b/src/SensiolabsMinifyBundle.php index 767c5ca..b66392c 100644 --- a/src/SensiolabsMinifyBundle.php +++ b/src/SensiolabsMinifyBundle.php @@ -13,18 +13,12 @@ namespace Sensiolabs\MinifyBundle; -use Sensiolabs\MinifyBundle\AssetMapper\MinifierCompiler; -use Sensiolabs\MinifyBundle\Command\MinifyAssetCommand; -use Sensiolabs\MinifyBundle\Command\MinifyInstallCommand; -use Sensiolabs\MinifyBundle\Minifier\MinifierInterface; use Sensiolabs\MinifyBundle\Minifier\TraceableMinifier; use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Bundle\AbstractBundle; -use function Symfony\Component\DependencyInjection\Loader\Configurator\abstract_arg; use function Symfony\Component\DependencyInjection\Loader\Configurator\param; use function Symfony\Component\DependencyInjection\Loader\Configurator\service; diff --git a/tests/EventListener/PreAssetsCompileEventListenerTest.php b/tests/EventListener/PreAssetsCompileEventListenerTest.php index b5357b4..8ef8572 100644 --- a/tests/EventListener/PreAssetsCompileEventListenerTest.php +++ b/tests/EventListener/PreAssetsCompileEventListenerTest.php @@ -14,8 +14,8 @@ namespace Sensiolabs\MinifyBundle\Tests\EventListener; use PHPUnit\Framework\Attributes\CoversClass; -use Sensiolabs\MinifyBundle\EventListener\PreAssetsCompileEventListener; use PHPUnit\Framework\TestCase; +use Sensiolabs\MinifyBundle\EventListener\PreAssetsCompileEventListener; use Sensiolabs\MinifyBundle\Minifier\MinifierInstallerInterface; use Symfony\Component\AssetMapper\Event\PreAssetsCompileEvent; use Symfony\Component\Console\Output\NullOutput; diff --git a/tests/Fixtures/MinifyBundleTestKernel.php b/tests/Fixtures/MinifyBundleTestKernel.php index 85db7ca..e832563 100644 --- a/tests/Fixtures/MinifyBundleTestKernel.php +++ b/tests/Fixtures/MinifyBundleTestKernel.php @@ -35,12 +35,12 @@ public function registerBundles(): iterable return [ new FrameworkBundle(), new SensiolabsMinifyBundle(), - new class () extends Bundle { + new class extends Bundle { public function shutdown(): void { restore_exception_handler(); } - } + }, ]; } diff --git a/tests/Minifier/SystemUtilsTest.php b/tests/Minifier/SystemUtilsTest.php index c038064..f306f6c 100644 --- a/tests/Minifier/SystemUtilsTest.php +++ b/tests/Minifier/SystemUtilsTest.php @@ -14,8 +14,8 @@ namespace Sensiolabs\MinifyBundle\Tests\Minifier; use PHPUnit\Framework\Attributes\CoversClass; -use Sensiolabs\MinifyBundle\Minifier\SystemUtils; use PHPUnit\Framework\TestCase; +use Sensiolabs\MinifyBundle\Minifier\SystemUtils; #[CoversClass(SystemUtils::class)] class SystemUtilsTest extends TestCase @@ -55,5 +55,4 @@ public function testMatchReturnsFalseForNonMatchingArchitecture() $releaseUtils = new SystemUtils('linux', 'amd64'); $this->assertFalse($releaseUtils->match('linux-arm64')); } - } diff --git a/tests/Minifier/TraceableMinifierTest.php b/tests/Minifier/TraceableMinifierTest.php index 244b1a8..b75b2a2 100644 --- a/tests/Minifier/TraceableMinifierTest.php +++ b/tests/Minifier/TraceableMinifierTest.php @@ -14,10 +14,10 @@ namespace Sensiolabs\MinifyBundle\Tests\Minifier; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; use Sensiolabs\MinifyBundle\Minifier\MinifierInterface; use Sensiolabs\MinifyBundle\Minifier\TraceableMinifier; -use PHPUnit\Framework\TestCase; #[CoversClass(TraceableMinifier::class)] class TraceableMinifierTest extends TestCase