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/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..aa574392 100644
--- a/src/Compress/Zip.php
+++ b/src/Compress/Zip.php
@@ -240,84 +240,37 @@ public function decompress($content)
/**
* Returns the proper string based on the given error constant
*
- * @param string $error
+ * @param int|false $error
* @return string
*/
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/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/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)
{
}