diff --git a/.gitignore b/.gitignore index 368d57f76..15142fc65 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.idea/ /.php_cs.cache +/.php-cs-fixer.cache /.phpunit.result.cache /bin/ /composer.lock diff --git a/doc/post-processors/jpeg-optim.rst b/doc/post-processors/jpeg-optim.rst index 9733ac64f..c33a1d027 100644 --- a/doc/post-processors/jpeg-optim.rst +++ b/doc/post-processors/jpeg-optim.rst @@ -21,7 +21,7 @@ To add this post-processor to the filter set created in the thumbnail: { size: [120, 90], mode: outbound } background: { size: [124, 94], position: center, color: '#000' } post_processors: - jpegoptim: { strip_all: true, max: 70, progressive: true } + jpegoptim: { strip_all: true, quality: 70, progressive: true } This configuration enables metadata stripping and progressive JPEG encoding, and sets a maximum quality factor of 70 for the resulting image binary. @@ -45,7 +45,7 @@ Options **strip_all:** ``bool`` Removes all comments, EXIF markers, and other image metadata. -**max:** ``int`` +**quality:** ``int`` Sets the maximum image quality factor. **progressive:** ``bool`` @@ -58,7 +58,7 @@ Parameters **liip_imagine.jpegoptim.stripAll:** ``bool`` Removes all comments, EXIF markers, and other metadata from the image binary. -**liip_imagine.jpegoptim.max:** ``int`` +**liip_imagine.jpegoptim.quality:** ``int`` Assigns the maximum quality factor for the image binary. **liip_imagine.jpegoptim.progressive:** ``bool`` diff --git a/doc/post-processors/png-opti.rst b/doc/post-processors/png-opti.rst index e90b1c179..0c3c91799 100644 --- a/doc/post-processors/png-opti.rst +++ b/doc/post-processors/png-opti.rst @@ -21,7 +21,7 @@ To add this post-processor to the filter set created in the thumbnail: { size: [120, 90], mode: outbound } background: { size: [124, 94], position: center, color: '#000' } post_processors: - optipng: { strip_all: true, level: 5 } + optipng: { strip: true, level: 5 } This configuration enables metadata stripping, and sets a maximum optimization factor of 5 for the resulting image binary. @@ -77,7 +77,7 @@ Options Parameters ---------- -**liip_imagine.optipng.stripAll:** ``bool`` +**liip_imagine.optipng.strip:** ``bool`` Removes all comments, EXIF markers, and other metadata from the image binary. **liip_imagine.optipng.level:** ``int`` diff --git a/doc/post-processors/png-quant.rst b/doc/post-processors/png-quant.rst index d7ead67ce..f9f93b546 100644 --- a/doc/post-processors/png-quant.rst +++ b/doc/post-processors/png-quant.rst @@ -21,7 +21,7 @@ To add this post-processor to the filter set created in the thumbnail: { size: [120, 90], mode: outbound } background: { size: [124, 94], position: center, color: '#000' } post_processors: - pngquant: { quality: "75-85" } + pngquant: { quality: [75, 85] } This configuration sets a quality factor range of 75 to 85 for the resulting image binary. diff --git a/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php index 42b8e2497..a20484f1f 100644 --- a/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/AbstractPostProcessor.php @@ -129,11 +129,4 @@ protected function isSuccessfulProcess(Process $process, array $validReturns = [ return true; } - - protected function triggerSetterMethodDeprecation(string $method): void - { - @trigger_error(sprintf('The %s() method was deprecated in 2.2 and will be removed in 3.0. You must ' - .'setup the class state via its __construct() method. You can still pass filter-specific options to the '. - 'process() method to overwrite behavior.', $method), E_USER_DEPRECATED); - } } diff --git a/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php index 5a66f6d79..1381de758 100644 --- a/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php @@ -55,54 +55,6 @@ public function __construct($executablePath = '/usr/bin/jpegoptim', $strip = tru $this->progressive = $progressive; } - /** - * @deprecated All post-processor setters have been deprecated in 2.2 for removal in 3.0. You must only use the - * class's constructor to set the property state. - * - * @param int $maxQuality - * - * @return JpegOptimPostProcessor - */ - public function setMax($maxQuality) - { - $this->triggerSetterMethodDeprecation(__METHOD__); - $this->quality = $maxQuality; - - return $this; - } - - /** - * @deprecated All post-processor setters have been deprecated in 2.2 for removal in 3.0. You must only use the - * class's constructor to set the property state. - * - * @param bool $progressive - * - * @return JpegOptimPostProcessor - */ - public function setProgressive($progressive) - { - $this->triggerSetterMethodDeprecation(__METHOD__); - $this->progressive = $progressive; - - return $this; - } - - /** - * @deprecated All post-processor setters have been deprecated in 2.2 for removal in 3.0. You must only use the - * class's constructor to set the property state. - * - * @param bool $strip - * - * @return JpegOptimPostProcessor - */ - public function setStripAll($strip) - { - $this->triggerSetterMethodDeprecation(__METHOD__); - $this->strip = $strip; - - return $this; - } - /* * @throws ProcessFailedException */ @@ -144,17 +96,6 @@ private function getProcessArguments(array $options = []): array $arguments[] = '--strip-all'; } - if (isset($options['max'])) { - @trigger_error('The "max" option was deprecated in 2.2 and will be removed in 3.0. '. - 'Instead, use the "quality" option.', E_USER_DEPRECATED); - - if (isset($options['quality'])) { - throw new InvalidOptionException('the "max" and "quality" options cannot both be set', $options); - } - - $options['quality'] = $options['max']; - } - if ($quality = $options['quality'] ?? $this->quality) { if (!\in_array($quality, range(0, 100), true)) { throw new InvalidOptionException('the "quality" option must be an int between 0 and 100', $options); diff --git a/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php b/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php index 62e250e56..afc77a75f 100644 --- a/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/MozJpegPostProcessor.php @@ -41,22 +41,6 @@ public function __construct($executablePath = '/opt/mozjpeg/bin/cjpeg', $quality $this->quality = $quality; } - /** - * @deprecated All post-processor setters have been deprecated in 2.2 for removal in 3.0. You must only use the - * class's constructor to set the property state. - * - * @param int $quality - * - * @return MozJpegPostProcessor - */ - public function setQuality($quality) - { - $this->triggerSetterMethodDeprecation(__METHOD__); - $this->quality = $quality; - - return $this; - } - /* * @throws ProcessFailedException */ diff --git a/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php index b43d8baa3..0feb46cf0 100644 --- a/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/OptiPngPostProcessor.php @@ -91,17 +91,6 @@ private function getProcessArguments(array $options = []): array $arguments[] = sprintf('-o%d', $level); } - if (isset($options['strip_all'])) { - @trigger_error('The "strip_all" option was deprecated in 2.2 and will be removed in 3.0. '. - 'Instead, use the "strip" option.', E_USER_DEPRECATED); - - if (isset($options['strip'])) { - throw new InvalidOptionException('the "strip" and "strip_all" options cannot both be set', $options); - } - - $options['strip'] = $options['strip_all']; - } - if ($strip = $options['strip'] ?? $this->strip) { $arguments[] = '-strip'; $arguments[] = true === $strip ? 'all' : $strip; diff --git a/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php b/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php index f10b1f6df..73bc84773 100644 --- a/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php +++ b/src/Imagine/Filter/PostProcessor/PngquantPostProcessor.php @@ -43,22 +43,6 @@ public function __construct($executablePath = '/usr/bin/pngquant', $quality = [8 $this->quality = $quality; } - /** - * @deprecated All post-processor setters have been deprecated in 2.2 for removal in 3.0. You must only use the - * class's constructor to set the property state. - * - * @param string $quality - * - * @return PngquantPostProcessor - */ - public function setQuality($quality) - { - $this->triggerSetterMethodDeprecation(__METHOD__); - $this->quality = $quality; - - return $this; - } - /* * @throws ProcessFailedException */ @@ -91,16 +75,6 @@ private function getProcessArguments(array $options = []): array $arguments = [$this->executablePath]; if ($quality = $options['quality'] ?? $this->quality) { - if (\is_string($quality) && false !== mb_strpos($quality, '-')) { - @trigger_error('Passing the "quality" option as a string was deprecated in 2.2 and '. - 'will be removed in 3.0. Instead, pass wither an integer representing the max value or an array '. - 'representing the minimum and maximum values.', E_USER_DEPRECATED); - - $quality = array_map(function ($q) { - return (int) $q; - }, explode('-', $quality)); - } - if (!\is_array($quality)) { $quality = [0, (int) $quality]; } diff --git a/tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php b/tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php index 2903cd810..f1dabdd60 100644 --- a/tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php +++ b/tests/Imagine/Filter/PostProcessor/JpegOptimPostProcessorTest.php @@ -23,33 +23,6 @@ */ class JpegOptimPostProcessorTest extends AbstractPostProcessorTestCase { - /** - * @group legacy - * @expectedDeprecation The %s::setMax() method was deprecated in %s and will be removed in %s. You must setup the class state via its __construct() method. You can still pass filter-specific options to the process() method to overwrite behavior. - */ - public function testDeprecatedSetMaxMethod(): void - { - $this->getPostProcessorInstance()->setMax(50); - } - - /** - * @group legacy - * @expectedDeprecation The %s::setProgressive() method was deprecated in %s and will be removed in %s. You must setup the class state via its __construct() method. You can still pass filter-specific options to the process() method to overwrite behavior. - */ - public function testDeprecatedSetProgressiveMethod(): void - { - $this->getPostProcessorInstance()->setProgressive(50); - } - - /** - * @group legacy - * @expectedDeprecation The %s::setStripAll() method was deprecated in %s and will be removed in %s. You must setup the class state via its __construct() method. You can still pass filter-specific options to the process() method to overwrite behavior. - */ - public function testDeprecatedSetStripAllMethod(): void - { - $this->getPostProcessorInstance()->setStripAll(50); - } - public function testInvalidLevelOption(): void { $this->expectException(InvalidOptionException::class); @@ -58,29 +31,6 @@ public function testInvalidLevelOption(): void $this->getProcessArguments(['quality' => 1000]); } - /** - * @group legacy - * - * @expectedDeprecation The "max" option was deprecated in %s and will be removed in %s. Instead, use the "quality" option. - */ - public function testOptionThrowsWhenBothMaxAndQualityAreSet(): void - { - $this->expectException(InvalidOptionException::class); - $this->expectExceptionMessage('the "max" and "quality" options cannot both be set'); - - $this->getProcessArguments(['max' => 50, 'quality' => 50]); - } - - /** - * @group legacy - * - * @expectedDeprecation The "max" option was deprecated in %s and will be removed in %s. Instead, use the "quality" option. - */ - public function testInvalidStripDeprecationMessage(): void - { - $this->assertContains('--max=50', $this->getProcessArguments(['max' => 50])); - } - public static function provideProcessArgumentsData(): array { $data = [ diff --git a/tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php b/tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php index 3393cc44d..d3703b0de 100644 --- a/tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php +++ b/tests/Imagine/Filter/PostProcessor/MozJpegPostProcessorTest.php @@ -22,16 +22,6 @@ */ class MozJpegPostProcessorTest extends AbstractPostProcessorTestCase { - /** - * @group legacy - * - * @expectedDeprecation The %s::setQuality() method was deprecated in %s and will be removed in %s. You must setup the class state via its __construct() method. You can still pass filter-specific options to the process() method to overwrite behavior. - */ - public function testDeprecatedSetQualityMethod(): void - { - $this->getPostProcessorInstance()->setQuality(50); - } - public static function provideProcessArgumentsData(): array { $data = [ diff --git a/tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php b/tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php index d1cc817a3..81150457c 100644 --- a/tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php +++ b/tests/Imagine/Filter/PostProcessor/OptiPngPostProcessorTest.php @@ -39,32 +39,6 @@ public function testInvalidInterlaceOption(): void $this->getProcessArguments(['interlace_type' => 10]); } - /** - * @group legacy - * - * @expectedDeprecation The "strip_all" option was deprecated in %s and will be removed in %s. Instead, use the "strip" option. - */ - public function testInvalidStripOptionAndDeprecation(): void - { - $this->expectException(InvalidOptionException::class); - $this->expectExceptionMessage('the "strip" and "strip_all" options cannot both be set'); - - $this->getProcessArguments(['strip_all' => true, 'strip' => 'all']); - } - - /** - * @group legacy - * - * @expectedDeprecation The "strip_all" option was deprecated in %s and will be removed in %s. Instead, use the "strip" option. - */ - public function testInvalidStripDeprecationMessage(): void - { - $arguments = $this->getProcessArguments(['strip_all' => true]); - - $this->assertSame('all', array_pop($arguments)); - $this->assertSame('-strip', array_pop($arguments)); - } - public static function provideSetupProcessBuilderData(): array { $data = [ diff --git a/tests/Imagine/Filter/PostProcessor/PngquantPostProcessorTest.php b/tests/Imagine/Filter/PostProcessor/PngquantPostProcessorTest.php index b8737129b..1262f6e76 100644 --- a/tests/Imagine/Filter/PostProcessor/PngquantPostProcessorTest.php +++ b/tests/Imagine/Filter/PostProcessor/PngquantPostProcessorTest.php @@ -23,26 +23,6 @@ */ class PngquantPostProcessorTest extends AbstractPostProcessorTestCase { - /** - * @group legacy - * - * @expectedDeprecation The %s::setQuality() method was deprecated in %s and will be removed in %s. You must setup the class state via its __construct() method. You can still pass filter-specific options to the process() method to overwrite behavior. - */ - public function testDeprecatedSetQualityMethod(): void - { - $this->getPostProcessorInstance()->setQuality(50); - } - - /** - * @group legacy - * - * @expectedDeprecation Passing the "quality" option as a string was deprecated in %s and will be removed in %s. Instead, pass wither an integer representing the max value or an array representing the minimum and maximum values. - */ - public function testQualityOptionDeprecation(): void - { - $this->getProcessArguments(['quality' => '0-100']); - } - public function testQualityOptionThrowsOnLargerMinThanMaxValue(): void { $this->expectException(InvalidOptionException::class);