From 773d73c7a8e5397ad6fe82cc584b3af1e05744e3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 2 Nov 2024 14:20:41 +0700 Subject: [PATCH 01/27] Update to latest PHP 8.1 syntax Signed-off-by: Abdul Malik Ikhsan --- src/AbstractFilter.php | 5 +- src/Compress/Zip.php | 99 +++++-------------- src/FilterChain.php | 2 +- src/FilterInterface.php | 3 +- src/ForceUriScheme.php | 2 +- src/Inflector.php | 5 +- test/CallbackTest.php | 2 +- test/FilterPluginManagerCompatibilityTest.php | 6 +- test/StaticAnalysis/PluginRetrieval.php | 2 +- 9 files changed, 37 insertions(+), 89 deletions(-) diff --git a/src/AbstractFilter.php b/src/AbstractFilter.php index 060463ce..01562786 100644 --- a/src/AbstractFilter.php +++ b/src/AbstractFilter.php @@ -9,10 +9,9 @@ use function array_key_exists; use function array_map; -use function gettype; +use function get_debug_type; use function is_array; use function is_iterable; -use function is_object; use function is_scalar; use function is_string; use function method_exists; @@ -56,7 +55,7 @@ public function setOptions($options) throw new Exception\InvalidArgumentException(sprintf( '"%s" expects an array or Traversable; received "%s"', __METHOD__, - is_object($options) ? $options::class : gettype($options) + get_debug_type($options) )); } diff --git a/src/Compress/Zip.php b/src/Compress/Zip.php index 080a2f32..6d6a21f5 100644 --- a/src/Compress/Zip.php +++ b/src/Compress/Zip.php @@ -245,79 +245,32 @@ public function decompress($content) */ public function errorString($error) { - switch ($error) { - case ZipArchive::ER_MULTIDISK: - return 'Multidisk ZIP Archives not supported'; - - case ZipArchive::ER_RENAME: - return 'Failed to rename the temporary file for ZIP'; - - case ZipArchive::ER_CLOSE: - return 'Failed to close the ZIP Archive'; - - case ZipArchive::ER_SEEK: - return 'Failure while seeking the ZIP Archive'; - - case ZipArchive::ER_READ: - return 'Failure while reading the ZIP Archive'; - - case ZipArchive::ER_WRITE: - return 'Failure while writing the ZIP Archive'; - - case ZipArchive::ER_CRC: - return 'CRC failure within the ZIP Archive'; - - case ZipArchive::ER_ZIPCLOSED: - return 'ZIP Archive already closed'; - - case ZipArchive::ER_NOENT: - return 'No such file within the ZIP Archive'; - - case ZipArchive::ER_EXISTS: - return 'ZIP Archive already exists'; - - case ZipArchive::ER_OPEN: - return 'Can not open ZIP Archive'; - - case ZipArchive::ER_TMPOPEN: - return 'Failure creating temporary ZIP Archive'; - - case ZipArchive::ER_ZLIB: - return 'ZLib Problem'; - - case ZipArchive::ER_MEMORY: - return 'Memory allocation problem while working on a ZIP Archive'; - - case ZipArchive::ER_CHANGED: - return 'ZIP Entry has been changed'; - - case ZipArchive::ER_COMPNOTSUPP: - return 'Compression method not supported within ZLib'; - - case ZipArchive::ER_EOF: - return 'Premature EOF within ZIP Archive'; - - case ZipArchive::ER_INVAL: - return 'Invalid argument for ZLIB'; - - case ZipArchive::ER_NOZIP: - return 'Given file is no zip archive'; - - case ZipArchive::ER_INTERNAL: - return 'Internal error while working on a ZIP Archive'; - - case ZipArchive::ER_INCONS: - return 'Inconsistent ZIP archive'; - - case ZipArchive::ER_REMOVE: - return 'Can not remove ZIP Archive'; - - case ZipArchive::ER_DELETED: - return 'ZIP Entry has been deleted'; - - default: - return 'Unknown error within ZIP Archive'; - } + return match ($error) { + ZipArchive::ER_MULTIDISK => 'Multidisk ZIP Archives not supported', + ZipArchive::ER_RENAME => 'Failed to rename the temporary file for ZIP', + ZipArchive::ER_CLOSE => 'Failed to close the ZIP Archive', + ZipArchive::ER_SEEK => 'Failure while seeking the ZIP Archive', + ZipArchive::ER_READ => 'Failure while reading the ZIP Archive', + ZipArchive::ER_WRITE => 'Failure while writing the ZIP Archive', + ZipArchive::ER_CRC => 'CRC failure within the ZIP Archive', + ZipArchive::ER_ZIPCLOSED => 'ZIP Archive already closed', + ZipArchive::ER_NOENT => 'No such file within the ZIP Archive', + ZipArchive::ER_EXISTS => 'ZIP Archive already exists', + ZipArchive::ER_OPEN => 'Can not open ZIP Archive', + ZipArchive::ER_TMPOPEN => 'Failure creating temporary ZIP Archive', + ZipArchive::ER_ZLIB => 'ZLib Problem', + ZipArchive::ER_MEMORY => 'Memory allocation problem while working on a ZIP Archive', + ZipArchive::ER_CHANGED => 'ZIP Entry has been changed', + ZipArchive::ER_COMPNOTSUPP => 'Compression method not supported within ZLib', + ZipArchive::ER_EOF => 'Premature EOF within ZIP Archive', + ZipArchive::ER_INVAL => 'Invalid argument for ZLIB', + ZipArchive::ER_NOZIP => 'Given file is no zip archive', + ZipArchive::ER_INTERNAL => 'Internal error while working on a ZIP Archive', + ZipArchive::ER_INCONS => 'Inconsistent ZIP archive', + ZipArchive::ER_REMOVE => 'Can not remove ZIP Archive', + ZipArchive::ER_DELETED => 'ZIP Entry has been deleted', + default => 'Unknown error within ZIP Archive', + }; } /** diff --git a/src/FilterChain.php b/src/FilterChain.php index 8343becb..c1355e3a 100644 --- a/src/FilterChain.php +++ b/src/FilterChain.php @@ -178,7 +178,7 @@ public function attach($callback, $priority = self::DEFAULT_PRIORITY) get_debug_type($callback) )); } - $callback = [$callback, 'filter']; + $callback = $callback->filter(...); } $this->filters->insert($callback, $priority); return $this; diff --git a/src/FilterInterface.php b/src/FilterInterface.php index 6e75bff8..2fa1c6a4 100644 --- a/src/FilterInterface.php +++ b/src/FilterInterface.php @@ -9,9 +9,8 @@ interface FilterInterface /** * Returns the result of filtering $value * - * @param mixed $value * @throws Exception\RuntimeException If filtering $value is impossible. * @return mixed */ - public function filter($value); + public function filter(mixed $value); } diff --git a/src/ForceUriScheme.php b/src/ForceUriScheme.php index 01140131..c2b17778 100644 --- a/src/ForceUriScheme.php +++ b/src/ForceUriScheme.php @@ -22,7 +22,7 @@ final class ForceUriScheme implements FilterInterface private const DEFAULT_SCHEME = 'https'; /** @var non-empty-string */ - private string $scheme; + private readonly string $scheme; /** @param Options $options */ public function __construct(array $options = ['scheme' => self::DEFAULT_SCHEME]) diff --git a/src/Inflector.php b/src/Inflector.php index 27c83c5d..14fe7079 100644 --- a/src/Inflector.php +++ b/src/Inflector.php @@ -290,10 +290,7 @@ public function getRules($spec = null) { if (null !== $spec) { $spec = $this->_normalizeSpec($spec); - if (isset($this->rules[$spec])) { - return $this->rules[$spec]; - } - return false; + return $this->rules[$spec] ?? false; } return $this->rules; diff --git a/test/CallbackTest.php b/test/CallbackTest.php index 4779de68..1d125e1e 100644 --- a/test/CallbackTest.php +++ b/test/CallbackTest.php @@ -29,7 +29,7 @@ public function testConstructorWithOptions(): void public function testStaticCallback(): void { $filter = new CallbackFilter( - [CallbackClass::class, 'staticCallback'] + CallbackClass::staticCallback(...) ); self::assertSame('staticCallback-test', $filter('test')); } diff --git a/test/FilterPluginManagerCompatibilityTest.php b/test/FilterPluginManagerCompatibilityTest.php index f32d9b65..f2c94ad6 100644 --- a/test/FilterPluginManagerCompatibilityTest.php +++ b/test/FilterPluginManagerCompatibilityTest.php @@ -14,7 +14,7 @@ use ReflectionProperty; use function in_array; -use function strpos; +use function str_contains; class FilterPluginManagerCompatibilityTest extends TestCase { @@ -73,12 +73,12 @@ public static function aliasProvider(): Generator self::assertIsString($alias); self::assertIsString($target); // Skipping as laminas-i18n is not required by this package - if (strpos($target, '\\I18n\\') !== false) { + if (str_contains($target, '\\I18n\\')) { continue; } // Skipping as it has required options - if (strpos($target, 'DataUnitFormatter') !== false) { + if (str_contains($target, 'DataUnitFormatter')) { continue; } diff --git a/test/StaticAnalysis/PluginRetrieval.php b/test/StaticAnalysis/PluginRetrieval.php index 1778fde3..c1477639 100644 --- a/test/StaticAnalysis/PluginRetrieval.php +++ b/test/StaticAnalysis/PluginRetrieval.php @@ -10,7 +10,7 @@ /** @psalm-suppress UnusedClass */ final class PluginRetrieval { - public function __construct(private FilterPluginManager $pluginManager) + public function __construct(private readonly FilterPluginManager $pluginManager) { } From af7e2988ce90f6fe6ff9a5b31f45b851e5a8ff75 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 2 Nov 2024 14:27:19 +0700 Subject: [PATCH 02/27] Fix @param to be int as error is int Signed-off-by: Abdul Malik Ikhsan --- src/Compress/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compress/Zip.php b/src/Compress/Zip.php index 6d6a21f5..453338cd 100644 --- a/src/Compress/Zip.php +++ b/src/Compress/Zip.php @@ -240,7 +240,7 @@ public function decompress($content) /** * Returns the proper string based on the given error constant * - * @param string $error + * @param int $error * @return string */ public function errorString($error) From d78eebc0cc115f7ee93f7d442a6b1d8544be7bb0 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 2 Nov 2024 14:33:14 +0700 Subject: [PATCH 03/27] Fix possibly false value on errorString parameter Signed-off-by: Abdul Malik Ikhsan --- src/Compress/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compress/Zip.php b/src/Compress/Zip.php index 453338cd..aa574392 100644 --- a/src/Compress/Zip.php +++ b/src/Compress/Zip.php @@ -240,7 +240,7 @@ public function decompress($content) /** * Returns the proper string based on the given error constant * - * @param int $error + * @param int|false $error * @return string */ public function errorString($error) From b7ae47f7b0d43393c8c65df6d3abd3c883a2fab9 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 2 Nov 2024 14:40:39 +0700 Subject: [PATCH 04/27] Fix psalm mixed param override Signed-off-by: Abdul Malik Ikhsan --- src/FilterInterface.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FilterInterface.php b/src/FilterInterface.php index 2fa1c6a4..6e75bff8 100644 --- a/src/FilterInterface.php +++ b/src/FilterInterface.php @@ -9,8 +9,9 @@ interface FilterInterface /** * Returns the result of filtering $value * + * @param mixed $value * @throws Exception\RuntimeException If filtering $value is impossible. * @return mixed */ - public function filter(mixed $value); + public function filter($value); } From a7e47b5d525acbe33e293689cfeb51f4a7ac6b92 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 2 Nov 2024 14:48:44 +0700 Subject: [PATCH 05/27] regenerate psalm baseline Signed-off-by: Abdul Malik Ikhsan --- psalm-baseline.xml | 14 -------------- src/Inflector.php | 5 ++++- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d59c5237..d0aee7ed 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -25,9 +25,6 @@ - - - @@ -37,9 +34,6 @@ options]]> - - - @@ -394,13 +388,6 @@ - - - - - - - @@ -2078,7 +2065,6 @@ - diff --git a/src/Inflector.php b/src/Inflector.php index 14fe7079..27c83c5d 100644 --- a/src/Inflector.php +++ b/src/Inflector.php @@ -290,7 +290,10 @@ public function getRules($spec = null) { if (null !== $spec) { $spec = $this->_normalizeSpec($spec); - return $this->rules[$spec] ?? false; + if (isset($this->rules[$spec])) { + return $this->rules[$spec]; + } + return false; } return $this->rules; From 060662481b047620ae97f22ec3f0c3fb00a26ef2 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 4 Nov 2024 07:06:43 +0700 Subject: [PATCH 06/27] Update to latest PHPUnit 10 syntax Signed-off-by: Abdul Malik Ikhsan --- test/StringToLowerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/StringToLowerTest.php b/test/StringToLowerTest.php index 26a62c4c..65f8019f 100644 --- a/test/StringToLowerTest.php +++ b/test/StringToLowerTest.php @@ -110,7 +110,7 @@ public function testCaseInsensitiveEncoding(): void self::assertSame($output, $filter($input)); } } catch (Exception\ExtensionNotLoadedException $e) { - self::assertContains('mbstring is required', $e->getMessage()); + self::assertStringContainsString('mbstring is required', $e->getMessage()); } } From 56e3088d7bac94ce14d8c63d826f68a2fdb74264 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 4 Nov 2024 07:12:17 +0700 Subject: [PATCH 07/27] Regenerate psalm-baseline.xml Signed-off-by: Abdul Malik Ikhsan --- psalm-baseline.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d0aee7ed..d77cc748 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2010,9 +2010,6 @@ - - getMessage()]]> - From 391533bc7f66d819e781ff11eea2b350d56511c8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 00:12:51 +0000 Subject: [PATCH 08/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 74 +++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/composer.lock b/composer.lock index f66d5094..391a3320 100644 --- a/composer.lock +++ b/composer.lock @@ -8,21 +8,21 @@ "packages": [ { "name": "laminas/laminas-servicemanager", - "version": "3.22.1", + "version": "3.23.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-servicemanager.git", - "reference": "de98d297d4743956a0558a6d71616979ff779328" + "reference": "a8640182b892b99767d54404d19c5c3b3699f79b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/de98d297d4743956a0558a6d71616979ff779328", - "reference": "de98d297d4743956a0558a6d71616979ff779328", + "url": "https://api.github.com/repos/laminas/laminas-servicemanager/zipball/a8640182b892b99767d54404d19c5c3b3699f79b", + "reference": "a8640182b892b99767d54404d19c5c3b3699f79b", "shasum": "" }, "require": { - "laminas/laminas-stdlib": "^3.17", - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", + "laminas/laminas-stdlib": "^3.19", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "psr/container": "^1.0" }, "conflict": { @@ -39,15 +39,15 @@ }, "require-dev": { "composer/package-versions-deprecated": "^1.11.99.5", - "friendsofphp/proxy-manager-lts": "^1.0.14", - "laminas/laminas-code": "^4.10.0", + "friendsofphp/proxy-manager-lts": "^1.0.18", + "laminas/laminas-code": "^4.14.0", "laminas/laminas-coding-standard": "~2.5.0", "laminas/laminas-container-config-test": "^0.8", - "mikey179/vfsstream": "^1.6.11", - "phpbench/phpbench": "^1.2.9", - "phpunit/phpunit": "^10.4", + "mikey179/vfsstream": "^1.6.12", + "phpbench/phpbench": "^1.3.1", + "phpunit/phpunit": "^10.5.36", "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.8.0" + "vimeo/psalm": "^5.26.1" }, "suggest": { "friendsofphp/proxy-manager-lts": "ProxyManager ^2.1.1 to handle lazy initialization of services" @@ -94,34 +94,34 @@ "type": "community_bridge" } ], - "time": "2023-10-24T11:19:47+00:00" + "time": "2024-10-28T21:32:16+00:00" }, { "name": "laminas/laminas-stdlib", - "version": "3.19.0", + "version": "3.20.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-stdlib.git", - "reference": "6a192dd0882b514e45506f533b833b623b78fff3" + "reference": "8974a1213be42c3e2f70b2c27b17f910291ab2f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/6a192dd0882b514e45506f533b833b623b78fff3", - "reference": "6a192dd0882b514e45506f533b833b623b78fff3", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/8974a1213be42c3e2f70b2c27b17f910291ab2f4", + "reference": "8974a1213be42c3e2f70b2c27b17f910291ab2f4", "shasum": "" }, "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "conflict": { "zendframework/zend-stdlib": "*" }, "require-dev": { - "laminas/laminas-coding-standard": "^2.5", - "phpbench/phpbench": "^1.2.15", - "phpunit/phpunit": "^10.5.8", - "psalm/plugin-phpunit": "^0.18.4", - "vimeo/psalm": "^5.20.0" + "laminas/laminas-coding-standard": "^3.0", + "phpbench/phpbench": "^1.3.1", + "phpunit/phpunit": "^10.5.38", + "psalm/plugin-phpunit": "^0.19.0", + "vimeo/psalm": "^5.26.1" }, "type": "library", "autoload": { @@ -153,7 +153,7 @@ "type": "community_bridge" } ], - "time": "2024-01-19T12:39:49+00:00" + "time": "2024-10-29T13:46:07+00:00" }, { "name": "psr/container", @@ -2148,23 +2148,23 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.8.2", + "version": "1.9.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "153ae662783729388a584b4361f2545e4d841e3c" + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/153ae662783729388a584b4361f2545e4d841e3c", - "reference": "153ae662783729388a584b4361f2545e4d841e3c", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d", + "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.13" + "phpstan/phpdoc-parser": "^1.18" }, "require-dev": { "ext-tokenizer": "*", @@ -2200,9 +2200,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.8.2" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0" }, - "time": "2024-02-23T11:10:43+00:00" + "time": "2024-11-03T20:11:34+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -2574,16 +2574,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.37", + "version": "10.5.38", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c7cffa0efa2b70c22366523e6d804c9419eb2400" + "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c7cffa0efa2b70c22366523e6d804c9419eb2400", - "reference": "c7cffa0efa2b70c22366523e6d804c9419eb2400", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a86773b9e887a67bc53efa9da9ad6e3f2498c132", + "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132", "shasum": "" }, "require": { @@ -2655,7 +2655,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.37" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.38" }, "funding": [ { @@ -2671,7 +2671,7 @@ "type": "tidelift" } ], - "time": "2024-10-19T13:03:41+00:00" + "time": "2024-10-28T13:06:21+00:00" }, { "name": "psalm/plugin-phpunit", From cb7b293d3918b60529efb877f00abb76b9fc9346 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 02:16:31 +0000 Subject: [PATCH 09/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 54 +++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/composer.lock b/composer.lock index 391a3320..09e18ce3 100644 --- a/composer.lock +++ b/composer.lock @@ -1517,16 +1517,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -1565,7 +1565,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -1573,7 +1573,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "netresearch/jsonmapper", @@ -2084,16 +2084,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.1", + "version": "5.5.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", - "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", + "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", "shasum": "" }, "require": { @@ -2106,13 +2106,13 @@ "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.5", + "mockery/mockery": "~1.3.5 || ~1.6.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8", "phpstan/phpstan-mockery": "^1.1", "phpstan/phpstan-webmozart-assert": "^1.2", "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^5.13" + "psalm/phar": "^5.26" }, "type": "library", "extra": { @@ -2142,29 +2142,29 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" }, - "time": "2024-05-21T05:55:05+00:00" + "time": "2024-11-06T11:58:54+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.9.0", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d" + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d", - "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.18" + "phpstan/phpdoc-parser": "^1.18|^2.0" }, "require-dev": { "ext-tokenizer": "*", @@ -2200,9 +2200,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" }, - "time": "2024-11-03T20:11:34+00:00" + "time": "2024-11-09T15:12:26+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -4022,16 +4022,16 @@ }, { "name": "symfony/console", - "version": "v6.4.13", + "version": "v6.4.14", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f793dd5a7d9ae9923e35d0503d08ba734cec1d79" + "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f793dd5a7d9ae9923e35d0503d08ba734cec1d79", - "reference": "f793dd5a7d9ae9923e35d0503d08ba734cec1d79", + "url": "https://api.github.com/repos/symfony/console/zipball/897c2441ed4eec8a8a2c37b943427d24dba3f26b", + "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b", "shasum": "" }, "require": { @@ -4096,7 +4096,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.13" + "source": "https://github.com/symfony/console/tree/v6.4.14" }, "funding": [ { @@ -4112,7 +4112,7 @@ "type": "tidelift" } ], - "time": "2024-10-09T08:40:40+00:00" + "time": "2024-11-05T15:34:40+00:00" }, { "name": "symfony/deprecation-contracts", From 2bca808c0b652d67a54a4078cd18414cd9cf404b Mon Sep 17 00:00:00 2001 From: ramchale Date: Fri, 15 Nov 2024 13:41:22 +0000 Subject: [PATCH 10/27] Apply one line per sentence style to md files Signed-off-by: ramchale --- docs/book/v2/file.md | 122 ++-- docs/book/v2/filter-chains.md | 37 +- docs/book/v2/inflector.md | 164 ++--- docs/book/v2/intro.md | 100 ++- docs/book/v2/migration/preparing-for-v3.md | 9 +- docs/book/v2/standard-filters.md | 716 +++++++++------------ docs/book/v2/static-filter.md | 23 +- docs/book/v2/word.md | 58 +- docs/book/v2/writing-filters.md | 6 +- 9 files changed, 507 insertions(+), 728 deletions(-) diff --git a/docs/book/v2/file.md b/docs/book/v2/file.md index 03c517b3..0aadf7b2 100644 --- a/docs/book/v2/file.md +++ b/docs/book/v2/file.md @@ -1,20 +1,16 @@ # File Filters -laminas-filter also comes with a set of classes for filtering file contents, and -performing file operations such as renaming. +laminas-filter also comes with a set of classes for filtering file contents, and performing file operations such as renaming. > ## $_FILES > -> All file filter `filter()` implementations support either a file path string -> *or* a `$_FILES` array as the supplied argument. When a `$_FILES` array is -> passed in, the `tmp_name` is used for the file path. +> All file filter `filter()` implementations support either a file path string *or* a `$_FILES` array as the supplied argument. +> When a `$_FILES` array is passed in, the `tmp_name` is used for the file path. ## Encrypt and Decrypt -These filters allow encrypting and decrypting file contents, and are derived -from the `Laminas\Filter\Encrypt` and `Laminas\Filter\Decrypt` filters. Only file reading and -writing operations are performed by the filer; encryption and decryption operations -are performed by the parent classes. +These filters allow encrypting and decrypting file contents, and are derived from the `Laminas\Filter\Encrypt` and `Laminas\Filter\Decrypt` filters. +Only file reading and writing operations are performed by the filer; encryption and decryption operations are performed by the parent classes. Usage: @@ -33,8 +29,8 @@ $filter = new EncryptFileFilter([ $filter->filter($files['my-upload']); ``` -In the above example, we pass options to our constructor in order to configure -the filter. We could instead use use setter methods to inject these options: +In the above example, we pass options to our constructor in order to configure the filter. +We could instead use use setter methods to inject these options: ```php use Laminas\Filter\File\Encrypt as EncryptFileFilter; @@ -55,8 +51,7 @@ for more information about options and adapters. ## Lowercase -`Laminas\Filter\File\Lowercase` can be used to convert all file contents to -lowercase. +`Laminas\Filter\File\Lowercase` can be used to convert all file contents to lowercase. ### Supported Options @@ -78,13 +73,10 @@ $filter = new LowerCase(); $filter->filter($files['my-upload']); ``` -This example converts the contents of an uploaded file to lowercase. After this -process, you can use the [Rename](#rename) or [RenameUpload](#renameupload) -filter to replace this file with your original file, or read directly from file. -But, don't forget, if you upload a file and send your `$_FILES` array to a -filter method, the `LowerCase` filter will only change the temporary file -(`tmp_name` index of array), not the original file. Let's check following -example: +This example converts the contents of an uploaded file to lowercase. +After this process, you can use the [Rename](#rename) or [RenameUpload](#renameupload) filter to replace this file with your original file, or read directly from file. +But, don't forget, if you upload a file and send your `$_FILES` array to a filter method, the `LowerCase` filter will only change the temporary file (`tmp_name` index of array), not the original file. +Let's check following example: ```php use Laminas\Filter\File\LowerCase; @@ -104,12 +96,9 @@ $renameFilter = new Rename([ $filename = $renameFilter->filter($file['tmp_name']); ``` -With this example, the final, stored file on the server will have the lowercased -content. +With this example, the final, stored file on the server will have the lowercased content. -If you want to use a specific encoding when converting file content, you should -specify the encoding when instantiating the `LowerCase` filter, or use the -`setEncoding` method to change it. +If you want to use a specific encoding when converting file content, you should specify the encoding when instantiating the `LowerCase` filter, or use the `setEncoding` method to change it. ```php use Laminas\Filter\File\LowerCase; @@ -136,21 +125,16 @@ for more information about encoding and its exceptions. The following set of options are supported: -- `target` (string; default: `*`): Target filename or directory; the new name - of the source file. -- `source` (string; default: `*`): Source filename or directory which will be - renamed. Used to match the filtered file with an options set. +- `target` (string; default: `*`): Target filename or directory; the new name of the source file. +- `source` (string; default: `*`): Source filename or directory which will be renamed. +Used to match the filtered file with an options set. - `overwrite` (boolean; default: `false`): Shall existing files be overwritten? - If the file is unable to be moved into the target path, a - `Laminas\Filter\Exception\RuntimeException` will be thrown. -- `randomize` (boolean; default: `false`): Shall target files have a random - postfix attached? The random postfix will generated with `uniqid('_')` after - the file name and before the extension. For example, `file.txt` might be - randomized to `file_4b3403665fea6.txt`. +- If the file is unable to be moved into the target path, a `Laminas\Filter\Exception\RuntimeException` will be thrown. +- `randomize` (boolean; default: `false`): Shall target files have a random postfix attached? The random postfix will generated with `uniqid('_')` after the file name and before the extension. +For example, `file.txt` might be randomized to `file_4b3403665fea6.txt`. -An array of option sets is also supported, where a single `Rename` filter -instance can filter several files using different options. The options used for -the filtered file will be matched from the `source` option in the options set. +An array of option sets is also supported, where a single `Rename` filter instance can filter several files using different options. +The options used for the filtered file will be matched from the `source` option in the options set. ### Usage Examples @@ -224,40 +208,28 @@ The following set of options are supported: - `target` (string; default: `*`): Target directory or full filename path. - `overwrite` (boolean; default: `false`): Shall existing files be overwritten? - If the file is unable to be moved into the target path, a - `Laminas\Filter\Exception\RuntimeException` will be thrown. -- `randomize` (boolean; default: `false`): Shall target files have a random - postfix attached? The random postfix will generated with `uniqid('_')` after - the file name and before the extension. For example, `file.txt` might be - randomized to `file_4b3403665fea6.txt`. -- `use_upload_name` (boolean; default: `false`): When true, this filter will - use `$_FILES['name']` as the target filename. Otherwise, the default `target` - rules and the `$_FILES['tmp_name']` will be used. -- `use_upload_extension` (boolean; default: `false`): When true, the uploaded - file will maintains its original extension if not specified. For example, if - the uploaded file is `file.txt` and the target is `mynewfile`, the upload - will be renamed to `mynewfile.txt`. +If the file is unable to be moved into the target path, a `Laminas\Filter\Exception\RuntimeException` will be thrown. +- `randomize` (boolean; default: `false`): Shall target files have a random postfix attached? The random postfix will generated with `uniqid('_')` after the file name and before the extension. +For example, `file.txt` might be randomized to `file_4b3403665fea6.txt`. +- `use_upload_name` (boolean; default: `false`): When true, this filter will use `$_FILES['name']` as the target filename. +Otherwise, the default `target` rules and the `$_FILES['tmp_name']` will be used. +- `use_upload_extension` (boolean; default: `false`): When true, the uploaded file will maintains its original extension if not specified. +For example, if the uploaded file is `file.txt` and the target is `mynewfile`, the upload will be renamed to `mynewfile.txt`. - `stream_factory` (`Psr\Http\Message\StreamFactoryInterface`; default: `null`): - Required when passing a [PSR-7 UploadedFileInterface](https://www.php-fig.org/psr/psr-7/#36-psrhttpmessageuploadedfileinterface) - to the filter; used to create a new stream representing the renamed file. - (Since 2.9.0) -- `upload_file_factory` (`Psr\Http\Message\UploadedFileFactoryInterface`; default: - `null`): Required when passing a [PSR-7 UploadedFileInterface](https://www.php-fig.org/psr/psr-7/#36-psrhttpmessageuploadedfileinterface) - to the filter; used to create a new uploaded file representation of the - renamed file. (Since 2.9.0) +Required when passing a [PSR-7 UploadedFileInterface](https://www.php-fig.org/psr/psr-7/#36-psrhttpmessageuploadedfileinterface) to the filter; used to create a new stream representing the renamed file. +(Since 2.9.0) +- `upload_file_factory` (`Psr\Http\Message\UploadedFileFactoryInterface`; default: `null`): Required when passing a [PSR-7 UploadedFileInterface](https://www.php-fig.org/psr/psr-7/#36-psrhttpmessageuploadedfileinterface) to the filter; used to create a new uploaded file representation of the renamed file. +(Since 2.9.0) > ### Using the upload Name is unsafe > -> Be **very** careful when using the `use_upload_name` option. For instance, -> extremely bad things could happen if you were to allow uploaded `.php` files -> (or other CGI files) to be moved into the `DocumentRoot`. +> Be **very** careful when using the `use_upload_name` option. +> For instance, extremely bad things could happen if you were to allow uploaded `.php` files (or other CGI files) to be moved into the `DocumentRoot`. > -> It is generally a better idea to supply an internal filename to avoid -> security risks. +> It is generally a better idea to supply an internal filename to avoid security risks. `RenameUpload` does not support an array of options like the`Rename` filter. -When filtering HTML5 file uploads with the `multiple` attribute set, all files -will be filtered with the same option settings. +When filtering HTML5 file uploads with the `multiple` attribute set, all files will be filtered with the same option settings. ### Usage Examples @@ -343,23 +315,16 @@ foreach ($request->getUploadedFiles() as $uploadedFile) { > ### PSR-7 Support > -> PSR-7/PSR-17 support has only been available since 2.9.0, and requires a valid -> [psr/http-factory-implementation](https://packagist.org/providers/psr/http-factory-implementation) -> in your application, as it relies on the stream and uploaded file factories in -> order to produce the final `UploadedFileInterface` artifact representing the -> filtered file. +> PSR-7/PSR-17 support has only been available since 2.9.0, and requires a valid [psr/http-factory-implementation](https://packagist.org/providers/psr/http-factory-implementation) in your application, as it relies on the stream and uploaded file factories in order to produce the final `UploadedFileInterface` artifact representing the filtered file. > -> PSR-17 itself requires PHP 7, so your application will need to be running on -> PHP 7 in order to use this feature. +> PSR-17 itself requires PHP 7, so your application will need to be running on PHP 7 in order to use this feature. > -> [laminas/laminas-diactoros 2.0](https://docs.laminas.dev/laminas-diactoros/) -> provides a PSR-17 implementation, but requires PHP 7.1. If you are still on -> PHP 7.0, either upgrade, or find a compatible psr/http-factory-implementation. +> [laminas/laminas-diactoros 2.0](https://docs.laminas.dev/laminas-diactoros/) provides a PSR-17 implementation, but requires PHP 7.1. +> If you are still on PHP 7.0, either upgrade, or find a compatible psr/http-factory-implementation. ## Uppercase -`Laminas\Filter\File\Uppercase` can be used to convert all file contents to -uppercase. +`Laminas\Filter\File\Uppercase` can be used to convert all file contents to uppercase. ### Supported Options @@ -381,5 +346,4 @@ $filter = new UpperCase(); $filter->filter($files['my-upload']); ``` -See the documentation on the [`LowerCase`](#lowercase) filter, above, for more -information. +See the documentation on the [`LowerCase`](#lowercase) filter, above, for more information. diff --git a/docs/book/v2/filter-chains.md b/docs/book/v2/filter-chains.md index 7d9cef8e..68f883af 100644 --- a/docs/book/v2/filter-chains.md +++ b/docs/book/v2/filter-chains.md @@ -1,12 +1,10 @@ # Filter Chains Often, multiple filters should be applied to some value in a particular order. -For example, a login form accepts a username that should be lowercase and -contain only alphabetic characters. +For example, a login form accepts a username that should be lowercase and contain only alphabetic characters. -`Laminas\Filter\FilterChain` provides a simple method by which filters may be -chained together. The following code illustrates how to chain together two -filters for the submitted username and fulfill the above requirements: +`Laminas\Filter\FilterChain` provides a simple method by which filters may be chained together. +The following code illustrates how to chain together two filters for the submitted username and fulfill the above requirements: ```php // Create a filter chain and add filters to the chain @@ -19,21 +17,18 @@ $filterChain $username = $filterChain->filter($_POST['username']); ``` -Filters are run in the order they are added to the filter chain. In the above -example, the username is first removed of any non-alphabetic characters, and -then any uppercase characters are converted to lowercase. +Filters are run in the order they are added to the filter chain. +In the above example, the username is first removed of any non-alphabetic characters, and then any uppercase characters are converted to lowercase. -Any object that implements `Laminas\Filter\FilterInterface` may be used in a -filter chain. +Any object that implements `Laminas\Filter\FilterInterface` may be used in a filter chain. ## Setting Filter Chain Order -For each filter added to the `FilterChain`, you can set a priority to define -the chain order. Higher values indicate higher priority (execute first), while -lower and/or negative values indicate lower priority (execute last). The default value is `1000`. +For each filter added to the `FilterChain`, you can set a priority to define the chain order. +Higher values indicate higher priority (execute first), while lower and/or negative values indicate lower priority (execute last). +The default value is `1000`. -In the following example, any uppercase characters are converted to lowercase -before any non-alphabetic characters are removed. +In the following example, any uppercase characters are converted to lowercase before any non-alphabetic characters are removed. ```php // Create a filter chain and add filters to the chain @@ -45,13 +40,13 @@ $filterChain ## Using the Plugin Manager -A `FilterPluginManager` is attached to every `FilterChain` instance. Every filter -that is used in a `FilterChain` must be known to the `FilterPluginManager`. +A `FilterPluginManager` is attached to every `FilterChain` instance. +Every filter that is used in a `FilterChain` must be known to the `FilterPluginManager`. -To add a filter to the `FilterChain`, use the `attachByName()` method. The -first parameter is the name of the filter within the `FilterPluginManager`. The -second parameter takes any options for creating the filter instance. The third -parameter is the priority. +To add a filter to the `FilterChain`, use the `attachByName()` method. +The first parameter is the name of the filter within the `FilterPluginManager`. +The second parameter takes any options for creating the filter instance. +The third parameter is the priority. ```php // Create a filter chain and add filters to the chain diff --git a/docs/book/v2/inflector.md b/docs/book/v2/inflector.md index 320ca2e5..1154ff7b 100644 --- a/docs/book/v2/inflector.md +++ b/docs/book/v2/inflector.md @@ -1,15 +1,11 @@ # String Inflection -`Laminas\Filter\Inflector` is a general purpose tool for rules-based inflection of -strings to a given target. +`Laminas\Filter\Inflector` is a general purpose tool for rules-based inflection of strings to a given target. -As an example, you may find you need to transform MixedCase or camelCasedWords -into a path; for readability, OS policies, or other reasons, you also need to -lower case this; and finally, you want to separate the words using a dash -(`-`). An inflector can do this for you. +As an example, you may find you need to transform MixedCase or camelCasedWords into a path; for readability, OS policies, or other reasons, you also need to lower case this; and finally, you want to separate the words using a dash (`-`). +An inflector can do this for you. -`Laminas\Filter\Inflector` implements `Laminas\Filter\FilterInterface`; you perform -inflection by calling `filter()` on the object instance. +`Laminas\Filter\Inflector` implements `Laminas\Filter\FilterInterface`; you perform inflection by calling `filter()` on the object instance. ## Transforming MixedCase and CamelCaseText to another Format @@ -31,18 +27,17 @@ $filtered = $inflector->filter(['page' => $string]); ## Operation -An inflector requires a **target** and one or more **rules**. A target is -basically a string that defines placeholders for variables you wish to -substitute. These are specified by prefixing with a `:`: `:script`. +An inflector requires a **target** and one or more **rules**. +A target is basically a string that defines placeholders for variables you wish to substitute. +These are specified by prefixing with a `:`: `:script`. -When calling `filter()`, you then pass in an array of key and value pairs -corresponding to the variables in the target. +When calling `filter()`, you then pass in an array of key and value pairs corresponding to the variables in the target. Each variable in the target can have zero or more rules associated with them. -Rules may be either **static** or refer to a laminas-filter class. Static rules -will replace with the text provided. Otherwise, a class matching the rule -provided will be used to inflect the text. Classes are typically specified -using a short name indicating the filter name stripped of any common prefix. +Rules may be either **static** or refer to a laminas-filter class. +Static rules will replace with the text provided. +Otherwise, a class matching the rule provided will be used to inflect the text. +Classes are typically specified using a short name indicating the filter name stripped of any common prefix. As an example, you can use any laminas-filter concrete implementations; however, instead of referring to them as `Laminas\I18n\Filter\Alpha` or @@ -50,20 +45,16 @@ instead of referring to them as `Laminas\I18n\Filter\Alpha` or ### Using Custom Filters -`Laminas\Filter\Inflector` uses `Laminas\Filter\FilterPluginManager` to manage -loading filters to use with inflection. By default, filters registered with -`Laminas\Filter\FilterPluginManager` are available. To access filters with that -prefix but which occur deeper in the hierarchy, such as the various `Word` -filters, simply strip off the `Laminas\Filter` prefix: +`Laminas\Filter\Inflector` uses `Laminas\Filter\FilterPluginManager` to manage loading filters to use with inflection. +By default, filters registered with `Laminas\Filter\FilterPluginManager` are available. +To access filters with that prefix but which occur deeper in the hierarchy, such as the various `Word` filters, simply strip off the `Laminas\Filter` prefix: ```php // use Laminas\Filter\Word\CamelCaseToDash as a rule $inflector->addRules(['script' => 'Word\CamelCaseToDash']); ``` -To use custom filters, you have two choices: reference them by fully qualified -class name (e.g., `My\Custom\Filter\Mungify`), or manipulate the composed -`FilterPluginManager` instance. +To use custom filters, you have two choices: reference them by fully qualified class name (e.g., `My\Custom\Filter\Mungify`), or manipulate the composed `FilterPluginManager` instance. ```php $filters = $inflector->getPluginManager(); @@ -73,9 +64,8 @@ $filters->addInvokableClass('mungify', 'My\Custom\Filter\Mungify'); ### Setting the Inflector Target The inflector target is a string with some placeholders for variables. -Placeholders take the form of an identifier, a colon (`:`) by default, followed -by a variable name: `:script`, `:path`, etc. The `filter()` method looks for -the identifier followed by the variable name being replaced. +Placeholders take the form of an identifier, a colon (`:`) by default, followed by a variable name: `:script`, `:path`, etc. +The `filter()` method looks for the identifier followed by the variable name being replaced. You can change the identifier using the `setTargetReplacementIdentifier()` method, or passing it as the fourth argument to the constructor: @@ -88,17 +78,16 @@ $inflector = new Laminas\Filter\Inflector('#foo/#bar.#sfx', array(), null, '#'); $inflector->setTargetReplacementIdentifier('#'); ``` -Typically, you will set the target via the constructor. However, you may want -to re-set the target later. `setTarget()` can be used for this purpose: +Typically, you will set the target via the constructor. +However, you may want to re-set the target later. +`setTarget()` can be used for this purpose: ```php $inflector->setTarget('layouts/:script.phtml'); ``` -Additionally, you may wish to have a class member for your class that you can -use to keep the inflector target updated — without needing to directly update -the target each time (thus saving on method calls). `setTargetReference()` -allows you to do this: +Additionally, you may wish to have a class member for your class that you can use to keep the inflector target updated — without needing to directly update the target each time (thus saving on method calls). +`setTargetReference()` allows you to do this: ```php class Foo @@ -138,21 +127,15 @@ As mentioned in the introduction, there are two types of rules: static and filte > ### Order is important > -> It is important to note that regardless of the method in which you add rules -> to the inflector, either one-by-one, or all-at-once; the order is very -> important. More specific names, or names that might contain other rule names, -> must be added before least specific names. For example, assuming the two rule -> names `moduleDir` and `module`, the `moduleDir` rule should appear before -> module since `module` is contained within `moduleDir`. If `module` were added -> before `moduleDir`, `module` will match part of `moduleDir` and process it -> leaving `Dir` inside of the target uninflected. +> It is important to note that regardless of the method in which you add rules to the inflector, either one-by-one, or all-at-once; the order is very important. +> More specific names, or names that might contain other rule names, must be added before least specific names. +> For example, assuming the two rule names `moduleDir` and `module`, the `moduleDir` rule should appear before module since `module` is contained within `moduleDir`. +> If `module` were added before `moduleDir`, `module` will match part of `moduleDir` and process it leaving `Dir` inside of the target uninflected. ### Static Rules -Static rules do simple string substitution; use them when you have a segment in -the target that will typically be static, but which you want to allow the -developer to modify. Use the `setStaticRule()` method to set or modify the -rule: +Static rules do simple string substitution; use them when you have a segment in the target that will typically be static, but which you want to allow the developer to modify. +Use the `setStaticRule()` method to set or modify the rule: ```php $inflector = new Laminas\Filter\Inflector(':script.:suffix'); @@ -162,11 +145,8 @@ $inflector->setStaticRule('suffix', 'phtml'); $inflector->setStaticRule('suffix', 'php'); ``` -Much like the target itself, you can also bind a static rule to a reference, -allowing you to update a single variable instead of require a method call; this -is often useful when your class uses an inflector internally, and you don't -want your users to need to fetch the inflector in order to update it. The -`setStaticRuleReference()` method is used to accomplish this: +Much like the target itself, you can also bind a static rule to a reference, allowing you to update a single variable instead of require a method call; this is often useful when your class uses an inflector internally, and you don't want your users to need to fetch the inflector in order to update it. +The`setStaticRuleReference()` method is used to accomplish this: ```php class Foo @@ -202,23 +182,19 @@ class Foo ### Filter-Based Inflector Rules -`Laminas\Filter` filters may be used as inflector rules as well. Just like static -rules, these are bound to a target variable; unlike static rules, you may -define multiple filters to use when inflecting. These filters are processed in -order, so be careful to register them in an order that makes sense for the data -you receive. +`Laminas\Filter` filters may be used as inflector rules as well. +Just like static rules, these are bound to a target variable; unlike static rules, you may define multiple filters to use when inflecting. +These filters are processed in order, so be careful to register them in an order that makes sense for the data you receive. -Rules may be added using `setFilterRule()` (which overwrites any previous rules -for that variable) or `addFilterRule()` (which appends the new rule to any -existing rule for that variable). Filters are specified in one of the following -ways: +Rules may be added using `setFilterRule()` (which overwrites any previous rules for that variable) or `addFilterRule()` (which appends the new rule to any existing rule for that variable). +Filters are specified in one of the following ways: -- **String**. The string may be a filter class name, or a class name segment - minus any prefix set in the inflector's plugin loader (by default, minus the - '`Laminas\Filter`' prefix). -- **Filter object**. Any object instance implementing - `Laminas\Filter\FilterInterface` may be passed as a filter. -- **Array**. An array of one or more strings or filter objects as defined above. +- **String**. +The string may be a filter class name, or a class name segment minus any prefix set in the inflector's plugin loader (by default, minus the '`Laminas\Filter`' prefix). +- **Filter object**. +Any object instance implementing `Laminas\Filter\FilterInterface` may be passed as a filter. +- **Array**. +An array of one or more strings or filter objects as defined above. ```php $inflector = new Laminas\Filter\Inflector(':script.:suffix'); @@ -238,14 +214,11 @@ $inflector->setFilterRule('script', [ ## Setting many Rules at once -Typically, it's easier to set many rules at once than to configure a single -variable and its inflection rules one at a time. `Laminas\Filter\Inflector`'s -`addRules()` and `setRules()` methods allow this. +Typically, it's easier to set many rules at once than to configure a single variable and its inflection rules one at a time. +`Laminas\Filter\Inflector`'s `addRules()` and `setRules()` methods allow this. -Each method takes an array of variable and rule pairs, where the rule may be -whatever the type of rule accepts (string, filter object, or array). Variable -names accept a special notation to allow setting static rules and filter rules, -according to the following notation: +Each method takes an array of variable and rule pairs, where the rule may be whatever the type of rule accepts (string, filter object, or array). +Variable names accept a special notation to allow setting static rules and filter rules, according to the following notation: - **`:` prefix**: filter rules. - **No prefix**: static rule. @@ -266,42 +239,27 @@ $inflector->addRules([ ## Utility Methods -`Laminas\Filter\Inflector` has a number of utility methods for retrieving and -setting the plugin loader, manipulating and retrieving rules, and controlling -if and when exceptions are thrown. - -- `setPluginManager()` can be used when you have configured your own - `Laminas\Filter\FilterPluginManager` instance and wish to use it with - `Laminas\Filter\Inflector`; `getPluginManager()` retrieves the currently set - one. -- `setThrowTargetExceptionsOn()` can be used to control whether or not - `filter()` throws an exception when a given replacement identifier passed to - it is not found in the target. By default, no exceptions are thrown. - `isThrowTargetExceptionsOn()` will tell you what the current value is. -- `getRules($spec = null)` can be used to retrieve all registered rules for all - variables, or just the rules for a single variable. -- `getRule($spec, $index)` fetches a single rule for a given variable; this can - be useful for fetching a specific filter rule for a variable that has a - filter chain. `$index` must be passed. +`Laminas\Filter\Inflector` has a number of utility methods for retrieving and setting the plugin loader, manipulating and retrieving rules, and controlling if and when exceptions are thrown. + +- `setPluginManager()` can be used when you have configured your own `Laminas\Filter\FilterPluginManager` instance and wish to use it with `Laminas\Filter\Inflector`; `getPluginManager()` retrieves the currently set one. +- `setThrowTargetExceptionsOn()` can be used to control whether or not `filter()` throws an exception when a given replacement identifier passed to it is not found in the target. +By default, no exceptions are thrown. +`isThrowTargetExceptionsOn()` will tell you what the current value is. +- `getRules($spec = null)` can be used to retrieve all registered rules for all variables, or just the rules for a single variable. +- `getRule($spec, $index)` fetches a single rule for a given variable; this can be useful for fetching a specific filter rule for a variable that has a filter chain. +`$index` must be passed. - `clearRules()` will clear all currently registered rules. ## Using a Traversable or an Array -You can use a `Traversable` or an array to set rules and other object state in -your inflectors, by passing either type to either the constructor or the -`setOptions()` method. The following settings may be specified: +You can use a `Traversable` or an array to set rules and other object state in your inflectors, by passing either type to either the constructor or the `setOptions()` method. +The following settings may be specified: - `target` specifies the inflection target. -- `pluginManager` specifies the `Laminas\Filter\FilterPluginManager` instance or - extension to use for obtaining plugins; alternately, you may specify a class - name of a class that extends the `FilterPluginManager`. -- `throwTargetExceptionsOn` should be a boolean indicating whether or not to - throw exceptions when a replacement identifier is still present after - inflection. -- `targetReplacementIdentifier` specifies the character to use when identifying - replacement variables in the target string. -- `rules` specifies an array of inflection rules; it should consist of keys - that specify either values or arrays of values, consistent with `addRules()`. +- `pluginManager` specifies the `Laminas\Filter\FilterPluginManager` instance or extension to use for obtaining plugins; alternately, you may specify a class name of a class that extends the `FilterPluginManager`. +- `throwTargetExceptionsOn` should be a boolean indicating whether or not to throw exceptions when a replacement identifier is still present after inflection. +- `targetReplacementIdentifier` specifies the character to use when identifying replacement variables in the target string. +- `rules` specifies an array of inflection rules; it should consist of keys that specify either values or arrays of values, consistent with `addRules()`. As examples: diff --git a/docs/book/v2/intro.md b/docs/book/v2/intro.md index f10ac0ba..3faf6665 100644 --- a/docs/book/v2/intro.md +++ b/docs/book/v2/intro.md @@ -1,31 +1,22 @@ # Introduction -laminas-filter provides a set of commonly needed data filters. It also provides a -simple filter chaining mechanism by which multiple filters may be applied to a -single datum in a user-defined order. +laminas-filter provides a set of commonly needed data filters. +It also provides a simple filter chaining mechanism by which multiple filters may be applied to a single datum in a user-defined order. ## What is a filter? -In the physical world, a filter is typically used for removing unwanted portions -of input, and the desired portion of the input passes through as filter output -(e.g., coffee). In such scenarios, a filter is an operator that produces a -subset of the input. This type of filtering is useful for web applications: -removing illegal input, trimming unnecessary white space, etc. - -This basic definition of a filter may be extended to include generalized -transformations upon input. A common transformation applied in web applications -is the escaping of HTML entities. For example, if a form field is automatically -populated with untrusted input (e.g., from a web browser), this value should -either be free of HTML entities or contain only escaped HTML entities, in order -to prevent undesired behavior and security vulnerabilities. To meet this -requirement, HTML entities that appear in the input must either be removed or -escaped. Of course, which approach is more appropriate depends on the situation. -A filter that removes the HTML entities operates within the scope of the first -definition of filter - an operator that produces a subset of the input. A filter -that escapes the HTML entities, however, transforms the input (e.g., `&` is -transformed to `&`). Supporting such use cases for web developers is -important, and “to filter”, in the context of using laminas-filter, means to -perform some transformations upon input data. +In the physical world, a filter is typically used for removing unwanted portions of input, and the desired portion of the input passes through as filter output (e.g., coffee). +In such scenarios, a filter is an operator that produces a subset of the input. +This type of filtering is useful for web applications: removing illegal input, trimming unnecessary white space, etc. + +This basic definition of a filter may be extended to include generalized transformations upon input. +A common transformation applied in web applications is the escaping of HTML entities. +For example, if a form field is automatically populated with untrusted input (e.g., from a web browser), this value should either be free of HTML entities or contain only escaped HTML entities, in order to prevent undesired behavior and security vulnerabilities. +To meet this requirement, HTML entities that appear in the input must either be removed or escaped. +Of course, which approach is more appropriate depends on the situation. +A filter that removes the HTML entities operates within the scope of the first definition of filter - an operator that produces a subset of the input. +A filter that escapes the HTML entities, however, transforms the input (e.g., `&` is transformed to `&`). +Supporting such use cases for web developers is important, and “to filter”, in the context of using laminas-filter, means to perform some transformations upon input data. ## Basic usage of filters @@ -33,8 +24,7 @@ Having this filter definition established provides the foundation for `Laminas\Filter\FilterInterface`, which requires a single method named `filter()` to be implemented by a filter class. -Following is a basic example of using a filter upon two input data, the -ampersand (`&`) and double quote (`"`) characters: +Following is a basic example of using a filter upon two input data, the ampersand (`&`) and double quote (`"`) characters: ```php $htmlEntities = new Laminas\Filter\HtmlEntities(); @@ -43,8 +33,7 @@ echo $htmlEntities->filter('&'); // & echo $htmlEntities->filter('"'); // " ``` -Also, if a filter inherits from `Laminas\Filter\AbstractFilter` (as do all of the -out-of-the-box filters), you can also use them as invokables: +Also, if a filter inherits from `Laminas\Filter\AbstractFilter` (as do all of the out-of-the-box filters), you can also use them as invokables: ```php $strtolower = new Laminas\Filter\StringToLower; @@ -58,20 +47,16 @@ $laminaslove = $strtolower('I LOVE Laminas!'); CAUTION: **Deprecated** This filter is deprecated since version 2.15.0 and [will be removed](migration/preparing-for-v3.md#static-filter-removal) in version 3.0. -If it is inconvenient to load a given filter class and create an instance of the -filter, you can use `StaticFilter` with its `execute()` method as an alternative -invocation style. The first argument of this method is a data input value, that -you would pass to the `filter()` method. The second argument is a string, which -corresponds to the basename of the filter class, relative to the `Laminas\Filter` -namespace. The `execute()` method automatically loads the class, creates an -instance, and applies the `filter()` method to the data input. +If it is inconvenient to load a given filter class and create an instance of the filter, you can use `StaticFilter` with its `execute()` method as an alternative invocation style. +The first argument of this method is a data input value, that you would pass to the `filter()` method. +The second argument is a string, which corresponds to the basename of the filter class, relative to the `Laminas\Filter` namespace. +The `execute()` method automatically loads the class, creates an instance, and applies the `filter()` method to the data input. ```php echo StaticFilter::execute('&', 'HtmlEntities'); ``` -You can also pass an array of constructor arguments, if they are needed for the -filter class: +You can also pass an array of constructor arguments, if they are needed for the filter class: ```php echo StaticFilter::execute( @@ -81,17 +66,12 @@ echo StaticFilter::execute( ); ``` -The static usage can be convenient for invoking a filter ad hoc, but if you have -the need to run a filter for multiple inputs, it’s more efficient to follow the -first example above, creating an instance of the filter object and calling its -`filter()` method. +The static usage can be convenient for invoking a filter ad hoc, but if you have the need to run a filter for multiple inputs, it’s more efficient to follow the first example above, creating an instance of the filter object and calling its `filter()` method. -Also, the `FilterChain` class allows you to instantiate and run multiple filter -and validator classes on demand to process sets of input data. See the -[FilterChain](filter-chains.md) chapter for more details. +Also, the `FilterChain` class allows you to instantiate and run multiple filter and validator classes on demand to process sets of input data. +See the [FilterChain](filter-chains.md) chapter for more details. -You can set and receive the `FilterPluginManager` for the `StaticFilter` to -amend the standard filter classes. +You can set and receive the `FilterPluginManager` for the `StaticFilter` to amend the standard filter classes. ```php $pluginManager = StaticFilter::getPluginManager()->setInvokableClass( @@ -106,9 +86,8 @@ This is useful when adding custom filters to be used by the `StaticFilter`. ## Double filtering -When using two filters in succession, you have to keep in mind that it is -often not possible to get the original output by using the opposite filter. Take -the following example: +When using two filters in succession, you have to keep in mind that it is often not possible to get the original output by using the opposite filter. +Take the following example: ```php $original = 'my_original_content'; @@ -122,21 +101,18 @@ $filter2 = new Laminas\Filter\Word\CamelCaseToUnderscore(); $filtered = $filter2->filter($filtered) ``` -The above code example could lead to the impression that you will get the -original output after the second filter has been applied. But thinking logically -this is not the case. After applying the first filter, `my_original_content` will -be changed to `MyOriginalContent`. But after applying the second filter, the result -is `My_Original_Content`. +The above code example could lead to the impression that you will get the original output after the second filter has been applied. +But thinking logically this is not the case. +After applying the first filter, `my_original_content` will be changed to `MyOriginalContent`. +But after applying the second filter, the result is `My_Original_Content`. -As you can see it is not always possible to get the original output by using a -filter which seems to be the opposite. It depends on the filter and also on the -given input. +As you can see it is not always possible to get the original output by using a filter which seems to be the opposite. +It depends on the filter and also on the given input. ## Providing filters via modules If you wish to indicate that your laminas-mvc module provides filters, have your -`Module` class implement `Laminas\Filter\FilterProviderInterface`, which defines -the method: +`Module` class implement `Laminas\Filter\FilterProviderInterface`, which defines the method: ```php /** @@ -148,10 +124,6 @@ public function getFilterConfig(); The method should return an array of configuration following the [laminas-servicemanager configuration format](https://docs.laminas.dev/laminas-servicemanager/configuring-the-service-manager/). -If you are not using laminas-mvc, but are using a dependency injection container -(e.g., if you are using Mezzio), you can also provide filters using the -top-level `filters` configuration key; the value of that key should be -laminas-servicemanager configuration, as linked above. +If you are not using laminas-mvc, but are using a dependency injection container (e.g., if you are using Mezzio), you can also provide filters using the top-level `filters` configuration key; the value of that key should be laminas-servicemanager configuration, as linked above. -(laminas-mvc users may also provide configuration in the same way, and omit -implementation of the `FilterProviderInterface`.) +(laminas-mvc users may also provide configuration in the same way, and omit implementation of the `FilterProviderInterface`.) diff --git a/docs/book/v2/migration/preparing-for-v3.md b/docs/book/v2/migration/preparing-for-v3.md index 35904086..931d4c91 100644 --- a/docs/book/v2/migration/preparing-for-v3.md +++ b/docs/book/v2/migration/preparing-for-v3.md @@ -1,6 +1,7 @@ # Preparing for Version 3 -Version 3 will introduce a number of backwards incompatible changes. This document is intended to help you prepare for these changes. +Version 3 will introduce a number of backwards incompatible changes. +This document is intended to help you prepare for these changes. ## Removed Features @@ -55,7 +56,8 @@ If you are currently using any of these compression formats with laminas-filter, ### Encryption & Decryption Filter Removal -These filters have become outdated and will be removed in version 3.0 of this library. We recommend that you make use of a maintained encryption library and [write your own filters](../writing-filters.md) if you need to encrypt or decrypt content using the `FilterInterface` contract. +These filters have become outdated and will be removed in version 3.0 of this library. +We recommend that you make use of a maintained encryption library and [write your own filters](../writing-filters.md) if you need to encrypt or decrypt content using the `FilterInterface` contract. - `Laminas\Filter\File\Decrypt` - `Laminas\Filter\File\Encrypt` @@ -64,7 +66,8 @@ These filters have become outdated and will be removed in version 3.0 of this li ### Static Filter Removal -`Laminas\Filter\StaticFilter` will be removed without replacement in v3. Most filters are "new-able" so similar behaviour can be accomplished with: +`Laminas\Filter\StaticFilter` will be removed without replacement in v3. +Most filters are "new-able" so similar behaviour can be accomplished with: ```php $filtered = (new \Laminas\Filter\HtmlEntities())('Nuts & Bolts'); diff --git a/docs/book/v2/standard-filters.md b/docs/book/v2/standard-filters.md index 7fc5e2b1..d79c0d1a 100644 --- a/docs/book/v2/standard-filters.md +++ b/docs/book/v2/standard-filters.md @@ -8,9 +8,8 @@ TIP: **New Feature** Available since version 2.12.0 Previously known as `Whitelist`. -This filter will return `null` if the value being filtered is not present the -filter's allowed list of values. If the value is present, it will return that -value. +This filter will return `null` if the value being filtered is not present the filter's allowed list of values. +If the value is present, it will return that value. For the opposite functionality see the [DenyList](#denylist) filter. @@ -33,12 +32,10 @@ echo $allowList->filter('not-allowed'); // => null ## Alnum -The `Alnum` filter can be used to return only alphabetic characters and digits -in the unicode "letter" and "number" categories, respectively. All other -characters are suppressed. +The `Alnum` filter can be used to return only alphabetic characters and digits in the unicode "letter" and "number" categories, respectively. +All other characters are suppressed. -This filter is part of the laminas-i18n package; you will need to include that -package in your application to use it. +This filter is part of the laminas-i18n package; you will need to include that package in your application to use it. ### Supported Options @@ -49,14 +46,13 @@ Alnum([ boolean $allowWhiteSpace [, string $locale ]]) ``` - `$allowWhiteSpace`: If set to true, then whitespace characters are allowed. - Otherwise they are suppressed. Default is `false` (whitespace is not allowed). - Methods for getting/setting the `allowWhiteSpace` option are also available: - `getAllowWhiteSpace()` and `setAllowWhiteSpace()`. +Otherwise they are suppressed. +Default is `false` (whitespace is not allowed). +Methods for getting/setting the `allowWhiteSpace` option are also available: `getAllowWhiteSpace()` and `setAllowWhiteSpace()`. -- `$locale`: The locale string used in identifying the characters to filter - (locale name, e.g. `en_US`). If unset, it will use the default locale - (`Locale::getDefault()`). Methods for getting/setting the locale are also - available: `getLocale()` and `setLocale()`. +- `$locale`: The locale string used in identifying the characters to filter (locale name, e.g.`en_US`). +If unset, it will use the default locale (`Locale::getDefault()`). +Methods for getting/setting the locale are also available: `getLocale()` and `setLocale()`. ### Basic Usage @@ -75,17 +71,15 @@ echo $filter->filter('This is (my) content: 123'); > ### Supported Languages > > `Alnum` works on almost all languages, except: Chinese, Japanese and Korean. -> Within these languages, the english alphabet is used instead of the characters -> from these languages. The language itself is detected using the `Locale` -> class. +> Within these languages, the english alphabet is used instead of the characters from these languages. +> The language itself is detected using the `Locale` class. ## Alpha -The `Alpha` filter can be used to return only alphabetic characters in the unicode "letter" -category. All other characters are suppressed. +The `Alpha` filter can be used to return only alphabetic characters in the unicode "letter" category. +All other characters are suppressed. -This filter is part of the laminas-i18n package; you will need to include that -package in your application to use it. +This filter is part of the laminas-i18n package; you will need to include that package in your application to use it. ### Supported Options @@ -96,14 +90,13 @@ Alpha([ boolean $allowWhiteSpace [, string $locale ]]) ``` - `$allowWhiteSpace`: If set to true then whitespace characters are allowed. - Otherwise they are suppressed. Default is `false` (whitespace is not allowed). - Methods for getting/setting the allowWhiteSpace option are also available: - `getAllowWhiteSpace()` and `setAllowWhiteSpace()`. +Otherwise they are suppressed. +Default is `false` (whitespace is not allowed). +Methods for getting/setting the allowWhiteSpace option are also available: `getAllowWhiteSpace()` and `setAllowWhiteSpace()`. -- `$locale`: The locale string used in identifying the characters to filter - (locale name, e.g. `en_US`). If unset, it will use the default locale - (`Locale::getDefault()`). Methods for getting/setting the locale are also - available: `getLocale()` and `setLocale()`. +- `$locale`: The locale string used in identifying the characters to filter (locale name, e.g. `en_US`). +If unset, it will use the default locale (`Locale::getDefault()`). +Methods for getting/setting the locale are also available: `getLocale()` and `setLocale()`. ### Basic Usage @@ -122,14 +115,12 @@ echo $filter->filter('This is (my) content: 123'); > ### Supported Languages > > `Alpha` works on almost all languages, except: Chinese, Japanese and Korean. -> Within these languages, the english alphabet is used instead of the characters -> from these languages. The language itself is detected using the `Locale` -> class. +> Within these languages, the english alphabet is used instead of the characters from these languages. +> The language itself is detected using the `Locale` class. ## BaseName -`Laminas\Filter\BaseName` allows you to filter a string which contains the path to -a file, and it will return the base name of this file. +`Laminas\Filter\BaseName` allows you to filter a string which contains the path to a file, and it will return the base name of this file. ### Supported Options @@ -161,23 +152,22 @@ Use the [DenyList filter](#denylist) instead. ## Boolean -This filter changes a given input to be a `BOOLEAN` value. This is often useful when working with -databases or when processing form values. +This filter changes a given input to be a `BOOLEAN` value. +This is often useful when working with databases or when processing form values. ### Supported Options The following options are supported for `Laminas\Filter\Boolean`: -- `casting`: When this option is set to `TRUE`, then any given input will be - cast to boolean. This option defaults to `TRUE`. +- `casting`: When this option is set to `TRUE`, then any given input will be cast to boolean. +This option defaults to `TRUE`. - `translations`: This option sets the translations which will be used to detect localized input. -- `type`: The `type` option sets the boolean type which should be used. Read - the following for details. +- `type`: The `type` option sets the boolean type which should be used. +Read the following for details. ### Default Behavior -By default, this filter works by casting the input to a `BOOLEAN` value; in other words, it operates -in a similar fashion to calling `(boolean) $value`. +By default, this filter works by casting the input to a `BOOLEAN` value; in other words, it operates in a similar fashion to calling `(boolean) $value`. ```php $filter = new Laminas\Filter\Boolean(); @@ -186,13 +176,12 @@ $result = $filter->filter($value); // returns false ``` -This means that without providing any configuration, `Laminas\Filter\Boolean` accepts all input types -and returns a `BOOLEAN` just as you would get by type casting to `BOOLEAN`. +This means that without providing any configuration, `Laminas\Filter\Boolean` accepts all input types and returns a `BOOLEAN` just as you would get by type casting to `BOOLEAN`. ### Changing the Default Behavior -Sometimes, casting with `(boolean)` will not suffice. `Laminas\Filter\Boolean` -allows you to configure specific types to convert, as well as which to omit. +Sometimes, casting with `(boolean)` will not suffice. +`Laminas\Filter\Boolean` allows you to configure specific types to convert, as well as which to omit. The following types can be handled (in this precedence order): @@ -208,14 +197,16 @@ The following types can be handled (in this precedence order): There are 2 additional special types: -- `all`: Converts all above types to `BOOLEAN`. The same as setting all above types. -- `php`: Converts all above types to `BOOLEAN` except `localized` or `false`. The same as setting all above types except `localized` or `false`. +- `all`: Converts all above types to `BOOLEAN`. +The same as setting all above types. +- `php`: Converts all above types to `BOOLEAN` except `localized` or `false`. +The same as setting all above types except `localized` or `false`. All other given values will return `TRUE` by default. -There are several ways to select which of the above types are filtered. You can -give one or multiple types and add them, you can give an array, you can use -constants, or you can give a textual string. See the following examples: +There are several ways to select which of the above types are filtered. +You can give one or multiple types and add them, you can give an array, you can use constants, or you can give a textual string. +See the following examples: ```php // converts 0 to false @@ -252,8 +243,8 @@ As mentioned previously, `Laminas\Filter\Boolean` can also recognise localized " This means that you can ask your customer in a form for "yes" or "no" within his native language and `Laminas\Filter\Boolean` will convert the response to the appropriate boolean value. -To set the translation and the corresponding value, you can use the `translations` option or the -method `setTranslations`. The translations must be set for any values you wish to map to boolean values. +To set the translation and the corresponding value, you can use the `translations` option or the method `setTranslations`. +The translations must be set for any values you wish to map to boolean values. ```php $filter = new Laminas\Filter\Boolean([ @@ -275,24 +266,22 @@ $result = $filter->filter('yes'); ### Disable Casting -Sometimes it is necessary to recognise only `TRUE` or `FALSE` and return all -other values without changes. `Laminas\Filter\Boolean` allows you to do this by -setting the `casting` option to `FALSE`. - -In this case `Laminas\Filter\Boolean` will work as described in the following -table, which shows which values return `TRUE` or `FALSE`. All other given values -are returned without change when `casting` is set to `FALSE` - -Type Constant | Type String | True | False ----- | ---- | ---- | ----- -`Laminas\Filter\Boolean::TYPE_BOOLEAN` | `boolean` | `TRUE` | `FALSE` -`Laminas\Filter\Boolean::TYPE_EMPTY_ARRAY` | `array` | | `[]` -`Laminas\Filter\Boolean::TYPE_FALSE_STRING` | `false` | `'true'` (case insensitive) | `'false'` (case insensitive) -`Laminas\Filter\Boolean::TYPE_FLOAT` | `float` | `1.0` | `0.0` -`Laminas\Filter\Boolean::TYPE_INTEGER` | `integer` | `1` | `0` -`Laminas\Filter\Boolean::TYPE_NULL` | `null` | | `NULL` -`Laminas\Filter\Boolean::TYPE_STRING` | `string` | | `''` -`Laminas\Filter\Boolean::TYPE_ZERO_STRING` | `zero` | `'1'` | `'0'` +Sometimes it is necessary to recognise only `TRUE` or `FALSE` and return all other values without changes. +`Laminas\Filter\Boolean` allows you to do this by setting the `casting` option to `FALSE`. + +In this case `Laminas\Filter\Boolean` will work as described in the following table, which shows which values return `TRUE` or `FALSE`. +All other given values are returned without change when `casting` is set to `FALSE` + +| Type Constant | Type String | True | False | +|---------------------------------------------|-------------|-----------------------------|------------------------------| +| `Laminas\Filter\Boolean::TYPE_BOOLEAN` | `boolean` | `TRUE` | `FALSE` | +| `Laminas\Filter\Boolean::TYPE_EMPTY_ARRAY` | `array` | | `[]` | +| `Laminas\Filter\Boolean::TYPE_FALSE_STRING` | `false` | `'true'` (case insensitive) | `'false'` (case insensitive) | +| `Laminas\Filter\Boolean::TYPE_FLOAT` | `float` | `1.0` | `0.0` | +| `Laminas\Filter\Boolean::TYPE_INTEGER` | `integer` | `1` | `0` | +| `Laminas\Filter\Boolean::TYPE_NULL` | `null` | | `NULL` | +| `Laminas\Filter\Boolean::TYPE_STRING` | `string` | | `''` | +| `Laminas\Filter\Boolean::TYPE_ZERO_STRING` | `zero` | `'1'` | `'0'` | The following example shows the behavior when changing the `casting` option: @@ -314,9 +303,8 @@ $result = $filter->filter(2); ## Callback -This filter allows you to use own methods in conjunction with `Laminas\Filter`. You -don't have to create a new filter when you already have a method which does the -job. +This filter allows you to use own methods in conjunction with `Laminas\Filter`. +You don't have to create a new filter when you already have a method which does the job. ### Supported Options @@ -328,8 +316,8 @@ The following options are supported for `Laminas\Filter\Callback`: ### Basic Usage -The usage of this filter is quite simple. In this example, we want to create a -filter which reverses a string: +The usage of this filter is quite simple. +In this example, we want to create a filter which reverses a string: ```php $filter = new Laminas\Filter\Callback('strrev'); @@ -338,9 +326,8 @@ print $filter->filter('Hello!'); // returns "!olleH" ``` -As you can see it's really simple to use a callback to define custom filters. It -is also possible to use a method, which is defined within a class, by giving an -array as the callback: +As you can see it's really simple to use a callback to define custom filters. +It is also possible to use a method, which is defined within a class, by giving an array as the callback: ```php class MyClass @@ -366,19 +353,16 @@ $filter = new Laminas\Filter\Callback(MyClass::class); print $filter->filter('Hello!'); ``` -To get the actual set callback use `getCallback()` and to set another callback -use `setCallback()`. +To get the actual set callback use `getCallback()` and to set another callback use `setCallback()`. > ### Possible Exceptions > -> You should note that defining a callback method which can not be called will -> raise an exception. +> You should note that defining a callback method which can not be called will raise an exception. ### Default Parameters within a Callback -It is also possible to define default parameters, which are given to the called -method as an array when the filter is executed. This array will be concatenated -with the value which will be filtered. +It is also possible to define default parameters, which are given to the called method as an array when the filter is executed. +This array will be concatenated with the value which will be filtered. ```php $filter = new Laminas\Filter\Callback([ @@ -402,9 +386,10 @@ These two filters are capable of compressing and decompressing strings, files, a The following options are supported for `Laminas\Filter\Compress` and `Laminas\Filter\Decompress`: -- `adapter`: The compression adapter which should be used. It defaults to `Gz`. +- `adapter`: The compression adapter which should be used. +It defaults to `Gz`. - `options`: Additional options which are given to the adapter at initiation. - Each adapter supports its own options. +Each adapter supports its own options. ### Supported Compression Adapters @@ -417,23 +402,20 @@ The following compression formats are supported by their own adapter: - **Lzf** - **Rar** -Each compression format has different capabilities as described below. All -compression filters may be used in approximately the same ways, and differ -primarily in the options available and the type of compression they offer (both -algorithmically as well as string vs. file vs. directory) +Each compression format has different capabilities as described below. +All compression filters may be used in approximately the same ways, and differ primarily in the options available and the type of compression they offer (both algorithmically as well as string vs. file vs. directory) ### Generic Handling -To create a compression filter, you need to select the compression format you want to use. The -following example takes the **Bz2** adapter. Details for all other adapters are described after -this section. +To create a compression filter, you need to select the compression format you want to use. +The following example takes the **Bz2** adapter. +Details for all other adapters are described after this section. The two filters are basically identical, in that they utilize the same backends. `Laminas\Filter\Compress` should be used when you wish to compress items, and `Laminas\Filter\Decompress` should be used when you wish to decompress items. -For instance, if we want to compress a string, we have to initialize `Laminas\Filter\Compress` and -indicate the desired adapter: +For instance, if we want to compress a string, we have to initialize `Laminas\Filter\Compress` and indicate the desired adapter: ```php $filter = new Laminas\Filter\Compress('Bz2'); @@ -441,10 +423,8 @@ $filter = new Laminas\Filter\Compress('Bz2'); To use a different adapter, you simply specify it to the constructor. -You may also provide an array of options or a `Traversable` object. If you do, -provide minimally the key "adapter", and then either the key "options" or -"adapterOptions", both of which should be an array of options to provide to the -adapter on instantiation. +You may also provide an array of options or a `Traversable` object. +If you do, provide minimally the key "adapter", and then either the key "options" or "adapterOptions", both of which should be an array of options to provide to the adapter on instantiation. ```php $filter = new Laminas\Filter\Compress([ @@ -466,8 +446,8 @@ filter instead: $filter = new Laminas\Filter\Decompress('Bz2'); ``` -To get the compressed string, we have to give the original string. The filtered value is the -compressed version of the original string. +To get the compressed string, we have to give the original string. +The filtered value is the compressed version of the original string. ```php $filter = new Laminas\Filter\Compress('Bz2'); @@ -475,8 +455,7 @@ $compressed = $filter->filter('Uncompressed string'); // Returns the compressed string ``` -Decompression works in reverse, accepting the compressed string, and returning -the original: +Decompression works in reverse, accepting the compressed string, and returning the original: ```php $filter = new Laminas\Filter\Decompress('Bz2'); @@ -486,14 +465,14 @@ $compressed = $filter->filter('Compressed string'); > ### Note on String Compression > -> Not all adapters support string compression. Compression formats like **Rar** -> can only handle files and directories. For details, consult the section for -> the adapter you wish to use. +> Not all adapters support string compression. +> Compression formats like **Rar** can only handle files and directories. +> For details, consult the section for the adapter you wish to use. ### Creating an Archive -Creating an archive file works almost the same as compressing a string. However, in this case we -need an additional parameter which holds the name of the archive we want to create. +Creating an archive file works almost the same as compressing a string. +However, in this case we need an additional parameter which holds the name of the archive we want to create. ```php $filter = new Laminas\Filter\Compress([ @@ -506,8 +485,7 @@ $compressed = $filter->filter('Uncompressed string'); // Returns true on success, and creates the archive file ``` -In the above example, the uncompressed string is compressed, and is then written -into the given archive file. +In the above example, the uncompressed string is compressed, and is then written into the given archive file. > ### Existing Archives will be overwritten > @@ -527,9 +505,8 @@ $compressed = $filter->filter('C:\temp\compressme.txt'); // Returns true on success and creates the archive file ``` -You may also specify a directory instead of a filename. In this case the whole -directory with all its files and subdirectories will be compressed into the -archive: +You may also specify a directory instead of a filename. +In this case the whole directory with all its files and subdirectories will be compressed into the archive: ```php $filter = new Laminas\Filter\Compress([ @@ -551,8 +528,8 @@ $compressed = $filter->filter('C:\temp\somedir'); ### Decompressing an Archive -Decompressing an archive file works almost like compressing it. You must specify either the -`archive` parameter, or give the filename of the archive when you decompress the file. +Decompressing an archive file works almost like compressing it. +You must specify either the `archive` parameter, or give the filename of the archive when you decompress the file. ```php $filter = new Laminas\Filter\Decompress('Bz2'); @@ -560,8 +537,8 @@ $decompressed = $filter->filter('filename.bz2'); // Returns true on success and decompresses the archive file ``` -Some adapters support decompressing the archive into another subdirectory. In -this case you can set the `target` parameter: +Some adapters support decompressing the archive into another subdirectory. +In this case you can set the `target` parameter: ```php $filter = new Laminas\Filter\Decompress([ @@ -593,12 +570,12 @@ This adapter makes use of PHP's Bz2 extension. To customize compression, this adapter supports the following options: - `archive`: This parameter sets the archive file which should be used or created. -- `blocksize`: This parameter sets the blocksize to use. It can be from '0' to - '9'. The default value is '4'. +- `blocksize`: This parameter sets the blocksize to use. +It can be from '0' to '9'. +The default value is '4'. -All options can be set at instantiation or by using a related method; for example, the related -methods for 'blocksize' are `getBlocksize()` and `setBlocksize()`. You can also use the -`setOptions()` method, which accepts an array of all options. +All options can be set at instantiation or by using a related method; for example, the related methods for 'blocksize' are `getBlocksize()` and `setBlocksize()`. +You can also use the `setOptions()` method, which accepts an array of all options. ### Gz Adapter @@ -613,14 +590,16 @@ This adapter makes use of PHP's Zlib extension. To customize the compression this adapter supports the following options: - `archive`: This parameter sets the archive file which should be used or created. -- `level`: This compression level to use. It can be from '0' to '9'. The default - value is '9'. -- `mode`: There are two supported modes. `compress` and `deflate`. The default - value is `compress`. +- `level`: This compression level to use. +It can be from '0' to '9'. +The default value is '9'. +- `mode`: There are two supported modes. +`compress` and `deflate`. +The default value is `compress`. -All options can be set at initiation or by using a related method. For example, the related methods -for `level` are `getLevel()` and `setLevel()`. You can also use the `setOptions()` method which -accepts an array of all options. +All options can be set at initiation or by using a related method. +For example, the related methods for `level` are `getLevel()` and `setLevel()`. +You can also use the `setOptions()` method which accepts an array of all options. ### Lzf Adapter @@ -659,10 +638,8 @@ This adapter makes use of PHP's Rar extension. > ### Rar Compression not supported > -> Due to restrictions with the Rar compression format, there is no compression -> available for free. When you want to compress files into a new Rar archive, -> you must provide a callback to the adapter that can invoke a Rar compression -> program. +> Due to restrictions with the Rar compression format, there is no compression available for free. +> When you want to compress files into a new Rar archive, you must provide a callback to the adapter that can invoke a Rar compression program. To customize compression, this adapter supports the following options: @@ -671,9 +648,9 @@ To customize compression, this adapter supports the following options: - `password`: The password which has to be used for decompression. - `target`: The target where the decompressed files will be written to. -All options can be set at instantiation or by using a related method. For example, the related -methods for `target` are `getTarget()` and `setTarget()`. You can also use the `setOptions()` method -which accepts an array of all options. +All options can be set at instantiation or by using a related method. +For example, the related methods for `target` are `getTarget()` and `setTarget()`. +You can also use the `setOptions()` method which accepts an array of all options. ### Tar Adapter @@ -691,21 +668,19 @@ This adapter makes use of PEAR's `Archive_Tar` component. To customize compression, this adapter supports the following options: - `archive`: This parameter sets the archive file which should be used or created. -- `mode`: A mode to use for compression. Supported are either `NULL`, which - means no compression at all; `Gz`, which makes use of PHP's Zlib extension; - and `Bz2`, which makes use of PHP's Bz2 extension. The default value is `NULL`. +- `mode`: A mode to use for compression. +Supported are either `NULL`, which means no compression at all; `Gz`, which makes use of PHP's Zlib extension; and `Bz2`, which makes use of PHP's Bz2 extension. +The default value is `NULL`. - `target`: The target where the decompressed files will be written to. -All options can be set at instantiation or by using a related method. For -example, the related methods for `target` are `getTarget()` and `setTarget()`. -You can also use the `setOptions()` method which accepts an array of all -options. +All options can be set at instantiation or by using a related method. +For example, the related methods for `target` are `getTarget()` and `setTarget()`. +You can also use the `setOptions()` method which accepts an array of all options. > ### Directory Usage > -> When compressing directories with Tar, the complete file path is used. This -> means that created Tar files will not only have the subdirectory, but the -> complete path for the compressed file. +> When compressing directories with Tar, the complete file path is used. +> This means that created Tar files will not only have the subdirectory, but the complete path for the compressed file. ### Zip Adapter @@ -727,9 +702,9 @@ To customize compression, this adapter supports the following options: - `archive`: This parameter sets the archive file which should be used or created. - `target`: The target where the decompressed files will be written to. -All options can be set at instantiation or by using a related method. For example, the related -methods for `target` are `getTarget()` and `setTarget()`. You can also use the `setOptions()` method -which accepts an array of all options. +All options can be set at instantiation or by using a related method. +For example, the related methods for `target` are `getTarget()` and `setTarget()`. +You can also use the `setOptions()` method which accepts an array of all options. ## DenyList @@ -737,8 +712,8 @@ TIP: **New Feature** Available since version 2.12.0 Previously known as `Blacklist`. -This filter will return `null` if the value being filtered is present in the filter's list of -values. If the value is not present, it will return that value. +This filter will return `null` if the value being filtered is present in the filter's list of values. +If the value is not present, it will return that value. For the opposite functionality, see the [`AllowList` filter](#allowlist). @@ -818,9 +793,8 @@ These filters were deprecated in version 2.24.0 and will be removed in version 3 You are encouraged to implement your own encryption or decryption filters by implementing `FilterInterface` around a dedicated crypto library. See [Writing Filters](writing-filters.md) -These filters allow encrypting and decrypting any given string; they do so via -the use of adapters. Included adapters support `Laminas\Crypt\BlockCipher` and -PHP's OpenSSL extension. +These filters allow encrypting and decrypting any given string; they do so via the use of adapters. +Included adapters support `Laminas\Crypt\BlockCipher` and PHP's OpenSSL extension. ### Supported Options @@ -830,46 +804,39 @@ The following options are supported for `Laminas\Filter\Encrypt` and #### General Options - `adapter`: This sets the encryption adapter to use. -- `compression`: If the encrypted value should be compressed. Default is no - compression. +- `compression`: If the encrypted value should be compressed. +Default is no compression. #### BlockCipher Options -- `algorithm`: The algorithm to use with `Laminas\Crypt\Symmetric\Mcrypt` (use the - the `getSupportedAlgorithms()` method of that class to determine what is - supported). If not set, it defaults to `aes`, the Advanced Encryption Standard - (see the [laminas-crypt BlockCipher documentation](https://docs.laminas.dev/laminas-crypt/block-cipher/) - for details). -- `key`: The encryption key with which the input will be encrypted. You need the - same key for decryption. -- `mode`: The encryption mode to use. It should be a - [valid PHP mcrypt modes](http://php.net/manual/en/mcrypt.constants.php). - If not set, it defaults to 'cbc'. -- `mode_directory`: The directory where the mode can be found. If not set, it - defaults to the path set within the `Mcrypt` extension. -- `vector`: The initialization vector which shall be used. If not set, it will - be a random vector. +- `algorithm`: The algorithm to use with `Laminas\Crypt\Symmetric\Mcrypt` (use the the `getSupportedAlgorithms()` method of that class to determine what is supported). +If not set, it defaults to `aes`, the Advanced Encryption Standard (see the [laminas-crypt BlockCipher documentation](https://docs.laminas.dev/laminas-crypt/block-cipher/) for details). +- `key`: The encryption key with which the input will be encrypted. +You need the same key for decryption. +- `mode`: The encryption mode to use. +It should be a [valid PHP mcrypt modes](http://php.net/manual/en/mcrypt.constants.php). +If not set, it defaults to 'cbc'. +- `mode_directory`: The directory where the mode can be found. +If not set, it defaults to the path set within the `Mcrypt` extension. +- `vector`: The initialization vector which shall be used. +If not set, it will be a random vector. #### OpenSSL Options -- `envelope`: The encrypted envelope key from the user who encrypted the - content. You can either provide the path and filename of the key file, or just - the content of the key file itself. When the `package` option has been set, - then you can omit this parameter. +- `envelope`: The encrypted envelope key from the user who encrypted the content. +You can either provide the path and filename of the key file, or just the content of the key file itself. +When the `package` option has been set, then you can omit this parameter. - `package`: If the envelope key should be packed with the encrypted value. - Default is `FALSE`. -- `private`: The private key to use for encrypting the content. You can either - provide the path and filename of the key file, or just the content of the key - file itself. -- `public`: The public key of the user for whom you want to provide the - encrypted content. You can either provide the path and filename of the key - file, or just the content of the key file itself. +Default is `FALSE`. +- `private`: The private key to use for encrypting the content. +You can either provide the path and filename of the key file, or just the content of the key file itself. +- `public`: The public key of the user for whom you want to provide the encrypted content. +You can either provide the path and filename of the key file, or just the content of the key file itself. ### Adapter Usage -As these two encryption methodologies work completely different, the usage -of the adapters differ. You have to select the adapter you want to use when -initiating the filter. +As these two encryption methodologies work completely different, the usage of the adapters differ. +You have to select the adapter you want to use when initiating the filter. ```php // Use the BlockCipher adapter @@ -879,8 +846,7 @@ $filter1 = new Laminas\Filter\Encrypt(['adapter' => 'BlockCipher']); $filter2 = new Laminas\Filter\Encrypt(['adapter' => 'openssl']); ``` -To set another adapter, you can use `setAdapter()`; `getAdapter()` will return -the currently composed adapter. +To set another adapter, you can use `setAdapter()`; `getAdapter()` will return the currently composed adapter. ```php // Use the OpenSSL adapter @@ -895,9 +861,7 @@ $filter->setAdapter('openssl'); ### Encryption with BlockCipher -To encrypt a string using the `BlockCipher` adapter, you have to specify the -encryption key by either calling the `setKey()` method or passing it to the -constructor. +To encrypt a string using the `BlockCipher` adapter, you have to specify the encryption key by either calling the `setKey()` method or passing it to the constructor. ```php // Use the default AES encryption algorithm @@ -938,14 +902,11 @@ var_dump($filter->getEncryption()); > ### Default BlockCipher Algorithm > -> The `BlockCipher` adapter uses the [Mcrypt](http://php.net/mcrypt) extension -> by default. That means you will need to install the Mcrypt module in your PHP -> environment. +> The `BlockCipher` adapter uses the [Mcrypt](http://php.net/mcrypt) extension by default. +> That means you will need to install the Mcrypt module in your PHP environment. -If you don't specify an initialization Vector (salt or iv), the `BlockCipher` will -generate a random value during each encryption. If you try to execute the -following code, the output will always be different (note that even if the output -is always different, you can still decrypt it using the same key). +If you don't specify an initialization Vector (salt or iv), the `BlockCipher` will generate a random value during each encryption. +If you try to execute the following code, the output will always be different (note that even if the output is always different, you can still decrypt it using the same key). ```php $key = 'encryption key'; @@ -959,9 +920,8 @@ for ($i = 0; $i < 10; $i++) { } ``` -If you want to obtain the same output, you need to specify a fixed vector, using -the `setVector()` method. This following example always produces the same -encryption output: +If you want to obtain the same output, you need to specify a fixed vector, using the `setVector()` method. +This following example always produces the same encryption output: ```php // use the default adapter that is BlockCipher @@ -977,17 +937,15 @@ printf("%s\n", $filter->filter('message')); > ### Use different Vectors > -> For security purposes, it's always better to use a different vector on each -> encryption. We suggest using `setVector()` only in exceptional circumstances. +> For security purposes, it's always better to use a different vector on each encryption. +> We suggest using `setVector()` only in exceptional circumstances. ### Decryption with BlockCipher -For decrypting content previously encrypted with `BlockCipher`, you need to use -the same options used for encryption. +For decrypting content previously encrypted with `BlockCipher`, you need to use the same options used for encryption. If you used only the encryption key, you can just use it to decrypt the content. -As soon as you have provided all options, decryption works the same as -encryption. +As soon as you have provided all options, decryption works the same as encryption. ```php $content = '04636a6cb8276fad0787a2e187803b6557f77825d5ca6ed4392be702b9754bb3MTIzNDU2Nzg5MDEyMzQ1NgZ+zPwTGpV6gQqPKECinig='; @@ -1000,17 +958,13 @@ printf("Decrypt: %s\n", $filter->filter($content)); // Decrypt: message ``` -Note that even if we did not specify the same vector, the `BlockCipher` is able -to decrypt the message because the vector is stored in the encryption string -itself (note that the vector can be stored in plaintext; it is not a secret, and -only used to improve the randomness of the encryption algorithm). +Note that even if we did not specify the same vector, the `BlockCipher` is able to decrypt the message because the vector is stored in the encryption string itself (note that the vector can be stored in plaintext; it is not a secret, and only used to improve the randomness of the encryption algorithm). ### Encryption with OpenSSL -If you have installed the `OpenSSL` extension, you can also use the `OpenSSL` -adapter. You can get or set the public key either during instantiation, or later -via the `setPublicKey()` method. The private key can also be set after-the-fact -via the `setPrivateKey()` method. +If you have installed the `OpenSSL` extension, you can also use the `OpenSSL` adapter. +You can get or set the public key either during instantiation, or later via the `setPublicKey()` method. +The private key can also be set after-the-fact via the `setPrivateKey()` method. ```php // Use openssl and provide a private key @@ -1027,8 +981,7 @@ $filter->setPublicKey('/public/key/path/public.pem'); > > The `OpenSSL` adapter will not work with invalid or missing keys. -When you want to decode content encoded with a passphrase, you will not only -need the public key, but also the passphrase: +When you want to decode content encoded with a passphrase, you will not only need the public key, but also the passphrase: ```php // Use openssl and provide a private key @@ -1040,12 +993,10 @@ $filter = new Laminas\Filter\Encrypt([ ]); ``` -When providing the encrypted content to the recipient, you will also need to -ensure they have the passphrase and the envelope keys so they may decrypt the -message. You can get the envelope keys using the `getEnvelopeKey()` method: +When providing the encrypted content to the recipient, you will also need to ensure they have the passphrase and the envelope keys so they may decrypt the message. +You can get the envelope keys using the `getEnvelopeKey()` method: -A complete example for encrypting content with `OpenSSL` looks like the -following: +A complete example for encrypting content with `OpenSSL` looks like the following: ```php // Use openssl and provide a private key @@ -1065,13 +1016,11 @@ print $encrypted; ### Simplified usage with OpenSSL -As noted in the previous section, you need to provide the envelope key to the -recipient in order for them to decrypt the message. This adds complexity, -particularly if you are encrypting multiple values. +As noted in the previous section, you need to provide the envelope key to the recipient in order for them to decrypt the message. +This adds complexity, particularly if you are encrypting multiple values. -To simplify usage, you can set the `package` option to `TRUE` when creating your -`Encrypt` instance (the default value is `FALSE`). This will return a value -containing both the encrypted message *and* the envelope key: +To simplify usage, you can set the `package` option to `TRUE` when creating your `Encrypt` instance (the default value is `FALSE`). +This will return a value containing both the encrypted message *and* the envelope key: ```php // Use openssl and provide a private key @@ -1088,16 +1037,15 @@ print $encrypted; // For decryption look at the Decrypt filter ``` -Now the returned value contains the encrypted value and the envelope. You don't -need to fetch the envelope key separately. +Now the returned value contains the encrypted value and the envelope. +You don't need to fetch the envelope key separately. -However, there is one negative aspect to this: the encrypted value can now only -be decrypted by using `Laminas\Filter\Encrypt`. +However, there is one negative aspect to this: the encrypted value can now only be decrypted by using `Laminas\Filter\Encrypt`. ### Compressing Content -Based on the original value, the encrypted value can be a very large string. To -reduce the value, `Laminas\Filter\Encrypt` allows the usage of compression. +Based on the original value, the encrypted value can be a very large string. +To reduce the value, `Laminas\Filter\Encrypt` allows the usage of compression. The `compression` option can either be set to the name of a compression adapter, or to an array which sets all required options for the compression adapter. @@ -1130,9 +1078,7 @@ $filter2 = new Laminas\Filter\Encrypt([ ### Decryption with OpenSSL -Decryption with `OpenSSL` follows the same patterns as for encryption, with one -difference: you must have all data, including the envelope key, from the person -who encrypted the content. +Decryption with `OpenSSL` follows the same patterns as for encryption, with one difference: you must have all data, including the envelope key, from the person who encrypted the content. As an example: @@ -1163,8 +1109,7 @@ $filter->setEnvelopeKey('/key/from/encoder/envelope_key.pem'); Finally, you can decode the content. -Our complete example for decrypting the previously encrypted content looks like -this: +Our complete example for decrypting the previously encrypted content looks like this: ```php // Use openssl and provide a private key @@ -1185,7 +1130,8 @@ print $decrypted; This filter will ensure that, given a string that looks like a URI with a host-name and scheme, the scheme will be forced to `https` by default, or any other arbitrary scheme provided as an option. -Any value that cannot be identified as an URI to begin with, will be returned un-filtered. Furthermore, URI parsing is rudimentary so for reliable results, you should ensure that the input is a valid URI prior to filtering. +Any value that cannot be identified as an URI to begin with, will be returned un-filtered. +Furthermore, URI parsing is rudimentary so for reliable results, you should ensure that the input is a valid URI prior to filtering. ### Supported Options @@ -1209,24 +1155,21 @@ entity equivalents when possible. The following options are supported for `Laminas\Filter\HtmlEntities`: -- `quotestyle`: Equivalent to the PHP `htmlentities()` native function parameter - `quote_style`. This allows you to define what will be done with 'single' and - "double" quotes. The following constants are accepted: `ENT_COMPAT`, - `ENT_QUOTES`, and `ENT_NOQUOTES`, with the default being `ENT_COMPAT`. -- `charset`: Equivalent to the PHP `htmlentities()` native function parameter - `charset`. This defines the character set to be used in filtering. Unlike the - PHP native function, the default is 'UTF-8'. See the [PHP htmlentities - manual](http://php.net/htmlentities) for a list of supported character sets. - - This option can also be set via the `$options` parameter as a Traversable - object or array. The option key will be accepted as either `charset` or - `encoding`. -- `doublequote`: Equivalent to the PHP `htmlentities()` native function - parameter `double_encode`. If set to `false`, existing HTML entities will not - be encoded. The default is to convert everything (`true`). - - This option must be set via the `$options` parameter or the - `setDoubleEncode()` method. +- `quotestyle`: Equivalent to the PHP `htmlentities()` native function parameter `quote_style`. +This allows you to define what will be done with 'single' and "double" quotes. +The following constants are accepted: `ENT_COMPAT`, `ENT_QUOTES`, and `ENT_NOQUOTES`, with the default being `ENT_COMPAT`. +- `charset`: Equivalent to the PHP `htmlentities()` native function parameter `charset`. +This defines the character set to be used in filtering. +Unlike the PHP native function, the default is 'UTF-8'. +See the [PHP htmlentities manual](http://php.net/htmlentities) for a list of supported character sets. + +This option can also be set via the `$options` parameter as a Traversable object or array. +The option key will be accepted as either `charset` or `encoding`. +`doublequote`: Equivalent to the PHP `htmlentities()` native function parameter `double_encode`. +If set to `false`, existing HTML entities will not be encoded. +The default is to convert everything (`true`). + +This option must be set via the `$options` parameter or the `setDoubleEncode()` method. ### Basic Usage @@ -1238,8 +1181,8 @@ print $filter->filter('<'); ### Quote Style -`Laminas\Filter\HtmlEntities` allows changing the quote style used. This can be useful when you want to -leave double, single, or both types of quotes un-filtered. +`Laminas\Filter\HtmlEntities` allows changing the quote style used. +This can be useful when you want to leave double, single, or both types of quotes un-filtered. ```php $filter = new Laminas\Filter\HtmlEntities(['quotestyle' => ENT_QUOTES]); @@ -1248,8 +1191,8 @@ $input = "A 'single' and " . '"double"'; print $filter->filter($input); ``` -The above example returns `A 'single' and "double"`. Notice -that 'single' as well as "double" quotes are filtered. +The above example returns `A 'single' and "double"`. +Notice that 'single' as well as "double" quotes are filtered. ```php $filter = new Laminas\Filter\HtmlEntities(['quotestyle' => ENT_COMPAT]); @@ -1258,8 +1201,8 @@ $input = "A 'single' and " . '"double"'; print $filter->filter($input); ``` -The above example returns `A 'single' and "double"`. Notice that -"double" quotes are filtered while 'single' quotes are not altered. +The above example returns `A 'single' and "double"`. +Notice that "double" quotes are filtered while 'single' quotes are not altered. ```php $filter = new Laminas\Filter\HtmlEntities(['quotestyle' => ENT_NOQUOTES]); @@ -1268,15 +1211,13 @@ $input = "A 'single' and " . '"double"'; print $filter->filter($input); ``` -The above example returns `A 'single' and "double"`. Notice that neither -"double" or 'single' quotes are altered. +The above example returns `A 'single' and "double"`. +Notice that neither "double" or 'single' quotes are altered. ### Helper Methods -To change or retrieve the `quotestyle` after instantiation, the two methods -`setQuoteStyle()` and `getQuoteStyle()` may be used respectively. -`setQuoteStyle()` accepts one parameter, `$quoteStyle`, which accepts one of the -constants `ENT_COMPAT`, `ENT_QUOTES`, or `ENT_NOQUOTES`. +To change or retrieve the `quotestyle` after instantiation, the two methods `setQuoteStyle()` and `getQuoteStyle()` may be used respectively. +`setQuoteStyle()` accepts one parameter, `$quoteStyle`, which accepts one of the constants `ENT_COMPAT`, `ENT_QUOTES`, or `ENT_NOQUOTES`. ```php $filter = new Laminas\Filter\HtmlEntities(); @@ -1286,9 +1227,9 @@ print $filter->getQuoteStyle(ENT_QUOTES); ``` To change or retrieve the `charset` after instantiation, the two methods -`setCharSet()` and `getCharSet()` may be used respectively. `setCharSet()` -accepts one parameter, `$charSet`. See the [PHP htmlentities manual -page](http://php.net/htmlentities) for a list of supported character sets. +`setCharSet()` and `getCharSet()` may be used respectively. +`setCharSet()` accepts one parameter, `$charSet`. +See the [PHP htmlentities manual page](http://php.net/htmlentities) for a list of supported character sets. ```php $filter = new Laminas\Filter\HtmlEntities(); @@ -1297,9 +1238,8 @@ $filter->setQuoteStyle(ENT_QUOTES); print $filter->getQuoteStyle(ENT_QUOTES); ``` -To change or retrieve the `doublequote` option after instantiation, the two methods -`setDoubleQuote()` and `getDoubleQuote()` may be used respectively. `setDoubleQuote()` accepts one -boolean parameter, `$doubleQuote`. +To change or retrieve the `doublequote` option after instantiation, the two methods `setDoubleQuote()` and `getDoubleQuote()` may be used respectively. +`setDoubleQuote()` accepts one boolean parameter, `$doubleQuote`. ```php $filter = new Laminas\Filter\HtmlEntities(); @@ -1348,19 +1288,17 @@ This will return '-4'. ### Migration from 2.0-2.3 to 2.4+ -Version 2.4 adds support for PHP 7. In PHP 7, `int` is a reserved keyword, which required renaming -the `Int` filter. If you were using the `Int` filter directly previously, you will now receive an -`E_USER_DEPRECATED` notice on instantiation. Please update your code to refer to the `ToInt` class -instead. +Version 2.4 adds support for PHP 7. +In PHP 7, `int` is a reserved keyword, which required renaming the `Int` filter. +If you were using the `Int` filter directly previously, you will now receive an `E_USER_DEPRECATED` notice on instantiation. +Please update your code to refer to the `ToInt` class instead. -Users pulling their `Int` filter instance from the filter plugin manager receive a `ToInt` instance -instead starting in 2.4.0. +Users pulling their `Int` filter instance from the filter plugin manager receive a `ToInt` instance instead starting in 2.4.0. ## ToNull -This filter will change the given input to be `NULL` if it meets specific -criteria. This is often necessary when you work with databases and want to have -a `NULL` value instead of a boolean or any other type. +This filter will change the given input to be `NULL` if it meets specific criteria. +This is often necessary when you work with databases and want to have a `NULL` value instead of a boolean or any other type. ### Supported Options @@ -1380,16 +1318,14 @@ $result = $filter->filter($value); // returns null instead of the empty string ``` -This means that without providing any configuration, `Laminas\Filter\ToNull` will -accept all input types and return `NULL` in the same cases as `empty()`. +This means that without providing any configuration, `Laminas\Filter\ToNull` will accept all input types and return `NULL` in the same cases as `empty()`. Any other value will be returned as is, without any changes. ### Changing the Default Behavior -Sometimes it's not enough to filter based on `empty()`. Therefore -`Laminas\Filter\ToNull` allows you to configure which types will be converted, and -which not. +Sometimes it's not enough to filter based on `empty()`. +Therefore `Laminas\Filter\ToNull` allows you to configure which types will be converted, and which not. The following types can be handled: @@ -1399,11 +1335,12 @@ The following types can be handled: - `float`: Converts an float `0.0` value to `NULL`. - `string`: Converts an empty string `''` to `NULL`. - `zero`: Converts a string containing the single character zero (`'0'`) to `NULL`. -- `all`: Converts all above types to `NULL`. (This is the default behavior.) +- `all`: Converts all above types to `NULL`. +(This is the default behavior.) -There are several ways to select which of the above types are filtered. You can -give one or multiple types and add them, you can give an array, you can use -constants, or you can give a textual string. See the following examples: +There are several ways to select which of the above types are filtered. +You can give one or multiple types and add them, you can give an array, you can use constants, or you can give a textual string. +See the following examples: ```php // converts false to null @@ -1427,15 +1364,15 @@ $filter = new Laminas\Filter\ToNull([ ]); ``` -You can also give a `Traversable` or an array to set the wished types. To set -types afterwards use `setType()`. +You can also give a `Traversable` or an array to set the wished types. +To set types afterwards use `setType()`. ### Migration from 2.0-2.3 to 2.4+ -Version 2.4 adds support for PHP 7. In PHP 7, `null` is a reserved keyword, which required renaming -the `Null` filter. If you were using the `Null` filter directly previously, you will now receive an -`E_USER_DEPRECATED` notice on instantiation. Please update your code to refer to the `ToNull` class -instead. +Version 2.4 adds support for PHP 7. +In PHP 7, `null` is a reserved keyword, which required renaming the `Null` filter. +If you were using the `Null` filter directly previously, you will now receive an `E_USER_DEPRECATED` notice on instantiation. +Please update your code to refer to the `ToNull` class instead. Users pulling their `Null` filter instance from the filter plugin manager receive a `ToNull` instance instead starting in 2.4.0. @@ -1463,12 +1400,10 @@ $filter->filter(['muppet' => 'Kermit']); // ['muppet' => 'Kermit'] ## NumberFormat -The `NumberFormat` filter can be used to return locale-specific number and percentage strings. It -extends the `NumberParse` filter, which acts as wrapper for the `NumberFormatter` class within the -Internationalization extension (Intl). +The `NumberFormat` filter can be used to return locale-specific number and percentage strings. +It extends the `NumberParse` filter, which acts as wrapper for the `NumberFormatter` class within the Internationalization extension (Intl). -This filter is part of the laminas-i18n package; you will need to include that -package in your application to use it. +This filter is part of the laminas-i18n package; you will need to include that package in your application to use it. ### Supported Options @@ -1478,21 +1413,17 @@ The following options are supported for `NumberFormat`: NumberFormat([ string $locale [, int $style [, int $type ]]]) ``` -- `$locale`: (Optional) Locale in which the number would be formatted (locale - name, e.g. `en_US`). If unset, it will use the default locale - (`Locale::getDefault()`). Methods for getting/setting the locale are also - available: `getLocale()` and `setLocale()`. +- `$locale`: (Optional) Locale in which the number would be formatted (locale name, e.g. `en_US`). +If unset, it will use the default locale (`Locale::getDefault()`). +Methods for getting/setting the locale are also available: `getLocale()` and `setLocale()`. -- `$style`: (Optional) Style of the formatting, one of the - [format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle). - If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style. - Methods for getting/setting the format style are also available: `getStyle()` - and `setStyle()`. +- `$style`: (Optional) Style of the formatting, one of the [format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle). +If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style. +Methods for getting/setting the format style are also available: `getStyle()` and `setStyle()`. -- `$type`: (Optional) The [formatting type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types) - to use. If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default - type. Methods for getting/setting the format type are also available: - `getType()` and `setType()`. +- `$type`: (Optional) The [formatting type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types) to use. +If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default type. +Methods for getting/setting the format type are also available: `getType()` and `setType()`. ### Basic Usage @@ -1512,12 +1443,10 @@ echo $filter->filter(0.00123456789); ## NumberParse -The `NumberParse` filter can be used to parse a number from a string. It acts as -a wrapper for the `NumberFormatter` class within the Internationalization -extension (Intl). +The `NumberParse` filter can be used to parse a number from a string. +It acts as a wrapper for the `NumberFormatter` class within the Internationalization extension (Intl). -This filter is part of the laminas-i18n package; you will need to include that -package in your application to use it. +This filter is part of the laminas-i18n package; you will need to include that package in your application to use it. ### Supported Options @@ -1527,21 +1456,17 @@ The following options are supported for `NumberParse`: NumberParse([ string $locale [, int $style [, int $type ]]]) ``` -- `$locale`: (Optional) Locale in which the number would be parsed (locale name, - e.g. `en_US`). If unset, it will use the default locale - (`Locale::getDefault()`). Methods for getting/setting the locale are also - available: `getLocale()` and `setLocale()`. +- `$locale`: (Optional) Locale in which the number would be parsed (locale name, e.g. `en_US`). +If unset, it will use the default locale (`Locale::getDefault()`). +Methods for getting/setting the locale are also available: `getLocale()` and `setLocale()`. -- `$style`: (Optional) Style of the parsing, one of the - [format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle). - If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style. - Methods for getting/setting the parse style are also available: `getStyle()` - and `setStyle()`. +- `$style`: (Optional) Style of the parsing, one of the [format style constants](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.unumberformatstyle). +If unset, it will use `NumberFormatter::DEFAULT_STYLE` as the default style. +Methods for getting/setting the parse style are also available: `getStyle()` and `setStyle()`. -- `$type`: (Optional) The [parsing type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types) - to use. If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default - type. Methods for getting/setting the parse type are also available: - `getType()` and `setType()`. +- `$type`: (Optional) The [parsing type](http://www.php.net/manual/class.numberformatter.php#intl.numberformatter-constants.types) to use. +If unset, it will use `NumberFormatter::TYPE_DOUBLE` as the default type. +Methods for getting/setting the parse type are also available: `getType()` and `setType()`. ### Basic Usage @@ -1561,8 +1486,7 @@ echo $filter->filter('1,23456789E-3'); ## PregReplace -`Laminas\Filter\PregReplace` performs a search using regular expressions and replaces all found -elements. +`Laminas\Filter\PregReplace` performs a search using regular expressions and replaces all found elements. ### Supported Options @@ -1576,12 +1500,11 @@ The following options are supported for `Laminas\Filter\PregReplace`: To use this filter properly, you must give both options listed above. -The `pattern` option has to be given to set the pattern to search for. It can be -a string for a single pattern, or an array of strings for multiple patterns. +The `pattern` option has to be given to set the pattern to search for. +It can be a string for a single pattern, or an array of strings for multiple patterns. -The `replacement` option indicates the string to replace matches with, and can -contain placeholders for matched groups from the search `pattern`. The value may -be a string replacement, or an array of string replacements. +The `replacement` option indicates the string to replace matches with, and can contain placeholders for matched groups from the search `pattern`. +The value may be a string replacement, or an array of string replacements. ```php $filter = new Laminas\Filter\PregReplace([ @@ -1594,8 +1517,7 @@ $filter->filter($input); // returns 'Hi john!' ``` -You can also use `setPattern()` to set the pattern(s), and `setReplacement()` set -the replacement(s). +You can also use `setPattern()` to set the pattern(s), and `setReplacement()` set the replacement(s). ```php $filter = new Laminas\Filter\PregReplace(); @@ -1613,8 +1535,7 @@ For more complex usage, read the ## RealPath -This filter will resolve given links and pathnames, and returns the canonicalized -absolute pathnames. +This filter will resolve given links and pathnames, and returns the canonicalized absolute pathnames. ### Supported Options @@ -1625,13 +1546,12 @@ The following options are supported for `Laminas\Filter\RealPath`: ### Basic Usage -For any given link or pathname, its absolute path will be returned. References -to `/./`, `/../` and extra `/` sequences in the input path will be stripped. The -resulting path will not have any symbolic links, `/./`, or `/../` sequences. +For any given link or pathname, its absolute path will be returned. +References to `/./`, `/../` and extra `/` sequences in the input path will be stripped. +The resulting path will not have any symbolic links, `/./`, or `/../` sequences. -`Laminas\Filter\RealPath` will return `FALSE` on failure, e.g. if the file does not exist. On BSD -systems `Laminas\Filter\RealPath` doesn't fail if only the last path component doesn't exist, while -other systems will return `FALSE`. +`Laminas\Filter\RealPath` will return `FALSE` on failure, e.g. if the file does not exist. +On BSD systems `Laminas\Filter\RealPath` doesn't fail if only the last path component doesn't exist, while other systems will return `FALSE`. ```php $filter = new Laminas\Filter\RealPath(); @@ -1643,9 +1563,8 @@ $filtered = $filter->filter($path); ### Non-Existing Paths -Sometimes it is useful to get paths to files that do n0t exist; e.g., when you -want to get the real path for a path you want to create. You can then either -provide a `FALSE` `exists` value at initiation, or use `setExists()` to set it. +Sometimes it is useful to get paths to files that do not exist; e.g., when you want to get the real path for a path you want to create. +You can then either provide a `FALSE` `exists` value at initiation, or use `setExists()` to set it. ```php $filter = new Laminas\Filter\RealPath(false); @@ -1725,11 +1644,9 @@ print $filter->filter('SAMPLE'); ### Handling alternate Encoding -By default, `StringToLower` will only handle characters from the locale of your -server; characters from other charsets will be ignored. If you have the mbstring -extension, however, you can use the filter with other encodings. Pass the -desired encoding when initiating the `StringToLower` filter, or use the -`setEncoding()` method to change it. +By default, `StringToLower` will only handle characters from the locale of your server; characters from other charsets will be ignored. +If you have the mbstring extension, however, you can use the filter with other encodings. +Pass the desired encoding when initiating the `StringToLower` filter, or use the `setEncoding()` method to change it. ```php // using UTF-8 @@ -1770,8 +1687,7 @@ print $filter->filter('Sample'); ### Different encoded Strings -Like the `StringToLower` filter, this filter will only handle characters -supported by your server locale, unless you have the mbstring extension enabled. +Like the `StringToLower` filter, this filter will only handle characters supported by your server locale, unless you have the mbstring extension enabled. Using different character sets works the same as with `StringToLower`. ```php @@ -1783,16 +1699,14 @@ $filter->setEncoding('ISO-8859-1'); ## StringTrim -This filter modifies a given string such that certain characters are removed -from the beginning and end. +This filter modifies a given string such that certain characters are removed from the beginning and end. ### Supported Options The following options are supported for `Laminas\Filter\StringTrim`: -- `charlist`: List of characters to remove from the beginning and end of the - string. If this is not set or is null, the default behavior will be invoked, - which is to remove only whitespace from the beginning and end of the string. +- `charlist`: List of characters to remove from the beginning and end of the string. +If this is not set or is null, the default behavior will be invoked, which is to remove only whitespace from the beginning and end of the string. ### Basic Usage @@ -1802,8 +1716,8 @@ $filter = new Laminas\Filter\StringTrim(); print $filter->filter(' This is (my) content: '); ``` -The above example returns `This is (my) content:`. Notice that the whitespace -characters have been removed. +The above example returns `This is (my) content:`. +Notice that the whitespace characters have been removed. ### Specifying alternate Characters @@ -1814,16 +1728,15 @@ $filter = new Laminas\Filter\StringTrim(':'); print $filter->filter(' This is (my) content:'); ``` -The above example returns `This is (my) content`. Notice that the whitespace -characters and colon are removed. You can also provide a `Traversable` or an -array with a `charlist` key. To set the desired character list after -instantiation, use the `setCharList()` method. `getCharList()` returns the -current character list. +The above example returns `This is (my) content`. +Notice that the whitespace characters and colon are removed. +You can also provide a `Traversable` or an array with a `charlist` key. +To set the desired character list after instantiation, use the `setCharList()` method. +`getCharList()` returns the current character list. ## StripNewlines -This filter modifies a given string and removes all new line characters within -that string. +This filter modifies a given string and removes all new line characters within that string. ### Supported Options @@ -1837,8 +1750,8 @@ $filter = new Laminas\Filter\StripNewlines(); print $filter->filter(' This is (my)``\n\r``content: '); ``` -The above example returns `This is (my) content:`. Notice that all newline -characters have been removed. +The above example returns `This is (my) content:`. +Notice that all newline characters have been removed. ## StripTags @@ -1846,22 +1759,19 @@ This filter can strip XML and HTML tags from given content. > ### Laminas\\Filter\\StripTags is potentially insecure > -> Be warned that `Laminas\\Filter\\StripTags` should only be used to strip *all* -> available tags. Using `Laminas\\Filter\\StripTags` to make your site secure by -> stripping *some* unwanted tags will lead to unsecure and dangerous code, -> including potential XSS vectors. +> Be warned that `Laminas\\Filter\\StripTags` should only be used to strip *all* available tags. +> Using `Laminas\\Filter\\StripTags` to make your site secure by stripping *some* unwanted tags will lead to unsecure and dangerous code, including potential XSS vectors. > -> For a fully secure solution that allows selected filtering of HTML tags, use -> either Tidy or HtmlPurifier. +> For a fully secure solution that allows selected filtering of HTML tags, use either Tidy or HtmlPurifier. ### Supported Options The following options are supported for `Laminas\Filter\StripTags`: -- `allowAttribs`: This option sets the attributes which are accepted. All other - attributes are stripped from the given content. -- `allowTags`: This option sets the tags which are accepted. All other tags will - be stripped from; the given content. +- `allowAttribs`: This option sets the attributes which are accepted. +All other attributes are stripped from the given content. +- `allowTags`: This option sets the tags which are accepted. +All other tags will be stripped from; the given content. ### Basic Usage @@ -1873,8 +1783,7 @@ print $filter->filter('My content'); The result will be the stripped content `My content`. -When the content contains broken or partial tags, any content following the -opening tag will be completely removed: +When the content contains broken or partial tags, any content following the opening tag will be completely removed: ```php $filter = new Laminas\Filter\StripTags(); @@ -1886,8 +1795,8 @@ The above will return `This contains`, with the rest being stripped. ### Allowing defined Tags -`Laminas\Filter\StripTags` allows stripping all but an allowed set of tags. As an -example, this can be used to strip all markup except for links: +`Laminas\Filter\StripTags` allows stripping all but an allowed set of tags. +As an example, this can be used to strip all markup except for links: ```php $filter = new Laminas\Filter\StripTags(['allowTags' => 'a']); @@ -1896,14 +1805,13 @@ $input = "A text with
a link"; print $filter->filter($input); ``` -The above will return `A text with a link`; -it strips all tags but the link. By providing an array, you can specify multiple -tags at once. +The above will return `A text with a link`; it strips all tags but the link. +By providing an array, you can specify multiple tags at once. > ### Warning > -> Do not use this feature to secure content. This component does not replace the -> use of a properly configured html filter. +> Do not use this feature to secure content. +> This component does not replace the use of a properly configured html filter. ### Allowing defined Attributes @@ -1919,15 +1827,12 @@ $input = "A text with
a picture" print $filter->filter($input); ``` -The above will return `A text with a picture`; it -strips all tags but ``, and all attributes but `src` from those tags.By -providing an array you can set multiple attributes at once. +The above will return `A text with a picture`; it strips all tags but ``, and all attributes but `src` from those tags.By providing an array you can set multiple attributes at once. ### Allow specific Tags with specific Attributes -You can also pass the tag allow list as a set of tag/attribute values. Each key -will be an allowed tag, pointing to a list of allowed attributes for that -tag. +You can also pass the tag allow list as a set of tag/attribute values. +Each key will be an allowed tag, pointing to a list of allowed attributes for that tag. ```php $allowedElements = [ @@ -1953,7 +1858,8 @@ as the result. ## UriNormalize CAUTION: **Deprecated** -This filter is deprecated since version 2.36.0 and will be removed in version 3.0. The ability to force the scheme has been moved to the [ForceUriScheme filter](#forceurischeme). +This filter is deprecated since version 2.36.0 and will be removed in version 3.0. +The ability to force the scheme has been moved to the [ForceUriScheme filter](#forceurischeme). This filter sets the scheme on a URI if the scheme is missing. diff --git a/docs/book/v2/static-filter.md b/docs/book/v2/static-filter.md index 5eae7260..10346af4 100644 --- a/docs/book/v2/static-filter.md +++ b/docs/book/v2/static-filter.md @@ -3,13 +3,10 @@ CAUTION: **Deprecated** This filter is deprecated since version 2.15.0 and [will be removed](migration/preparing-for-v3.md#static-filter-removal) in version 3.0. -If it is inconvenient to load a given filter class and create an instance of -the filter, you can use `StaticFilter` with it's method `execute()` as an -alternative invocation style. The first argument of this method is a data input -value that you would pass to the `filter()` method. The second argument is a -string, which corresponds to the basename of the filter class, relative to the -`Laminas\Filter` namespace. The `execute()` method automatically loads the class, -creates an instance, and applies the `filter()` method to the data input. +If it is inconvenient to load a given filter class and create an instance of the filter, you can use `StaticFilter` with it's method `execute()` as an alternative invocation style. +The first argument of this method is a data input value that you would pass to the `filter()` method. +The second argument is a string, which corresponds to the basename of the filter class, relative to the `Laminas\Filter` namespace. +The `execute()` method automatically loads the class, creates an instance, and applies the `filter()` method to the data input. ```php echo StaticFilter::execute('&', 'HtmlEntities'); @@ -25,18 +22,14 @@ echo StaticFilter::execute( ); ``` -The static usage can be convenient for invoking a filter ad hoc, but if you -have the need to run a filter for multiple inputs, it's more efficient to -create an instance of the filter and invoke it. instance of the filter object -and calling its `filter()` method. +The static usage can be convenient for invoking a filter ad hoc, but if you have the need to run a filter for multiple inputs, it's more efficient to create an instance of the filter and invoke it. +instance of the filter object and calling its `filter()` method. -Additionally, [filter chains](filter-chains.md) allow you to instantiate and run multiple filters -on demand to process sets of input data. +Additionally, [filter chains](filter-chains.md) allow you to instantiate and run multiple filters on demand to process sets of input data. ## Using custom Filters -You can set and receive the `FilterPluginManager` for the `StaticFilter` to -amend the standard filter classes: +You can set and receive the `FilterPluginManager` for the `StaticFilter` to amend the standard filter classes: ```php $pluginManager = StaticFilter::getPluginManager() diff --git a/docs/book/v2/word.md b/docs/book/v2/word.md index 7e1f6540..ba57f516 100644 --- a/docs/book/v2/word.md +++ b/docs/book/v2/word.md @@ -1,7 +1,6 @@ # Word Filters -In addition to the standard set of filters, there are several classes specific -to filtering word strings. +In addition to the standard set of filters, there are several classes specific to filtering word strings. ## CamelCaseToDash @@ -29,8 +28,8 @@ This filter modifies a given string such that `CamelCaseWords` are converted to The following options are supported for `Laminas\Filter\Word\CamelCaseToSeparator`: -- `separator`: A separator character. If this is not set, the default separator - is a space. +- `separator`: A separator character. +If this is not set, the default separator is a space. ### Basic Usage @@ -74,8 +73,7 @@ The above example returns `This_Is_My_Content`. ## DashToCamelCase -This filter modifies a given string such that `words-with-dashes` are converted -to `WordsWithDashes`. +This filter modifies a given string such that `words-with-dashes` are converted to `WordsWithDashes`. ### Supported Options @@ -93,15 +91,14 @@ The above example returns `ThisIsMyContent`. ## DashToSeparator -This filter modifies a given string such that `words-with-dashes` are converted -to `words with dashes`. +This filter modifies a given string such that `words-with-dashes` are converted to `words with dashes`. ### Supported Options The following options are supported for `Laminas\Filter\Word\DashToSeparator`: -- `separator`: A separator character. If this is not set, the default separator - is a space. +- `separator`: A separator character. +If this is not set, the default separator is a space. ### Basic Usage @@ -126,8 +123,7 @@ The above example returns `this is my content`. ## DashToUnderscore -This filter modifies a given string such that `words-with-dashes` are converted -to `words_with_dashes`. +This filter modifies a given string such that `words-with-dashes` are converted to `words_with_dashes`. ### Supported Options @@ -145,15 +141,14 @@ The above example returns `this_is_my_content`. ## SeparatorToCamelCase -This filter modifies a given string such that `words with separators` are -converted to `WordsWithSeparators`. +This filter modifies a given string such that `words with separators` are converted to `WordsWithSeparators`. ### Supported Options The following options are supported for `Laminas\Filter\Word\SeparatorToCamelCase`: -- `separator`: A separator character. If this is not set, the default separator - is a space. +- `separator`: A separator character. +If this is not set, the default separator is a space. ### Basic Usage @@ -178,15 +173,14 @@ The above example returns `ThisIsMyContent`. ## SeparatorToDash -This filter modifies a given string such that `words with separators` are -converted to `words-with-separators`. +This filter modifies a given string such that `words with separators` are converted to `words-with-separators`. ### Supported Options The following options are supported for `Laminas\Filter\Word\SeparatorToDash`: -- `separator`: A separator character. If this is not set, the default separator - is a space. +- `separator`: A separator character. +If this is not set, the default separator is a space. ### Basic Usage @@ -211,17 +205,16 @@ The above example returns `this-is-my-content`. ## SeparatorToSeparator -This filter modifies a given string such that `words with separators` are -converted to `words-with-separators`. +This filter modifies a given string such that `words with separators` are converted to `words-with-separators`. ### Supported Options The following options are supported for `Laminas\Filter\Word\SeparatorToSeparator`: -- `searchSeparator`: The search separator character. If this is not set, the - default separator is a space. -- `replaceSeparator`: The replacement separator character. If this is not set, the - default separator is a dash (`-`). +- `searchSeparator`: The search separator character. +If this is not set, the default separator is a space. +- `replaceSeparator`: The replacement separator character. +If this is not set, the default separator is a dash (`-`). ### Basic Usage @@ -245,8 +238,7 @@ The above example returns `this-is-my-content`. ## UnderscoreToCamelCase -This filter modifies a given string such that `words_with_underscores` are -converted to `WordsWithUnderscores`. +This filter modifies a given string such that `words_with_underscores` are converted to `WordsWithUnderscores`. ### Supported Options @@ -264,15 +256,14 @@ The above example returns `ThisIsMyContent`. ## UnderscoreToSeparator -This filter modifies a given string such that `words_with_underscores` are -converted to `words with underscores`. +This filter modifies a given string such that `words_with_underscores` are converted to `words with underscores`. ### Supported Options The following options are supported for `Laminas\Filter\Word\UnderscoreToSeparator`: -- `separator`: A separator character. If this is not set, the default separator - is a space. +- `separator`: A separator character. +If this is not set, the default separator is a space. ### Basic Usage @@ -297,8 +288,7 @@ The above example returns `this is my content`. ## UnderscoreToDash -This filter modifies a given string such that `words_with_underscores` are -converted to `words-with-underscores`. +This filter modifies a given string such that `words_with_underscores` are converted to `words-with-underscores`. ### Supported Options diff --git a/docs/book/v2/writing-filters.md b/docs/book/v2/writing-filters.md index 48552743..55607ca7 100644 --- a/docs/book/v2/writing-filters.md +++ b/docs/book/v2/writing-filters.md @@ -1,9 +1,7 @@ # Writing Filters -`Laminas\Filter` supplies a set of commonly needed filters, but developers will -often need to write custom filters for their particular use cases. You can do -so by writing classes that implement `Laminas\Filter\FilterInterface`, which -defines a single method, `filter()`. +`Laminas\Filter` supplies a set of commonly needed filters, but developers will often need to write custom filters for their particular use cases. +You can do so by writing classes that implement `Laminas\Filter\FilterInterface`, which defines a single method, `filter()`. ## Example From cc7715ed7cb2bde3393801563382aefe927ebbb1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 02:18:18 +0000 Subject: [PATCH 11/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 64 +++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/composer.lock b/composer.lock index 09e18ce3..fab6dc02 100644 --- a/composer.lock +++ b/composer.lock @@ -440,16 +440,16 @@ }, { "name": "composer/pcre", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", "shasum": "" }, "require": { @@ -459,8 +459,8 @@ "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.10", - "phpstan/phpstan-strict-rules": "^1.1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", "phpunit/phpunit": "^8 || ^9" }, "type": "library", @@ -499,7 +499,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.1" + "source": "https://github.com/composer/pcre/tree/3.3.2" }, "funding": [ { @@ -515,7 +515,7 @@ "type": "tidelift" } ], - "time": "2024-08-27T18:44:43+00:00" + "time": "2024-11-12T16:29:46+00:00" }, { "name": "composer/semver", @@ -2084,16 +2084,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.5.1", + "version": "5.6.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", + "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", "shasum": "" }, "require": { @@ -2102,7 +2102,7 @@ "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", "webmozart/assert": "^1.9.1" }, "require-dev": { @@ -2142,9 +2142,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" }, - "time": "2024-11-06T11:58:54+00:00" + "time": "2024-11-12T11:25:25+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3942,16 +3942,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", "shasum": "" }, "require": { @@ -4018,20 +4018,20 @@ "type": "open_collective" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2024-11-16T12:02:36+00:00" }, { "name": "symfony/console", - "version": "v6.4.14", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b" + "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/897c2441ed4eec8a8a2c37b943427d24dba3f26b", - "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b", + "url": "https://api.github.com/repos/symfony/console/zipball/f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", + "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", "shasum": "" }, "require": { @@ -4096,7 +4096,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.14" + "source": "https://github.com/symfony/console/tree/v6.4.15" }, "funding": [ { @@ -4112,7 +4112,7 @@ "type": "tidelift" } ], - "time": "2024-11-05T15:34:40+00:00" + "time": "2024-11-06T14:19:14+00:00" }, { "name": "symfony/deprecation-contracts", @@ -4650,16 +4650,16 @@ }, { "name": "symfony/string", - "version": "v6.4.13", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627" + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", + "url": "https://api.github.com/repos/symfony/string/zipball/73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", "shasum": "" }, "require": { @@ -4716,7 +4716,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.13" + "source": "https://github.com/symfony/string/tree/v6.4.15" }, "funding": [ { @@ -4732,7 +4732,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:18:03+00:00" + "time": "2024-11-13T13:31:12+00:00" }, { "name": "theseer/tokenizer", From 70bcaadebc5d066b091da55f9b93f894d3739311 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:03:46 +0000 Subject: [PATCH 12/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index fab6dc02..42a04408 100644 --- a/composer.lock +++ b/composer.lock @@ -1805,16 +1805,16 @@ }, { "name": "pear/pear-core-minimal", - "version": "v1.10.15", + "version": "v1.10.16", "source": { "type": "git", "url": "https://github.com/pear/pear-core-minimal.git", - "reference": "ce0adade8b97561656ace07cdaac4751c271ea8c" + "reference": "c0f51b45f50683bf5bbf558036854ebc9b54d033" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/ce0adade8b97561656ace07cdaac4751c271ea8c", - "reference": "ce0adade8b97561656ace07cdaac4751c271ea8c", + "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/c0f51b45f50683bf5bbf558036854ebc9b54d033", + "reference": "c0f51b45f50683bf5bbf558036854ebc9b54d033", "shasum": "" }, "require": { @@ -1850,7 +1850,7 @@ "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR", "source": "https://github.com/pear/pear-core-minimal" }, - "time": "2024-03-16T18:41:45+00:00" + "time": "2024-11-24T22:27:58+00:00" }, { "name": "pear/pear_exception", From 07ca38d531c2be11027b15db574f5fb49023a3bd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 01:26:56 +0000 Subject: [PATCH 13/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.lock b/composer.lock index 42a04408..65716638 100644 --- a/composer.lock +++ b/composer.lock @@ -1433,16 +1433,16 @@ }, { "name": "laminas/laminas-validator", - "version": "2.64.1", + "version": "2.64.2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-validator.git", - "reference": "9db115056b666b7540c951b6d4477b8e0b52b9ad" + "reference": "771e504760448ac7af660710237ceb93be602e08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/9db115056b666b7540c951b6d4477b8e0b52b9ad", - "reference": "9db115056b666b7540c951b6d4477b8e0b52b9ad", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/771e504760448ac7af660710237ceb93be602e08", + "reference": "771e504760448ac7af660710237ceb93be602e08", "shasum": "" }, "require": { @@ -1513,7 +1513,7 @@ "type": "community_bridge" } ], - "time": "2024-08-01T09:32:54+00:00" + "time": "2024-11-26T21:29:17+00:00" }, { "name": "myclabs/deep-copy", @@ -4116,16 +4116,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -4163,7 +4163,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -4179,7 +4179,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/filesystem", @@ -4567,16 +4567,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { @@ -4630,7 +4630,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -4646,7 +4646,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/string", @@ -4859,11 +4859,11 @@ "type": "project", "extra": { "branch-alias": { - "dev-master": "5.x-dev", - "dev-4.x": "4.x-dev", - "dev-3.x": "3.x-dev", + "dev-1.x": "1.x-dev", "dev-2.x": "2.x-dev", - "dev-1.x": "1.x-dev" + "dev-3.x": "3.x-dev", + "dev-4.x": "4.x-dev", + "dev-master": "5.x-dev" } }, "autoload": { From 37164aef068fadfca11b6cbe5c9c88d57e510487 Mon Sep 17 00:00:00 2001 From: George Steel Date: Wed, 4 Dec 2024 22:10:03 +0000 Subject: [PATCH 14/27] Deprecate legacy compression related adapters and filter Signed-off-by: George Steel --- psalm-baseline.xml | 225 ++++++++++++++++++ src/Compress.php | 3 + src/Compress/AbstractCompressionAlgorithm.php | 4 + src/Compress/Bz2.php | 4 + .../CompressionAlgorithmInterface.php | 4 + src/Compress/Gz.php | 4 + src/Compress/Tar.php | 4 + src/Compress/Zip.php | 4 + src/Decompress.php | 3 + 9 files changed, 255 insertions(+) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index d77cc748..1677e983 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -167,6 +167,16 @@ + + + + + + + ]]> + |null|AdapterTypeOrInstance]]> + + @@ -191,6 +201,9 @@
+ + + @@ -202,6 +215,13 @@ + + + + + + + @@ -230,6 +250,13 @@ + + + + + + + @@ -272,6 +299,9 @@ + + + @@ -281,6 +311,13 @@ + + + + + + + @@ -319,6 +356,9 @@ + + + @@ -340,6 +380,13 @@ + + + + + + + @@ -388,6 +435,13 @@ + + + + + + + @@ -475,6 +529,9 @@ + + + @@ -591,6 +648,10 @@ + + compression)]]> + compression)]]> + @@ -688,6 +749,10 @@ compression]]> compression]]> + + compression)]]> + compression)]]> + @@ -1075,6 +1140,16 @@ + + + + + + + + + + @@ -1683,6 +1758,20 @@ + + + + + + + + + + + + + 8])]]> + @@ -1696,6 +1785,20 @@ + + + + + + + + + + + + 8])]]> + 'deflate'])]]> + @@ -1725,7 +1828,118 @@ + + + $this->tmp . '/compressed.tar', + 'target' => $this->tmp . '/_compress', + ] + )]]> + $this->tmp . '/compressed.tar', + 'target' => $this->tmp . '/zipextracted.txt', + ] + )]]> + $this->tmp . '/compressed.tar', + 'target' => $this->tmp . '/zipextracted.txt', + ] + )]]> + + + + + + $this->tmp . '/compressed.tar', + 'target' => $this->tmp . '/zipextracted.txt', + ])]]> + $target, + ])]]> + + + + + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/_compress', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/_compress', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/_compress', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/_compress', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/zipextracted.txt', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp . '/zipextracted.txt', + ] + )]]> + $this->tmp . '/compressed.zip', + 'target' => $this->tmp, + ] + )]]> + $this->tmp . '/_compress', + ] + )]]> + + + + + + + + + + + + + + + + + + + + + + $filterType, + 'options' => [ + 'archive' => 'test.txt', + ], + ])]]> + @@ -1759,6 +1973,17 @@ + + + + + + + + + + + diff --git a/src/Compress.php b/src/Compress.php index 501870e5..381d0fa6 100644 --- a/src/Compress.php +++ b/src/Compress.php @@ -20,6 +20,9 @@ /** * Compresses a given string * + * @deprecated Since 2.40.0. This filter will be removed in 3.0 and replaced with `CompressString` and + * `CompressToArchive` + * * @psalm-type AdapterType = 'Bz2'|'Gz'|'Lzf'|'Rar'|'Snappy'|'Tar'|'Zip' * @psalm-type AdapterTypeOrInstance = Compress\CompressionAlgorithmInterface|AdapterType * @psalm-type Options = array{ diff --git a/src/Compress/AbstractCompressionAlgorithm.php b/src/Compress/AbstractCompressionAlgorithm.php index 17fc58d2..36b9dcf9 100644 --- a/src/Compress/AbstractCompressionAlgorithm.php +++ b/src/Compress/AbstractCompressionAlgorithm.php @@ -13,6 +13,10 @@ /** * Abstract compression adapter * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. + * * @template TOptions of array */ abstract class AbstractCompressionAlgorithm implements CompressionAlgorithmInterface diff --git a/src/Compress/Bz2.php b/src/Compress/Bz2.php index f3d6e215..4355451c 100644 --- a/src/Compress/Bz2.php +++ b/src/Compress/Bz2.php @@ -20,6 +20,10 @@ /** * Compression adapter for Bz2 * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. + * * @psalm-type Options = array{ * blocksize?: int, * archive?: string|null, diff --git a/src/Compress/CompressionAlgorithmInterface.php b/src/Compress/CompressionAlgorithmInterface.php index 57a421e1..0b7fa724 100644 --- a/src/Compress/CompressionAlgorithmInterface.php +++ b/src/Compress/CompressionAlgorithmInterface.php @@ -6,6 +6,10 @@ /** * Compression interface + * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. */ interface CompressionAlgorithmInterface { diff --git a/src/Compress/Gz.php b/src/Compress/Gz.php index 74b7def8..b089608c 100644 --- a/src/Compress/Gz.php +++ b/src/Compress/Gz.php @@ -30,6 +30,10 @@ /** * Compression adapter for Gzip (ZLib) * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. + * * @psalm-type Options = array{ * level?: int, * mode?: string, diff --git a/src/Compress/Tar.php b/src/Compress/Tar.php index bbd7078f..85b498a4 100644 --- a/src/Compress/Tar.php +++ b/src/Compress/Tar.php @@ -24,6 +24,10 @@ /** * Compression adapter for Tar * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. + * * @psalm-type Options = array{ * archive?: string|null, * target?: string, diff --git a/src/Compress/Zip.php b/src/Compress/Zip.php index aa574392..984000d9 100644 --- a/src/Compress/Zip.php +++ b/src/Compress/Zip.php @@ -27,6 +27,10 @@ /** * Compression adapter for zip * + * @deprecated Since 2.40.0 Compression adapters will be split into multiple interfaces to clearly separate the + * capability of the underlying compression or archive format. For example, tar cannot compress strings and + * GZ cannot be used to create multi-file archives. + * * @psalm-type Options = array{ * archive?: string|null, * password?: string|null, diff --git a/src/Decompress.php b/src/Decompress.php index ab3f5511..db0d176f 100644 --- a/src/Decompress.php +++ b/src/Decompress.php @@ -9,6 +9,9 @@ /** * Decompresses a given string * + * @deprecated Since 2.40.0. This filter will be removed in 3.0 and replaced with `DecompressString` and + * `DecompressArchive` + * * @final */ class Decompress extends Compress From ce73e754efaf3c4281d776cbb89f88aca0721dc9 Mon Sep 17 00:00:00 2001 From: George Steel Date: Wed, 4 Dec 2024 22:44:10 +0000 Subject: [PATCH 15/27] Deprecate `FilterProviderInterface` This interface is MVC Module Manager specific and oes not belong in this library Signed-off-by: George Steel --- src/FilterProviderInterface.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/FilterProviderInterface.php b/src/FilterProviderInterface.php index 0a075cc4..70b6c993 100644 --- a/src/FilterProviderInterface.php +++ b/src/FilterProviderInterface.php @@ -7,6 +7,8 @@ /** * Implement this interface within Module classes to indicate that your module * provides filter configuration for the FilterPluginManager. + * + * @deprecated Since 2.40.0 This interface will be removed in version 3.0 without replacement */ interface FilterProviderInterface { From 4a314bc112f2eadd95e18362d50a7fd42b8a1757 Mon Sep 17 00:00:00 2001 From: George Steel Date: Wed, 4 Dec 2024 23:13:59 +0000 Subject: [PATCH 16/27] Deprecate legacy module manager affordances Signed-off-by: George Steel --- src/Module.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Module.php b/src/Module.php index a03522ca..2b5dd094 100644 --- a/src/Module.php +++ b/src/Module.php @@ -23,6 +23,8 @@ public function getConfig() /** * Register a specification for the FilterManager with the ServiceListener. * + * @deprecated Since 2.40.0 This method is not necessary for module manager and will be removed in 3.0 + * * @param ModuleManager $moduleManager * @return void */ From 38e4d813f7916c52666708227bf19d3088a6984f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 00:38:42 +0000 Subject: [PATCH 17/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 61 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/composer.lock b/composer.lock index 65716638..2cbec55b 100644 --- a/composer.lock +++ b/composer.lock @@ -781,29 +781,27 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", + "doctrine/coding-standard": "^9 || ^12", + "phpstan/phpstan": "1.4.10 || 2.0.3", + "phpstan/phpstan-phpunit": "^1.0 || ^2", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" + "psr/log": "^1 || ^2 || ^3" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -811,7 +809,7 @@ "type": "library", "autoload": { "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -822,9 +820,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + "source": "https://github.com/doctrine/deprecations/tree/1.1.4" }, - "time": "2024-01-30T19:34:25+00:00" + "time": "2024-12-07T21:18:45+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -1255,21 +1253,21 @@ }, { "name": "laminas/laminas-math", - "version": "3.7.0", + "version": "3.8.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-math.git", - "reference": "3e90445828fd64308de2a600b48c3df051b3b17a" + "reference": "a9e54f68accf5f8a3e66dd01fc6b32180e520018" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-math/zipball/3e90445828fd64308de2a600b48c3df051b3b17a", - "reference": "3e90445828fd64308de2a600b48c3df051b3b17a", + "url": "https://api.github.com/repos/laminas/laminas-math/zipball/a9e54f68accf5f8a3e66dd01fc6b32180e520018", + "reference": "a9e54f68accf5f8a3e66dd01fc6b32180e520018", "shasum": "" }, "require": { "ext-mbstring": "*", - "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0" + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "conflict": { "zendframework/zend-math": "*" @@ -1318,7 +1316,8 @@ "type": "community_bridge" } ], - "time": "2023-10-18T09:53:37+00:00" + "abandoned": true, + "time": "2024-12-05T13:49:56+00:00" }, { "name": "laminas/laminas-translator", @@ -1375,21 +1374,21 @@ }, { "name": "laminas/laminas-uri", - "version": "2.12.0", + "version": "2.13.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-uri.git", - "reference": "95a41a7592bacf4c648648a88b7c94b0c5c22b9e" + "reference": "de53600ae8153b3605bb6edce8aeeef524eaafba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/95a41a7592bacf4c648648a88b7c94b0c5c22b9e", - "reference": "95a41a7592bacf4c648648a88b7c94b0c5c22b9e", + "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/de53600ae8153b3605bb6edce8aeeef524eaafba", + "reference": "de53600ae8153b3605bb6edce8aeeef524eaafba", "shasum": "" }, "require": { "laminas/laminas-escaper": "^2.9", - "laminas/laminas-validator": "^2.39", + "laminas/laminas-validator": "^2.39 || ^3.0", "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" }, "conflict": { @@ -1429,7 +1428,7 @@ "type": "community_bridge" } ], - "time": "2024-08-03T21:22:51+00:00" + "time": "2024-12-03T12:27:51+00:00" }, { "name": "laminas/laminas-validator", @@ -2084,16 +2083,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.6.0", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f3558a4c23426d12bffeaab463f8a8d8b681193c", - "reference": "f3558a4c23426d12bffeaab463f8a8d8b681193c", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { @@ -2142,9 +2141,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2024-11-12T11:25:25+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", From 51e83cef57fe11faf4cfa333530ebc1d8c5ee20b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Dec 2024 00:45:37 +0000 Subject: [PATCH 18/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/composer.lock b/composer.lock index 2cbec55b..d1479b1c 100644 --- a/composer.lock +++ b/composer.lock @@ -2573,16 +2573,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.38", + "version": "10.5.39", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132" + "reference": "4e89eff200b801db58f3d580ad7426431949eaa9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a86773b9e887a67bc53efa9da9ad6e3f2498c132", - "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4e89eff200b801db58f3d580ad7426431949eaa9", + "reference": "4e89eff200b801db58f3d580ad7426431949eaa9", "shasum": "" }, "require": { @@ -2592,7 +2592,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.0", + "myclabs/deep-copy": "^1.12.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.1", @@ -2654,7 +2654,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.38" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.39" }, "funding": [ { @@ -2670,7 +2670,7 @@ "type": "tidelift" } ], - "time": "2024-10-28T13:06:21+00:00" + "time": "2024-12-11T10:51:07+00:00" }, { "name": "psalm/plugin-phpunit", @@ -3941,16 +3941,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.1", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87" + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", - "reference": "19473c30efe4f7b3cd42522d0b2e6e7f243c6f87", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", "shasum": "" }, "require": { @@ -4017,7 +4017,7 @@ "type": "open_collective" } ], - "time": "2024-11-16T12:02:36+00:00" + "time": "2024-12-11T16:04:26+00:00" }, { "name": "symfony/console", @@ -4272,8 +4272,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4348,8 +4348,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4426,8 +4426,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4510,8 +4510,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { From 116f9f5a582f8f162bfc820fe4d2371c57501390 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 17 Dec 2024 23:43:57 +0000 Subject: [PATCH 19/27] Filter Chain Deprecations See #208 Signed-off-by: George Steel --- psalm-baseline.xml | 17 +++++++++++++++++ src/FilterChain.php | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1677e983..bc5e8945 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1124,6 +1124,18 @@ + + + + + + + + + + + + @@ -2067,6 +2079,11 @@ + + + + + diff --git a/src/FilterChain.php b/src/FilterChain.php index c1355e3a..41178f3f 100644 --- a/src/FilterChain.php +++ b/src/FilterChain.php @@ -40,6 +40,8 @@ class FilterChain extends AbstractFilter implements Countable, IteratorAggregate { /** * Default priority at which filters are added + * + * @deprecated This constant will be moved to `FilterChainInterface` in version 3.0 */ public const DEFAULT_PRIORITY = 1000; @@ -68,6 +70,8 @@ public function __construct($options = null) } /** + * @deprecated This method will be removed in 3.0.0 without replacement + * * @param FilterChainConfiguration|Traversable $options * @return $this * @throws Exception\InvalidArgumentException @@ -125,6 +129,8 @@ public function count() /** * Get plugin manager instance * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @return FilterPluginManager */ public function getPluginManager() @@ -141,6 +147,8 @@ public function getPluginManager() /** * Set plugin manager instance * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @return self */ public function setPluginManager(FilterPluginManager $plugins) @@ -152,6 +160,8 @@ public function setPluginManager(FilterPluginManager $plugins) /** * Retrieve a filter plugin by name * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @param string $name * @return FilterInterface|callable(mixed): mixed */ @@ -222,6 +232,8 @@ public function merge(FilterChain $filterChain) /** * Get all the filters * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @return PriorityQueue */ public function getFilters() @@ -265,6 +277,8 @@ public function __clone() /** * Prepare filter chain for serialization * + * @deprecated This method will be removed in 3.0.0 without replacement + * * Plugin manager (property 'plugins') cannot * be serialized. On wakeup the property remains unset * and next invocation to getPluginManager() sets From 79c4e9a2936438450b0a0f04dbb016c7b2a88fd4 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 17 Dec 2024 23:51:39 +0000 Subject: [PATCH 20/27] `SeparatorToSeparator` Deprecations See #193 Closes #197 Signed-off-by: George Steel --- psalm-baseline.xml | 12 ++++++++++++ src/Word/SeparatorToSeparator.php | 12 ++++++++++-- src/Word/Service/SeparatorToSeparatorFactory.php | 6 +++++- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 1677e983..d1318643 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1179,6 +1179,8 @@ + + InvokableFactory::class]]> @@ -1614,6 +1616,10 @@ + + + + searchSeparator === null]]> @@ -2091,6 +2097,12 @@ + + + + + + diff --git a/src/Word/SeparatorToSeparator.php b/src/Word/SeparatorToSeparator.php index 83fbfcf3..08809d91 100644 --- a/src/Word/SeparatorToSeparator.php +++ b/src/Word/SeparatorToSeparator.php @@ -40,7 +40,9 @@ public function __construct($searchSeparator = ' ', $replacementSeparator = '-') /** * Sets a new separator to search for * - * @param string $separator Separator to search for + * @deprecated This method will be removed in 3.0.0 without replacement + * + * @param string $separator Separator to search for * @return self */ public function setSearchSeparator($separator) @@ -52,6 +54,8 @@ public function setSearchSeparator($separator) /** * Returns the actual set separator to search for * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @return string */ public function getSearchSeparator() @@ -62,7 +66,9 @@ public function getSearchSeparator() /** * Sets a new separator which replaces the searched one * - * @param string $separator Separator which replaces the searched one + * @deprecated This method will be removed in 3.0.0 without replacement + * + * @param string $separator Separator which replaces the searched one * @return self */ public function setReplacementSeparator($separator) @@ -74,6 +80,8 @@ public function setReplacementSeparator($separator) /** * Returns the actual set separator which replaces the searched one * + * @deprecated This method will be removed in 3.0.0 without replacement + * * @return string */ public function getReplacementSeparator() diff --git a/src/Word/Service/SeparatorToSeparatorFactory.php b/src/Word/Service/SeparatorToSeparatorFactory.php index 416701c5..0020963f 100644 --- a/src/Word/Service/SeparatorToSeparatorFactory.php +++ b/src/Word/Service/SeparatorToSeparatorFactory.php @@ -16,7 +16,11 @@ use function iterator_to_array; use function sprintf; -/** @final */ +/** + * @deprecated This factory will be removed in 3.0.0 without replacement + * + * @final + */ class SeparatorToSeparatorFactory implements FactoryInterface { /** From bc22c88a4f4e06e5f4b9dd631c66ae5f595da83e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 02:30:30 +0000 Subject: [PATCH 21/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/composer.lock b/composer.lock index d1479b1c..631ba169 100644 --- a/composer.lock +++ b/composer.lock @@ -465,13 +465,13 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "3.x-dev" } }, "autoload": { @@ -1105,16 +1105,16 @@ }, { "name": "laminas/laminas-escaper", - "version": "2.14.0", + "version": "2.15.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-escaper.git", - "reference": "0f7cb975f4443cf22f33408925c231225cfba8cb" + "reference": "c612b0488ae486284c39885efca494c180f16351" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/0f7cb975f4443cf22f33408925c231225cfba8cb", - "reference": "0f7cb975f4443cf22f33408925c231225cfba8cb", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/c612b0488ae486284c39885efca494c180f16351", + "reference": "c612b0488ae486284c39885efca494c180f16351", "shasum": "" }, "require": { @@ -1126,12 +1126,12 @@ "zendframework/zend-escaper": "*" }, "require-dev": { - "infection/infection": "^0.27.9", - "laminas/laminas-coding-standard": "~3.0.0", + "infection/infection": "^0.27.11", + "laminas/laminas-coding-standard": "~3.0.1", "maglnet/composer-require-checker": "^3.8.0", - "phpunit/phpunit": "^9.6.16", + "phpunit/phpunit": "^9.6.22", "psalm/plugin-phpunit": "^0.19.0", - "vimeo/psalm": "^5.21.1" + "vimeo/psalm": "^5.26.1" }, "type": "library", "autoload": { @@ -1163,7 +1163,7 @@ "type": "community_bridge" } ], - "time": "2024-10-24T10:12:53+00:00" + "time": "2024-12-17T19:39:54+00:00" }, { "name": "laminas/laminas-i18n", @@ -2573,16 +2573,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.39", + "version": "10.5.40", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4e89eff200b801db58f3d580ad7426431949eaa9" + "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4e89eff200b801db58f3d580ad7426431949eaa9", - "reference": "4e89eff200b801db58f3d580ad7426431949eaa9", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6ddda95af52f69c1e0c7b4f977cccb58048798c", + "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c", "shasum": "" }, "require": { @@ -2654,7 +2654,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.39" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.40" }, "funding": [ { @@ -2670,7 +2670,7 @@ "type": "tidelift" } ], - "time": "2024-12-11T10:51:07+00:00" + "time": "2024-12-21T05:49:06+00:00" }, { "name": "psalm/plugin-phpunit", @@ -3873,16 +3873,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.3.0", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" + "reference": "7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", - "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67", + "reference": "7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67", "shasum": "" }, "require": { @@ -3925,7 +3925,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" + "source": "https://github.com/spatie/array-to-xml/tree/3.4.0" }, "funding": [ { @@ -3937,7 +3937,7 @@ "type": "github" } ], - "time": "2024-05-01T10:20:27+00:00" + "time": "2024-12-16T12:45:15+00:00" }, { "name": "squizlabs/php_codesniffer", From e25964956d36df1d26e8e37cac856607e88f082e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 02:14:39 +0000 Subject: [PATCH 22/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.lock b/composer.lock index 631ba169..a4b663c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4132,12 +4132,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4588,12 +4588,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { From cd015e4bc42f5aa9e2a16fd315ba6e009e5f896c Mon Sep 17 00:00:00 2001 From: George Steel Date: Sat, 4 Jan 2025 00:30:16 +0000 Subject: [PATCH 23/27] StripTags filter deprecations Signed-off-by: George Steel --- psalm-baseline.xml | 32 ++++++++++++++++++++++++++++++++ src/StripTags.php | 16 ++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9b99b517..2bd6f5b3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1485,6 +1485,11 @@ + + + + + @@ -2293,6 +2298,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/StripTags.php b/src/StripTags.php index 6acde4a8..d861eeb0 100644 --- a/src/StripTags.php +++ b/src/StripTags.php @@ -37,6 +37,8 @@ class StripTags extends AbstractFilter { /** * Unique ID prefix used for allowing comments + * + * @deprecated This unused constant will be removed in 3.0 */ public const UNIQUE_ID_PREFIX = '__Laminas_Filter_StripTags__'; @@ -102,6 +104,8 @@ public function __construct($options = null) /** * Returns the tagsAllowed option * + * @deprecated This method will be removed in 3.0 + * * @return array> */ public function getTagsAllowed() @@ -112,7 +116,9 @@ public function getTagsAllowed() /** * Sets the tagsAllowed option * - * @param array|string $tagsAllowed + * @deprecated This method will be removed in 3.0. Only the constructor can be used to set options. + * + * @param array|string $tagsAllowed * @return self Provides a fluent interface */ public function setTagsAllowed($tagsAllowed) @@ -154,6 +160,8 @@ public function setTagsAllowed($tagsAllowed) /** * Returns the attributesAllowed option * + * @deprecated This method will be removed in 3.0 + * * @return array */ public function getAttributesAllowed() @@ -164,6 +172,8 @@ public function getAttributesAllowed() /** * Sets the attributesAllowed option * + * @deprecated This method will be removed in 3.0. Only the constructor can be used to set options. + * * @param list|string $attributesAllowed * @return self Provides a fluent interface */ @@ -245,7 +255,9 @@ public function filter($value) /** * Filters a single tag against the current option settings * - * @param string $tag + * @deprecated This method will be inaccessible in 3.0 once this class is marked final + * + * @param string $tag * @return string */ protected function _filterTag($tag) // phpcs:ignore From bdf5d8ae483cbe5cbb0989384db743898ed47ef3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 01:28:18 +0000 Subject: [PATCH 24/27] Lock file maintenance Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index a4b663c9..a4563464 100644 --- a/composer.lock +++ b/composer.lock @@ -4021,16 +4021,16 @@ }, { "name": "symfony/console", - "version": "v6.4.15", + "version": "v6.4.17", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd" + "reference": "799445db3f15768ecc382ac5699e6da0520a0a04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", - "reference": "f1fc6f47283e27336e7cebb9e8946c8de7bff9bd", + "url": "https://api.github.com/repos/symfony/console/zipball/799445db3f15768ecc382ac5699e6da0520a0a04", + "reference": "799445db3f15768ecc382ac5699e6da0520a0a04", "shasum": "" }, "require": { @@ -4095,7 +4095,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.15" + "source": "https://github.com/symfony/console/tree/v6.4.17" }, "funding": [ { @@ -4111,7 +4111,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T14:19:14+00:00" + "time": "2024-12-07T12:07:30+00:00" }, { "name": "symfony/deprecation-contracts", From 08b672131155037fc33f04f0a96ccd6384f46607 Mon Sep 17 00:00:00 2001 From: ramchale Date: Sat, 21 Dec 2024 13:15:50 +0000 Subject: [PATCH 25/27] Refactor RenameTest - Only remove temp directory after all tests have run - Use DataProvider for filter config and input variations Signed-off-by: ramchale --- psalm-baseline.xml | 2 + test/File/RenameTest.php | 582 ++++++++++++++++++--------------------- 2 files changed, 273 insertions(+), 311 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 9b99b517..e39cc51b 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -2055,6 +2055,8 @@ + + diff --git a/test/File/RenameTest.php b/test/File/RenameTest.php index a6bded2b..1df0c796 100644 --- a/test/File/RenameTest.php +++ b/test/File/RenameTest.php @@ -11,9 +11,8 @@ use stdClass; use function copy; -use function dirname; use function file_exists; -use function is_dir; +use function is_array; use function mkdir; use function preg_quote; use function rmdir; @@ -26,393 +25,327 @@ class RenameTest extends TestCase { - private string $tmpPath; - private string $origFile; - private string $oldFile; - private string $newFile; - private string $newDir; - private string $newDirFile; - - /** - * Sets the path to test files - */ - public function setUp(): void + private const TEST_FILE_NAME = 'test_file.txt'; + + private static ?string $tmpPath = null; + private static ?string $tmpSubDirectoryPath = null; + + private static function getTempPath(): string { - $control = sprintf('%s/_files/testfile.txt', dirname(__DIR__)); - $this->tmpPath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid('laminasilter')); - mkdir($this->tmpPath, 0775, true); - - $this->oldFile = sprintf('%s%stestfile.txt', $this->tmpPath, DIRECTORY_SEPARATOR); - $this->origFile = sprintf('%s%soriginal.file', $this->tmpPath, DIRECTORY_SEPARATOR); - $this->newFile = sprintf('%s%snewfile.xml', $this->tmpPath, DIRECTORY_SEPARATOR); - $this->newDir = sprintf('%s%stestdir', $this->tmpPath, DIRECTORY_SEPARATOR); - $this->newDirFile = sprintf('%s%stestfile.txt', $this->newDir, DIRECTORY_SEPARATOR); - - copy($control, $this->oldFile); - copy($control, $this->origFile); - mkdir($this->newDir, 0775, true); + if (self::$tmpPath === null) { + self::$tmpPath = sys_get_temp_dir() . '/' . uniqid('laminasfilter'); + mkdir(self::$tmpPath, 0775, true); + } + + return self::$tmpPath; } - /** - * Sets the path to test files - */ - public function tearDown(): void + private static function getTempSubDirectory(): string { - if (is_dir($this->tmpPath)) { - if (file_exists($this->oldFile)) { - unlink($this->oldFile); - } - if (file_exists($this->origFile)) { - unlink($this->origFile); - } - if (file_exists($this->newFile)) { - unlink($this->newFile); - } - if (is_dir($this->newDir)) { - if (file_exists($this->newDirFile)) { - unlink($this->newDirFile); - } - rmdir($this->newDir); - } - rmdir($this->tmpPath); + if (self::$tmpSubDirectoryPath === null) { + self::$tmpSubDirectoryPath = self::getTempPath() . '/test_dir'; + mkdir(self::$tmpSubDirectoryPath, 0775, true); } + + return self::$tmpSubDirectoryPath; } - /** - * Test single parameter filter - */ - public function testConstructSingleValue(): void + public static function tearDownAfterClass(): void { - $filter = new FileRename($this->newFile); + if (self::$tmpSubDirectoryPath !== null) { + rmdir(self::$tmpSubDirectoryPath); + } - self::assertSame( - [ - 0 => [ - 'target' => $this->newFile, + if (self::$tmpPath !== null) { + rmdir(self::$tmpPath); + } + } + + private static function createSourceFile(): void + { + copy(__DIR__ . '/../_files/testfile.txt', self::getTempPath() . '/' . self::TEST_FILE_NAME); + } + + private static function cleanupSourceFile(): void + { + $fileToRemove = self::getTempPath() . '/' . self::TEST_FILE_NAME; + if (file_exists($fileToRemove)) { + unlink($fileToRemove); + } + } + + public function tearDown(): void + { + self::cleanupSourceFile(); + } + + public static function returnValidFilterInputProvider(): array + { + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + $newDir = self::getTempSubDirectory(); + $newDirFile = self::getTempSubDirectory() . '/test_file.txt'; + + return [ + 'Configured with target file path and filtering file path' => [ + 'options' => $newFile, + 'input' => $oldFile, + 'expectedGetFileResult' => [ 'source' => '*', + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newFile, ], - $filter->getFile() - ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single parameter filter - */ - public function testConstructSingleValueWithFilesArray(): void - { - $filter = new FileRename($this->newFile); - - self::assertSame( - [ - 0 => [ - 'target' => $this->newFile, + 'Configured with target file path and filtering file path array' => [ + 'options' => $newFile, + 'input' => ['tmp_name' => $oldFile], + 'expectedGetFileResult' => [ 'source' => '*', + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => ['tmp_name' => $newFile], ], - $filter->getFile() - ); - self::assertSame( - ['tmp_name' => $this->newFile], - $filter(['tmp_name' => $this->oldFile]) - ); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter - */ - public function testConstructSingleArray(): void - { - $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newFile, - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'Configured with array' => [ + 'options' => ['source' => $oldFile, 'target' => $newFile], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newFile, ], - $filter->getFile() - ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test full array parameter filter - */ - public function testConstructFullOptionsArray(): void - { - $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newFile, - 'overwrite' => true, - 'randomize' => false, - 'unknown' => false, - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'Configured with all options set' => [ + 'options' => [ + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => true, 'randomize' => false, + 'unknown' => false, ], - ], - $filter->getFile() - ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter - */ - public function testConstructDoubleArray(): void - { - $filter = new FileRename([ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, - ], - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, - 'overwrite' => false, + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => $newFile, + 'overwrite' => true, 'randomize' => false, ], + 'expectedFilterResult' => $newFile, ], - $filter->getFile() - ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter - */ - public function testConstructTruncatedTarget(): void - { - $filter = new FileRename([ - 'source' => $this->oldFile, - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => '*', + 'Configured with array wrapped in array' => [ + 'options' => [0 => ['source' => $oldFile, 'target' => $newFile]], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newFile, ], - $filter->getFile() - ); - self::assertSame($this->oldFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter - */ - public function testConstructTruncatedSource(): void - { - $filter = new FileRename([ - 'target' => $this->newFile, - ]); - - self::assertSame( - [ - 0 => [ - 'target' => $this->newFile, + 'Only target configured' => [ + 'options' => ['target' => $newFile], + 'input' => $oldFile, + 'expectedGetFileResult' => [ 'source' => '*', + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newFile, ], - $filter->getFile() - ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single parameter filter by using directory only - */ - public function testConstructSingleDirectory(): void - { - $filter = new FileRename($this->newDir); - - self::assertSame( - [ - 0 => [ - 'target' => $this->newDir, + 'Configured with target directory and filtering file path' => [ + 'options' => $newDir, + 'input' => $oldFile, + 'expectedGetFileResult' => [ 'source' => '*', + 'target' => $newDir, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newDirFile, ], - $filter->getFile() - ); - self::assertSame($this->newDirFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter by using directory only - */ - public function testConstructSingleArrayDirectory(): void - { - $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newDir, - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'Configured with array and filtering file path' => [ + 'options' => ['source' => $oldFile, 'target' => $newDir], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => $newDir, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newDirFile, ], - $filter->getFile() - ); - self::assertSame($this->newDirFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); - } - - /** - * Test single array parameter filter by using directory only - */ - public function testConstructDoubleArrayDirectory(): void - { - $filter = new FileRename([ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'Configured with array wrapped in array and filtering file path' => [ + 'options' => [0 => ['source' => $oldFile, 'target' => $newDir]], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => $newDir, + 'overwrite' => false, + 'randomize' => false, + ], + 'expectedFilterResult' => $newDirFile, ], - ]); - - self::assertSame( - [ - 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'Configured with only target and filtering file path' => [ + 'options' => ['target' => $newDir], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => '*', + 'target' => $newDir, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => $newDirFile, ], - $filter->getFile() - ); - self::assertSame($this->newDirFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); + ]; } - /** - * Test single array parameter filter by using directory only - */ - public function testConstructTruncatedSourceDirectory(): void + public static function returnInvalidFilterInputProvider(): array { - $filter = new FileRename([ - 'target' => $this->newDir, - ]); + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; - self::assertSame( - [ - 0 => [ - 'target' => $this->newDir, + return [ + 'Source file non-existent' => [ + 'options' => $newFile, + 'input' => 'non-existent-file.txt', + 'expectedGetFileResult' => [ 'source' => '*', + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], + 'expectedFilterResult' => 'non-existent-file.txt', ], - $filter->getFile() - ); - self::assertSame($this->newDirFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); + 'Only source configured' => [ + 'options' => ['source' => $oldFile], + 'input' => $oldFile, + 'expectedGetFileResult' => [ + 'source' => $oldFile, + 'target' => '*', + 'overwrite' => false, + 'randomize' => false, + ], + 'expectedFilterResult' => $oldFile, + ], + ]; + } + + #[DataProvider('returnValidFilterInputProvider')] + #[DataProvider('returnInvalidFilterInputProvider')] + public function testFilterValidPaths( + string|array $options, + string|array $input, + array $expectedGetFileResult, + string|array $expectedFilterResult + ): void { + self::createSourceFile(); + + $filter = new FileRename($options); + + self::assertEquals([$expectedGetFileResult], $filter->getFile()); + + try { + self::assertSame($expectedFilterResult, $filter->filter($input)); + } finally { + /** @var string $fileToRemove */ + $fileToRemove = is_array($expectedFilterResult) ? $expectedFilterResult['tmp_name'] : $expectedFilterResult; + + if (file_exists($fileToRemove)) { + unlink($fileToRemove); + } + } } public function testAddSameFileAgainAndOverwriteExistingTarget(): void { + self::createSourceFile(); + + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'source' => $oldFile, + 'target' => '/to-be-overwritten.xml', ]); $filter->addFile([ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, ]); self::assertSame( [ 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], ], $filter->getFile() ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); + + try { + self::assertSame($newFile, $filter($oldFile)); + } finally { + if (file_exists($newFile)) { + unlink($newFile); + } + } } public function testGetNewName(): void { + self::createSourceFile(); + + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newDir = self::getTempSubDirectory(); + $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'source' => $oldFile, + 'target' => $newDir, ]); self::assertSame( [ 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newDir, + 'source' => $oldFile, + 'target' => $newDir, 'overwrite' => false, 'randomize' => false, ], ], $filter->getFile() ); - self::assertSame($this->newDirFile, $filter->getNewName($this->oldFile)); + + self::assertSame($newDir . '/' . self::TEST_FILE_NAME, $filter->getNewName($oldFile)); } public function testGetNewNameExceptionWithExistingFile(): void { + self::createSourceFile(); + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, ]); - copy($this->oldFile, $this->newFile); + copy($oldFile, $newFile); self::assertSame( [ 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => false, 'randomize' => false, ], @@ -421,64 +354,82 @@ public function testGetNewNameExceptionWithExistingFile(): void ); $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage('could not be renamed'); - self::assertSame($this->newFile, $filter->getNewName($this->oldFile)); + + try { + self::assertSame($newFile, $filter->getNewName($oldFile)); + } finally { + if (file_exists($newFile)) { + unlink($newFile); + } + } } public function testGetNewNameOverwriteWithExistingFile(): void { + self::createSourceFile(); + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => true, ]); - copy($this->oldFile, $this->newFile); + copy($oldFile, $newFile); self::assertSame( [ 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'overwrite' => true, 'randomize' => false, ], ], $filter->getFile() ); - self::assertSame($this->newFile, $filter->getNewName($this->oldFile)); + self::assertSame($newFile, $filter->getNewName($oldFile)); } public function testGetRandomizedFile(): void { + self::createSourceFile(); + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + $filter = new FileRename([ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'randomize' => true, ]); self::assertSame( [ 0 => [ - 'source' => $this->oldFile, - 'target' => $this->newFile, + 'source' => $oldFile, + 'target' => $newFile, 'randomize' => true, 'overwrite' => false, ], ], $filter->getFile() ); - $fileNoExt = $this->tmpPath . DIRECTORY_SEPARATOR . 'newfile'; + $fileNoExt = self::getTempPath() . '/new_file'; self::assertMatchesRegularExpression( '#' . preg_quote($fileNoExt) . '_.{13}\.xml#', - $filter->getNewName($this->oldFile) + $filter->getNewName($oldFile) ); } public function testGetRandomizedFileWithoutExtension(): void { - $fileNoExt = $this->tmpPath . DIRECTORY_SEPARATOR . 'newfile'; + self::createSourceFile(); + + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $fileNoExt = self::getTempPath() . '/new_file'; $filter = new FileRename([ - 'source' => $this->oldFile, + 'source' => $oldFile, 'target' => $fileNoExt, 'randomize' => true, ]); @@ -486,7 +437,7 @@ public function testGetRandomizedFileWithoutExtension(): void self::assertSame( [ 0 => [ - 'source' => $this->oldFile, + 'source' => $oldFile, 'target' => $fileNoExt, 'randomize' => true, 'overwrite' => false, @@ -496,19 +447,24 @@ public function testGetRandomizedFileWithoutExtension(): void ); self::assertMatchesRegularExpression( '#' . preg_quote($fileNoExt) . '_.{13}#', - $filter->getNewName($this->oldFile) + $filter->getNewName($oldFile) ); } public function testAddFileWithString(): void { - $filter = new FileRename($this->oldFile); - $filter->addFile($this->newFile); + self::createSourceFile(); + + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $newFile = self::getTempPath() . '/new_file.xml'; + + $filter = new FileRename($oldFile); + $filter->addFile($newFile); self::assertSame( [ 0 => [ - 'target' => $this->newFile, + 'target' => $newFile, 'source' => '*', 'overwrite' => false, 'randomize' => false, @@ -516,13 +472,18 @@ public function testAddFileWithString(): void ], $filter->getFile() ); - self::assertSame($this->newFile, $filter($this->oldFile)); - self::assertSame('falsefile', $filter('falsefile')); + try { + self::assertSame($newFile, $filter($oldFile)); + } finally { + if (file_exists($newFile)) { + unlink($newFile); + } + } } public function testAddFileWithInvalidOption(): void { - $filter = new FileRename($this->oldFile); + $filter = new FileRename('invalid'); $this->expectException(Exception\InvalidArgumentException::class); $this->expectExceptionMessage('Invalid options'); $filter->addFile(1234); @@ -538,11 +499,8 @@ public function testInvalidConstruction(): void /** @return list */ public static function returnUnfilteredDataProvider(): array { - $tmpPath = sprintf('%s%s%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, uniqid('returnUnfilteredDataProvider')); - mkdir($tmpPath, 0775, true); - - $oldFile = sprintf('%s%stestfile.txt', $tmpPath, DIRECTORY_SEPARATOR); - $origFile = sprintf('%s%soriginal.file', $tmpPath, DIRECTORY_SEPARATOR); + $oldFile = self::getTempPath() . '/' . self::TEST_FILE_NAME; + $origFile = sprintf('%s%soriginal.file', self::getTempPath(), DIRECTORY_SEPARATOR); return [ [null], @@ -559,7 +517,9 @@ public static function returnUnfilteredDataProvider(): array #[DataProvider('returnUnfilteredDataProvider')] public function testReturnUnfiltered(mixed $input): void { - $filter = new FileRename($this->newFile); + self::createSourceFile(); + + $filter = new FileRename(self::getTempPath() . '/new_file.xml'); self::assertSame($input, $filter($input)); } From 08aad80b84826fab4fbd154f568a6e092aa19949 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 6 Jan 2025 21:26:38 +0000 Subject: [PATCH 26/27] Deprecate getters and setters in the `HtmlEntities` filter Signed-off-by: George Steel --- psalm-baseline.xml | 35 ++++++++++++++++++++++++++++++++++- src/HtmlEntities.php | 24 ++++++++++++++++++++---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 561dd054..c0261ab3 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1249,6 +1249,20 @@ + + + + + + + + + + + + + + @@ -2061,8 +2075,8 @@ - + @@ -2134,6 +2148,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/HtmlEntities.php b/src/HtmlEntities.php index 8a2584d0..c3836e10 100644 --- a/src/HtmlEntities.php +++ b/src/HtmlEntities.php @@ -94,6 +94,8 @@ public function __construct($options = []) /** * Returns the quoteStyle option * + * @deprecated Since 2.40.0. This method will be removed in 3.0 without replacement + * * @return int */ public function getQuoteStyle() @@ -104,7 +106,9 @@ public function getQuoteStyle() /** * Sets the quoteStyle option * - * @param int $quoteStyle + * @deprecated Since 2.40.0. This method will be removed in 3.0. Set options during construction instead + * + * @param int $quoteStyle * @return self Provides a fluent interface */ public function setQuoteStyle($quoteStyle) @@ -116,6 +120,8 @@ public function setQuoteStyle($quoteStyle) /** * Get encoding * + * @deprecated Since 2.40.0. This method will be removed in 3.0 without replacement + * * @return string */ public function getEncoding() @@ -126,7 +132,9 @@ public function getEncoding() /** * Set encoding * - * @param string $value + * @deprecated Since 2.40.0. This method will be removed in 3.0. Set options during construction instead + * + * @param string $value * @return self */ public function setEncoding($value) @@ -138,6 +146,8 @@ public function setEncoding($value) /** * Returns the charSet option * + * @deprecated Since 2.40.0. This method will be removed in 3.0 without replacement + * * Proxies to {@link getEncoding()} * * @return string @@ -150,9 +160,11 @@ public function getCharSet() /** * Sets the charSet option * + * @deprecated Since 2.40.0. This method will be removed in 3.0. Set options during construction instead + * * Proxies to {@link setEncoding()} * - * @param string $charSet + * @param string $charSet * @return self Provides a fluent interface */ public function setCharSet($charSet) @@ -163,6 +175,8 @@ public function setCharSet($charSet) /** * Returns the doubleQuote option * + * @deprecated Since 2.40.0. This method will be removed in 3.0 without replacement + * * @return bool */ public function getDoubleQuote() @@ -173,7 +187,9 @@ public function getDoubleQuote() /** * Sets the doubleQuote option * - * @param bool $doubleQuote + * @deprecated Since 2.40.0. This method will be removed in 3.0. Set options during construction instead + * + * @param bool $doubleQuote * @return self Provides a fluent interface */ public function setDoubleQuote($doubleQuote) From 84cb2a88095c69eaa790fe41c03f6ecfe4c68711 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 6 Jan 2025 21:55:00 +0000 Subject: [PATCH 27/27] Refresh baseline and php deps post merge-up Signed-off-by: George Steel --- composer.json | 4 +- composer.lock | 237 ++++++++++++++++++++++----------------------- psalm-baseline.xml | 41 ++++++-- 3 files changed, 155 insertions(+), 127 deletions(-) diff --git a/composer.json b/composer.json index 84ad697a..66203e10 100644 --- a/composer.json +++ b/composer.json @@ -42,8 +42,8 @@ "laminas/laminas-coding-standard": "^3.0.1", "laminas/laminas-diactoros": "^3.5", "pear/archive_tar": "^1.5.0", - "pear/pear": "^1.10.15", - "phpunit/phpunit": "^10.5.38", + "pear/pear": "^1.10.16", + "phpunit/phpunit": "^10.5.40", "psalm/plugin-phpunit": "^0.19.0", "psr/http-factory": "^1.1.0", "vimeo/psalm": "^5.26.1" diff --git a/composer.lock b/composer.lock index b39c3315..ae912c29 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "51c0827fc3afb5acaabb68dfe2509036", + "content-hash": "f84772d7b2906b1ef52d7cc40e87eb06", "packages": [ { "name": "brick/varexporter", @@ -104,8 +104,8 @@ "type": "library", "extra": { "laminas": { - "config-provider": "Laminas\\ServiceManager\\ConfigProvider", - "module": "Laminas\\ServiceManager" + "module": "Laminas\\ServiceManager", + "config-provider": "Laminas\\ServiceManager\\ConfigProvider" } }, "autoload": { @@ -600,16 +600,16 @@ }, { "name": "composer/pcre", - "version": "3.3.1", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4" + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/63aaeac21d7e775ff9bc9d45021e1745c97521c4", - "reference": "63aaeac21d7e775ff9bc9d45021e1745c97521c4", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", "shasum": "" }, "require": { @@ -619,19 +619,19 @@ "phpstan/phpstan": "<1.11.10" }, "require-dev": { - "phpstan/phpstan": "^1.11.10", - "phpstan/phpstan-strict-rules": "^1.1", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", "phpunit/phpunit": "^8 || ^9" }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - }, "phpstan": { "includes": [ "extension.neon" ] + }, + "branch-alias": { + "dev-main": "3.x-dev" } }, "autoload": { @@ -659,7 +659,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.3.1" + "source": "https://github.com/composer/pcre/tree/3.3.2" }, "funding": [ { @@ -675,7 +675,7 @@ "type": "tidelift" } ], - "time": "2024-08-27T18:44:43+00:00" + "time": "2024-11-12T16:29:46+00:00" }, { "name": "composer/semver", @@ -941,29 +941,27 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.3", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", - "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", + "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", "shasum": "" }, "require": { "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", + "doctrine/coding-standard": "^9 || ^12", + "phpstan/phpstan": "1.4.10 || 2.0.3", + "phpstan/phpstan-phpunit": "^1.0 || ^2", "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" + "psr/log": "^1 || ^2 || ^3" }, "suggest": { "psr/log": "Allows logging deprecations via PSR-3 logger implementation" @@ -971,7 +969,7 @@ "type": "library", "autoload": { "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" + "Doctrine\\Deprecations\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -982,9 +980,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.3" + "source": "https://github.com/doctrine/deprecations/tree/1.1.4" }, - "time": "2024-01-30T19:34:25+00:00" + "time": "2024-12-07T21:18:45+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -1242,8 +1240,8 @@ "type": "library", "extra": { "laminas": { - "config-provider": "Laminas\\Diactoros\\ConfigProvider", - "module": "Laminas\\Diactoros" + "module": "Laminas\\Diactoros", + "config-provider": "Laminas\\Diactoros\\ConfigProvider" } }, "autoload": { @@ -1291,16 +1289,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.0", + "version": "1.12.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", - "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", + "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", "shasum": "" }, "require": { @@ -1339,7 +1337,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" }, "funding": [ { @@ -1347,7 +1345,7 @@ "type": "tidelift" } ], - "time": "2024-06-12T14:39:25+00:00" + "time": "2024-11-08T17:47:46+00:00" }, { "name": "netresearch/jsonmapper", @@ -1523,16 +1521,16 @@ }, { "name": "pear/pear", - "version": "v1.10.15", + "version": "v1.10.16", "source": { "type": "git", "url": "https://github.com/pear/pear-core.git", - "reference": "6f4c3a0b134626d238d75a44af01a2f7c4e688d9" + "reference": "9d3ac5eb137633e015d6c0d4e6deeca830f1ccc2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pear/pear-core/zipball/6f4c3a0b134626d238d75a44af01a2f7c4e688d9", - "reference": "6f4c3a0b134626d238d75a44af01a2f7c4e688d9", + "url": "https://api.github.com/repos/pear/pear-core/zipball/9d3ac5eb137633e015d6c0d4e6deeca830f1ccc2", + "reference": "9d3ac5eb137633e015d6c0d4e6deeca830f1ccc2", "shasum": "" }, "require": { @@ -1545,7 +1543,8 @@ "php": ">=5.4" }, "replace": { - "pear/pear-core-minimal": "*" + "pear/pear-core-minimal": "*", + "pear/pear-exception": "*" }, "suggest": { "pear/pear_frontend_gtk": "For GTK support", @@ -1619,7 +1618,7 @@ "issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=PEAR", "source": "https://github.com/pear/PEAR" }, - "time": "2024-03-09T19:36:44+00:00" + "time": "2024-11-24T22:10:16+00:00" }, { "name": "pear/structures_graph", @@ -1901,16 +1900,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.5.1", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/0c70d2c566e899666f367ab7b80986beb3581e6f", - "reference": "0c70d2c566e899666f367ab7b80986beb3581e6f", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { @@ -1919,7 +1918,7 @@ "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", "webmozart/assert": "^1.9.1" }, "require-dev": { @@ -1959,29 +1958,29 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.5.1" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2024-11-06T11:58:54+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.9.0", + "version": "1.10.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d" + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/1fb5ba8d045f5dd984ebded5b1cc66f29459422d", - "reference": "1fb5ba8d045f5dd984ebded5b1cc66f29459422d", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", + "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", "shasum": "" }, "require": { "doctrine/deprecations": "^1.0", "php": "^7.3 || ^8.0", "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.18" + "phpstan/phpdoc-parser": "^1.18|^2.0" }, "require-dev": { "ext-tokenizer": "*", @@ -2017,9 +2016,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.9.0" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" }, - "time": "2024-11-03T20:11:34+00:00" + "time": "2024-11-09T15:12:26+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -2391,16 +2390,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.38", + "version": "10.5.40", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132" + "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a86773b9e887a67bc53efa9da9ad6e3f2498c132", - "reference": "a86773b9e887a67bc53efa9da9ad6e3f2498c132", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6ddda95af52f69c1e0c7b4f977cccb58048798c", + "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c", "shasum": "" }, "require": { @@ -2410,7 +2409,7 @@ "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.12.0", + "myclabs/deep-copy": "^1.12.1", "phar-io/manifest": "^2.0.4", "phar-io/version": "^3.2.1", "php": ">=8.1", @@ -2472,7 +2471,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.38" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.40" }, "funding": [ { @@ -2488,7 +2487,7 @@ "type": "tidelift" } ], - "time": "2024-10-28T13:06:21+00:00" + "time": "2024-12-21T05:49:06+00:00" }, { "name": "psalm/plugin-phpunit", @@ -3638,16 +3637,16 @@ }, { "name": "spatie/array-to-xml", - "version": "3.3.0", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/spatie/array-to-xml.git", - "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876" + "reference": "7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/f56b220fe2db1ade4c88098d83413ebdfc3bf876", - "reference": "f56b220fe2db1ade4c88098d83413ebdfc3bf876", + "url": "https://api.github.com/repos/spatie/array-to-xml/zipball/7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67", + "reference": "7dcfc67d60b0272926dabad1ec01f6b8a5fb5e67", "shasum": "" }, "require": { @@ -3690,7 +3689,7 @@ "xml" ], "support": { - "source": "https://github.com/spatie/array-to-xml/tree/3.3.0" + "source": "https://github.com/spatie/array-to-xml/tree/3.4.0" }, "funding": [ { @@ -3702,20 +3701,20 @@ "type": "github" } ], - "time": "2024-05-01T10:20:27+00:00" + "time": "2024-12-16T12:45:15+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.10.3", + "version": "3.11.2", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", - "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", + "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", "shasum": "" }, "require": { @@ -3782,20 +3781,20 @@ "type": "open_collective" } ], - "time": "2024-09-18T10:38:58+00:00" + "time": "2024-12-11T16:04:26+00:00" }, { "name": "symfony/console", - "version": "v6.4.14", + "version": "v6.4.17", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b" + "reference": "799445db3f15768ecc382ac5699e6da0520a0a04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/897c2441ed4eec8a8a2c37b943427d24dba3f26b", - "reference": "897c2441ed4eec8a8a2c37b943427d24dba3f26b", + "url": "https://api.github.com/repos/symfony/console/zipball/799445db3f15768ecc382ac5699e6da0520a0a04", + "reference": "799445db3f15768ecc382ac5699e6da0520a0a04", "shasum": "" }, "require": { @@ -3860,7 +3859,7 @@ "terminal" ], "support": { - "source": "https://github.com/symfony/console/tree/v6.4.14" + "source": "https://github.com/symfony/console/tree/v6.4.17" }, "funding": [ { @@ -3876,20 +3875,20 @@ "type": "tidelift" } ], - "time": "2024-11-05T15:34:40+00:00" + "time": "2024-12-07T12:07:30+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", - "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", "shasum": "" }, "require": { @@ -3897,12 +3896,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -3927,7 +3926,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" }, "funding": [ { @@ -3943,7 +3942,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/filesystem", @@ -4037,8 +4036,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4113,8 +4112,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4191,8 +4190,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4275,8 +4274,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -4331,16 +4330,16 @@ }, { "name": "symfony/service-contracts", - "version": "v3.5.0", + "version": "v3.5.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f" + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", - "reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0", + "reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0", "shasum": "" }, "require": { @@ -4353,12 +4352,12 @@ }, "type": "library", "extra": { + "thanks": { + "url": "https://github.com/symfony/contracts", + "name": "symfony/contracts" + }, "branch-alias": { "dev-main": "3.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4394,7 +4393,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.5.0" + "source": "https://github.com/symfony/service-contracts/tree/v3.5.1" }, "funding": [ { @@ -4410,20 +4409,20 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:32:20+00:00" + "time": "2024-09-25T14:20:29+00:00" }, { "name": "symfony/string", - "version": "v6.4.13", + "version": "v6.4.15", "source": { "type": "git", "url": "https://github.com/symfony/string.git", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627" + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", - "reference": "38371c60c71c72b3d64d8d76f6b1bb81a2cc3627", + "url": "https://api.github.com/repos/symfony/string/zipball/73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", + "reference": "73a5e66ea2e1677c98d4449177c5a9cf9d8b4c6f", "shasum": "" }, "require": { @@ -4480,7 +4479,7 @@ "utf8" ], "support": { - "source": "https://github.com/symfony/string/tree/v6.4.13" + "source": "https://github.com/symfony/string/tree/v6.4.15" }, "funding": [ { @@ -4496,7 +4495,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:18:03+00:00" + "time": "2024-11-13T13:31:12+00:00" }, { "name": "theseer/tokenizer", @@ -4623,11 +4622,11 @@ "type": "project", "extra": { "branch-alias": { - "dev-master": "5.x-dev", - "dev-4.x": "4.x-dev", - "dev-3.x": "3.x-dev", + "dev-1.x": "1.x-dev", "dev-2.x": "2.x-dev", - "dev-1.x": "1.x-dev" + "dev-3.x": "3.x-dev", + "dev-4.x": "4.x-dev", + "dev-master": "5.x-dev" } }, "autoload": { @@ -4774,14 +4773,14 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "ext-mbstring": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.1.99" }, diff --git a/psalm-baseline.xml b/psalm-baseline.xml index eb3e2550..e23a8698 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,9 +1,6 @@ - - - @@ -18,9 +15,6 @@ - - - @@ -189,6 +183,20 @@ + + + + + + + + + + + + + + @@ -364,6 +372,27 @@ + + + + + + + + + + + + + + + + + + + + +