From 2f4c4cbf7dbdccd0f6f29b9236c846a004c8a0a9 Mon Sep 17 00:00:00 2001 From: George Steel Date: Mon, 3 Feb 2025 21:31:49 +0000 Subject: [PATCH] Upgrade Psalm to v6 - Fixes a number of new Psalm issues, mainly concerned with null/false return types from built-ins Signed-off-by: George Steel --- composer.json | 6 +- composer.lock | 1247 ++++++++++++++++++++++++++--- psalm-baseline.xml | 27 +- src/Compress/Bz2Adapter.php | 4 +- src/EncodingOption.php | 2 +- src/File/FileInformation.php | 2 + src/File/RenameUpload.php | 7 +- src/HtmlEntities.php | 5 +- src/Inflector.php | 1 + src/PregReplace.php | 8 +- src/RealPath.php | 6 +- src/StringTrim.php | 7 +- src/Word/CamelCaseToSeparator.php | 39 +- src/Word/SeparatorToCamelCase.php | 10 +- src/Word/SeparatorToSeparator.php | 17 +- test/Compress/TarAdapterTest.php | 4 +- test/CompressToArchiveTest.php | 4 +- test/DecompressArchiveTest.php | 5 +- test/File/FileInformationTest.php | 4 +- test/File/LowerCaseTest.php | 20 +- test/File/RenameUploadTest.php | 4 +- test/File/UpperCaseTest.php | 20 +- test/RealPathTest.php | 13 +- test/StringTrimTest.php | 17 +- 24 files changed, 1276 insertions(+), 203 deletions(-) diff --git a/composer.json b/composer.json index 66203e10..19e4fcc6 100644 --- a/composer.json +++ b/composer.json @@ -43,10 +43,10 @@ "laminas/laminas-diactoros": "^3.5", "pear/archive_tar": "^1.5.0", "pear/pear": "^1.10.16", - "phpunit/phpunit": "^10.5.40", - "psalm/plugin-phpunit": "^0.19.0", + "phpunit/phpunit": "^10.5.44", + "psalm/plugin-phpunit": "^0.19.2", "psr/http-factory": "^1.1.0", - "vimeo/psalm": "^5.26.1" + "vimeo/psalm": "^6.2.0" }, "conflict": { "laminas/laminas-validator": "<2.10.1", diff --git a/composer.lock b/composer.lock index ae912c29..44963cba 100644 --- a/composer.lock +++ b/composer.lock @@ -4,30 +4,30 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f84772d7b2906b1ef52d7cc40e87eb06", + "content-hash": "45f104d8d8e517716b658bcd9e586442", "packages": [ { "name": "brick/varexporter", - "version": "0.4.0", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/brick/varexporter.git", - "reference": "2fd038f7c9d12d468130c6e1b3ce06e4160a7dbb" + "reference": "84b2a7a91f69aa5d079aec5a0a7256ebf2dceb6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/varexporter/zipball/2fd038f7c9d12d468130c6e1b3ce06e4160a7dbb", - "reference": "2fd038f7c9d12d468130c6e1b3ce06e4160a7dbb", + "url": "https://api.github.com/repos/brick/varexporter/zipball/84b2a7a91f69aa5d079aec5a0a7256ebf2dceb6b", + "reference": "84b2a7a91f69aa5d079aec5a0a7256ebf2dceb6b", "shasum": "" }, "require": { - "nikic/php-parser": "^4.0", + "nikic/php-parser": "^5.0", "php": "^7.4 || ^8.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^8.5 || ^9.0", - "vimeo/psalm": "5.15.0" + "phpunit/phpunit": "^9.3", + "psalm/phar": "5.21.1" }, "type": "library", "autoload": { @@ -45,7 +45,7 @@ ], "support": { "issues": "https://github.com/brick/varexporter/issues", - "source": "https://github.com/brick/varexporter/tree/0.4.0" + "source": "https://github.com/brick/varexporter/tree/0.5.0" }, "funding": [ { @@ -53,7 +53,7 @@ "type": "github" } ], - "time": "2023-09-01T21:10:07+00:00" + "time": "2024-05-10T17:15:19+00:00" }, { "name": "laminas/laminas-servicemanager", @@ -203,25 +203,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.19.4", + "version": "v5.4.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2" + "reference": "447a020a1f875a434d62f2a401f53b82a396e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/715f4d25e225bc47b293a8b997fe6ce99bf987d2", - "reference": "715f4d25e225bc47b293a8b997fe6ce99bf987d2", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/447a020a1f875a434d62f2a401f53b82a396e494", + "reference": "447a020a1f875a434d62f2a401f53b82a396e494", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.1" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^9.0" }, "bin": [ "bin/php-parse" @@ -229,7 +231,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -253,9 +255,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.19.4" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.4.0" }, - "time": "2024-09-29T15:01:53+00:00" + "time": "2024-12-30T11:07:19+00:00" }, { "name": "psr/container", @@ -367,43 +369,694 @@ "packages-dev": [ { "name": "amphp/amp", - "version": "v2.6.4", + "version": "v3.1.0", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/amp/zipball/7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", + "reference": "7cf7fef3d667bfe4b2560bc87e67d5387a7bcde9", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "5.23.1" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php", + "src/Future/functions.php", + "src/Internal/functions.php" + ], + "psr-4": { + "Amp\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + } + ], + "description": "A non-blocking concurrency framework for PHP applications.", + "homepage": "https://amphp.org/amp", + "keywords": [ + "async", + "asynchronous", + "awaitable", + "concurrency", + "event", + "event-loop", + "future", + "non-blocking", + "promise" + ], + "support": { + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/v3.1.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2025-01-26T16:07:39+00:00" + }, + { + "name": "amphp/byte-stream", + "version": "v2.1.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/byte-stream.git", + "reference": "daa00f2efdbd71565bf64ffefa89e37542addf93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/byte-stream/zipball/daa00f2efdbd71565bf64ffefa89e37542addf93", + "reference": "daa00f2efdbd71565bf64ffefa89e37542addf93", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/parser": "^1.1", + "amphp/pipeline": "^1", + "amphp/serialization": "^1", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2.3" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.22.1" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php", + "src/Internal/functions.php" + ], + "psr-4": { + "Amp\\ByteStream\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A stream abstraction to make working with non-blocking I/O simple.", + "homepage": "https://amphp.org/byte-stream", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "non-blocking", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/v2.1.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-02-17T04:49:38+00:00" + }, + { + "name": "amphp/cache", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/cache.git", + "reference": "46912e387e6aa94933b61ea1ead9cf7540b7797c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/cache/zipball/46912e387e6aa94933b61ea1ead9cf7540b7797c", + "reference": "46912e387e6aa94933b61ea1ead9cf7540b7797c", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/serialization": "^1", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\Cache\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + } + ], + "description": "A fiber-aware cache API based on Amp and Revolt.", + "homepage": "https://amphp.org/cache", + "support": { + "issues": "https://github.com/amphp/cache/issues", + "source": "https://github.com/amphp/cache/tree/v2.0.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-19T03:38:06+00:00" + }, + { + "name": "amphp/dns", + "version": "v2.4.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/dns.git", + "reference": "78eb3db5fc69bf2fc0cb503c4fcba667bc223c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/dns/zipball/78eb3db5fc69bf2fc0cb503c4fcba667bc223c71", + "reference": "78eb3db5fc69bf2fc0cb503c4fcba667bc223c71", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/cache": "^2", + "amphp/parser": "^1", + "amphp/process": "^2", + "daverandom/libdns": "^2.0.2", + "ext-filter": "*", + "ext-json": "*", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.20" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Dns\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Chris Wright", + "email": "addr@daverandom.com" + }, + { + "name": "Daniel Lowrey", + "email": "rdlowrey@php.net" + }, + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + } + ], + "description": "Async DNS resolution for Amp.", + "homepage": "https://github.com/amphp/dns", + "keywords": [ + "amp", + "amphp", + "async", + "client", + "dns", + "resolve" + ], + "support": { + "issues": "https://github.com/amphp/dns/issues", + "source": "https://github.com/amphp/dns/tree/v2.4.0" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2025-01-19T15:43:40+00:00" + }, + { + "name": "amphp/parallel", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/parallel.git", + "reference": "5113111de02796a782f5d90767455e7391cca190" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/parallel/zipball/5113111de02796a782f5d90767455e7391cca190", + "reference": "5113111de02796a782f5d90767455e7391cca190", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/cache": "^2", + "amphp/parser": "^1", + "amphp/pipeline": "^1", + "amphp/process": "^2", + "amphp/serialization": "^1", + "amphp/socket": "^2", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.18" + }, + "type": "library", + "autoload": { + "files": [ + "src/Context/functions.php", + "src/Context/Internal/functions.php", + "src/Ipc/functions.php", + "src/Worker/functions.php" + ], + "psr-4": { + "Amp\\Parallel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + }, + { + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" + } + ], + "description": "Parallel processing component for Amp.", + "homepage": "https://github.com/amphp/parallel", + "keywords": [ + "async", + "asynchronous", + "concurrent", + "multi-processing", + "multi-threading" + ], + "support": { + "issues": "https://github.com/amphp/parallel/issues", + "source": "https://github.com/amphp/parallel/tree/v2.3.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-12-21T01:56:09+00:00" + }, + { + "name": "amphp/parser", + "version": "v1.1.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/parser.git", + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/parser/zipball/3cf1f8b32a0171d4b1bed93d25617637a77cded7", + "reference": "3cf1f8b32a0171d4b1bed93d25617637a77cded7", + "shasum": "" + }, + "require": { + "php": ">=7.4" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\Parser\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A generator parser to make streaming parsers simple.", + "homepage": "https://github.com/amphp/parser", + "keywords": [ + "async", + "non-blocking", + "parser", + "stream" + ], + "support": { + "issues": "https://github.com/amphp/parser/issues", + "source": "https://github.com/amphp/parser/tree/v1.1.1" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-03-21T19:16:53+00:00" + }, + { + "name": "amphp/pipeline", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/amphp/pipeline.git", + "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/pipeline/zipball/97cbf289f4d8877acfe58dd90ed5a4370a43caa4", + "reference": "97cbf289f4d8877acfe58dd90ed5a4370a43caa4", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "php": ">=8.1", + "revolt/event-loop": "^1" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.18" + }, + "type": "library", + "autoload": { + "psr-4": { + "Amp\\Pipeline\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Asynchronous iterators and operators.", + "homepage": "https://amphp.org/pipeline", + "keywords": [ + "amp", + "amphp", + "async", + "io", + "iterator", + "non-blocking" + ], + "support": { + "issues": "https://github.com/amphp/pipeline/issues", + "source": "https://github.com/amphp/pipeline/tree/v1.2.2" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2025-01-19T15:42:46+00:00" + }, + { + "name": "amphp/process", + "version": "v2.0.3", + "source": { + "type": "git", + "url": "https://github.com/amphp/process.git", + "reference": "52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", - "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "url": "https://api.github.com/repos/amphp/process/zipball/52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d", + "reference": "52e08c09dec7511d5fbc1fb00d3e4e79fc77d58d", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/sync": "^2", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.4" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Process\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bob Weinand", + "email": "bobwei9@hotmail.com" + }, + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "A fiber-aware process manager based on Amp and Revolt.", + "homepage": "https://amphp.org/process", + "support": { + "issues": "https://github.com/amphp/process/issues", + "source": "https://github.com/amphp/process/tree/v2.0.3" + }, + "funding": [ + { + "url": "https://github.com/amphp", + "type": "github" + } + ], + "time": "2024-04-19T03:13:44+00:00" + }, + { + "name": "amphp/serialization", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/amphp/serialization.git", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/serialization/zipball/693e77b2fb0b266c3c7d622317f881de44ae94a1", + "reference": "693e77b2fb0b266c3c7d622317f881de44ae94a1", "shasum": "" }, "require": { "php": ">=7.1" }, "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1", - "ext-json": "*", - "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^7 | ^8 | ^9", - "react/promise": "^2", - "vimeo/psalm": "^3.12" + "amphp/php-cs-fixer-config": "dev-master", + "phpunit/phpunit": "^9 || ^8 || ^7" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "Amp\\Serialization\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Serialization tools for IPC and data storage in PHP.", + "homepage": "https://github.com/amphp/serialization", + "keywords": [ + "async", + "asynchronous", + "serialization", + "serialize" + ], + "support": { + "issues": "https://github.com/amphp/serialization/issues", + "source": "https://github.com/amphp/serialization/tree/master" + }, + "time": "2020-03-25T21:39:07+00:00" + }, + { + "name": "amphp/socket", + "version": "v2.3.1", + "source": { + "type": "git", + "url": "https://github.com/amphp/socket.git", + "reference": "58e0422221825b79681b72c50c47a930be7bf1e1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/amphp/socket/zipball/58e0422221825b79681b72c50c47a930be7bf1e1", + "reference": "58e0422221825b79681b72c50c47a930be7bf1e1", + "shasum": "" + }, + "require": { + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/dns": "^2", + "ext-openssl": "*", + "kelunik/certificate": "^1.1", + "league/uri": "^6.5 | ^7", + "league/uri-interfaces": "^2.3 | ^7", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "amphp/process": "^2", + "phpunit/phpunit": "^9", + "psalm/phar": "5.20" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.x-dev" - } - }, "autoload": { "files": [ - "lib/functions.php", - "lib/Internal/functions.php" + "src/functions.php", + "src/Internal/functions.php", + "src/SocketAddress/functions.php" ], "psr-4": { - "Amp\\": "lib" + "Amp\\Socket\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -413,38 +1066,31 @@ "authors": [ { "name": "Daniel Lowrey", - "email": "rdlowrey@php.net" + "email": "rdlowrey@gmail.com" }, { "name": "Aaron Piotrowski", "email": "aaron@trowski.com" }, - { - "name": "Bob Weinand", - "email": "bobwei9@hotmail.com" - }, { "name": "Niklas Keller", "email": "me@kelunik.com" } ], - "description": "A non-blocking concurrency framework for PHP applications.", - "homepage": "https://amphp.org/amp", + "description": "Non-blocking socket connection / server implementations based on Amp and Revolt.", + "homepage": "https://github.com/amphp/socket", "keywords": [ + "amp", "async", - "asynchronous", - "awaitable", - "concurrency", - "event", - "event-loop", - "future", + "encryption", "non-blocking", - "promise" + "sockets", + "tcp", + "tls" ], "support": { - "irc": "irc://irc.freenode.org/amphp", - "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.4" + "issues": "https://github.com/amphp/socket/issues", + "source": "https://github.com/amphp/socket/tree/v2.3.1" }, "funding": [ { @@ -452,41 +1098,42 @@ "type": "github" } ], - "time": "2024-03-21T18:52:26+00:00" + "time": "2024-04-21T14:33:03+00:00" }, { - "name": "amphp/byte-stream", - "version": "v1.8.2", + "name": "amphp/sync", + "version": "v2.3.0", "source": { "type": "git", - "url": "https://github.com/amphp/byte-stream.git", - "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc" + "url": "https://github.com/amphp/sync.git", + "reference": "217097b785130d77cfcc58ff583cf26cd1770bf1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/byte-stream/zipball/4f0e968ba3798a423730f567b1b50d3441c16ddc", - "reference": "4f0e968ba3798a423730f567b1b50d3441c16ddc", + "url": "https://api.github.com/repos/amphp/sync/zipball/217097b785130d77cfcc58ff583cf26cd1770bf1", + "reference": "217097b785130d77cfcc58ff583cf26cd1770bf1", "shasum": "" }, "require": { - "amphp/amp": "^2", - "php": ">=7.1" + "amphp/amp": "^3", + "amphp/pipeline": "^1", + "amphp/serialization": "^1", + "php": ">=8.1", + "revolt/event-loop": "^1 || ^0.2" }, "require-dev": { - "amphp/php-cs-fixer-config": "dev-master", - "amphp/phpunit-util": "^1.4", - "friendsofphp/php-cs-fixer": "^2.3", - "jetbrains/phpstorm-stubs": "^2019.3", - "phpunit/phpunit": "^6 || ^7 || ^8", - "psalm/phar": "^3.11.4" + "amphp/php-cs-fixer-config": "^2", + "amphp/phpunit-util": "^3", + "phpunit/phpunit": "^9", + "psalm/phar": "5.23" }, "type": "library", "autoload": { "files": [ - "lib/functions.php" + "src/functions.php" ], "psr-4": { - "Amp\\ByteStream\\": "lib" + "Amp\\Sync\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -501,21 +1148,24 @@ { "name": "Niklas Keller", "email": "me@kelunik.com" + }, + { + "name": "Stephen Coakley", + "email": "me@stephencoakley.com" } ], - "description": "A stream abstraction to make working with non-blocking I/O simple.", - "homepage": "https://amphp.org/byte-stream", + "description": "Non-blocking synchronization primitives for PHP based on Amp and Revolt.", + "homepage": "https://github.com/amphp/sync", "keywords": [ - "amp", - "amphp", "async", - "io", - "non-blocking", - "stream" + "asynchronous", + "mutex", + "semaphore", + "synchronization" ], "support": { - "issues": "https://github.com/amphp/byte-stream/issues", - "source": "https://github.com/amphp/byte-stream/tree/v1.8.2" + "issues": "https://github.com/amphp/sync/issues", + "source": "https://github.com/amphp/sync/tree/v2.3.0" }, "funding": [ { @@ -523,7 +1173,7 @@ "type": "github" } ], - "time": "2024-04-13T18:00:56+00:00" + "time": "2024-08-03T19:31:26+00:00" }, { "name": "composer/package-versions-deprecated", @@ -824,6 +1474,50 @@ ], "time": "2024-05-06T16:37:16+00:00" }, + { + "name": "daverandom/libdns", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/DaveRandom/LibDNS.git", + "reference": "b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/DaveRandom/LibDNS/zipball/b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a", + "reference": "b84c94e8fe6b7ee4aecfe121bfe3b6177d303c8a", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "Required for IDN support" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions.php" + ], + "psr-4": { + "LibDNS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "DNS protocol implementation written in pure PHP", + "keywords": [ + "dns" + ], + "support": { + "issues": "https://github.com/DaveRandom/LibDNS/issues", + "source": "https://github.com/DaveRandom/LibDNS/tree/v2.1.0" + }, + "time": "2024-04-12T12:12:48+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v1.0.0", @@ -1146,6 +1840,64 @@ ], "time": "2024-08-06T10:04:20+00:00" }, + { + "name": "kelunik/certificate", + "version": "v1.1.3", + "source": { + "type": "git", + "url": "https://github.com/kelunik/certificate.git", + "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kelunik/certificate/zipball/7e00d498c264d5eb4f78c69f41c8bd6719c0199e", + "reference": "7e00d498c264d5eb4f78c69f41c8bd6719c0199e", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "php": ">=7.0" + }, + "require-dev": { + "amphp/php-cs-fixer-config": "^2", + "phpunit/phpunit": "^6 | 7 | ^8 | ^9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Kelunik\\Certificate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Access certificate details and transform between different formats.", + "keywords": [ + "DER", + "certificate", + "certificates", + "openssl", + "pem", + "x509" + ], + "support": { + "issues": "https://github.com/kelunik/certificate/issues", + "source": "https://github.com/kelunik/certificate/tree/v1.1.3" + }, + "time": "2023-02-03T21:26:53+00:00" + }, { "name": "laminas/laminas-coding-standard", "version": "3.0.1", @@ -1287,6 +2039,180 @@ ], "time": "2024-10-14T11:59:49+00:00" }, + { + "name": "league/uri", + "version": "7.5.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri.git", + "reference": "81fb5145d2644324614cc532b28efd0215bda430" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430", + "reference": "81fb5145d2644324614cc532b28efd0215bda430", + "shasum": "" + }, + "require": { + "league/uri-interfaces": "^7.5", + "php": "^8.1" + }, + "conflict": { + "league/uri-schemes": "^1.0" + }, + "suggest": { + "ext-bcmath": "to improve IPV4 host parsing", + "ext-fileinfo": "to create Data URI from file contennts", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain", + "league/uri-components": "Needed to easily manipulate URI objects components", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "URI manipulation library", + "homepage": "https://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "middleware", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "uri-template", + "url", + "ws" + ], + "support": { + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri/tree/7.5.1" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-12-08T08:40:02+00:00" + }, + { + "name": "league/uri-interfaces", + "version": "7.5.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri-interfaces.git", + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", + "reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^8.1", + "psr/http-factory": "^1", + "psr/http-message": "^1.1 || ^2.0" + }, + "suggest": { + "ext-bcmath": "to improve IPV4 host parsing", + "ext-gmp": "to improve IPV4 host parsing", + "ext-intl": "to handle IDN host with the best performance", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Uri\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://nyamsprod.com" + } + ], + "description": "Common interfaces and classes for URI representation and interaction", + "homepage": "https://uri.thephpleague.com", + "keywords": [ + "data-uri", + "file-uri", + "ftp", + "hostname", + "http", + "https", + "parse_str", + "parse_url", + "psr-7", + "query-string", + "querystring", + "rfc3986", + "rfc3987", + "rfc6570", + "uri", + "url", + "ws" + ], + "support": { + "docs": "https://uri.thephpleague.com", + "forum": "https://thephpleague.slack.com", + "issues": "https://github.com/thephpleague/uri-src/issues", + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0" + }, + "funding": [ + { + "url": "https://github.com/sponsors/nyamsprod", + "type": "github" + } + ], + "time": "2024-12-08T08:18:47+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.12.1", @@ -2390,16 +3316,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.5.40", + "version": "10.5.44", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c" + "reference": "1381c62769be4bb88fa4c5aec1366c7c66ca4f36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e6ddda95af52f69c1e0c7b4f977cccb58048798c", - "reference": "e6ddda95af52f69c1e0c7b4f977cccb58048798c", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1381c62769be4bb88fa4c5aec1366c7c66ca4f36", + "reference": "1381c62769be4bb88fa4c5aec1366c7c66ca4f36", "shasum": "" }, "require": { @@ -2471,7 +3397,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.40" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.44" }, "funding": [ { @@ -2487,28 +3413,28 @@ "type": "tidelift" } ], - "time": "2024-12-21T05:49:06+00:00" + "time": "2025-01-31T07:00:38+00:00" }, { "name": "psalm/plugin-phpunit", - "version": "0.19.0", + "version": "0.19.2", "source": { "type": "git", "url": "https://github.com/psalm/psalm-plugin-phpunit.git", - "reference": "e344eaaa27871e79c6cb97b9efe52a735f9d1966" + "reference": "7b7a5cde988f83ccdbdf3ebaecd88192e01c5eb1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/e344eaaa27871e79c6cb97b9efe52a735f9d1966", - "reference": "e344eaaa27871e79c6cb97b9efe52a735f9d1966", + "url": "https://api.github.com/repos/psalm/psalm-plugin-phpunit/zipball/7b7a5cde988f83ccdbdf3ebaecd88192e01c5eb1", + "reference": "7b7a5cde988f83ccdbdf3ebaecd88192e01c5eb1", "shasum": "" }, "require": { "composer/package-versions-deprecated": "^1.10", "composer/semver": "^1.4 || ^2.0 || ^3.0", "ext-simplexml": "*", - "php": "^7.4 || ^8.0", - "vimeo/psalm": "dev-master || ^5@beta || ^5.0" + "php": ">=8.1", + "vimeo/psalm": "dev-master || ^6" }, "conflict": { "phpunit/phpunit": "<7.5" @@ -2545,9 +3471,9 @@ "description": "Psalm plugin for PHPUnit", "support": { "issues": "https://github.com/psalm/psalm-plugin-phpunit/issues", - "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.19.0" + "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.19.2" }, - "time": "2024-03-15T10:43:15+00:00" + "time": "2025-01-26T11:39:17+00:00" }, { "name": "psr/http-factory", @@ -2654,6 +3580,78 @@ }, "time": "2024-09-11T13:17:53+00:00" }, + { + "name": "revolt/event-loop", + "version": "v1.0.6", + "source": { + "type": "git", + "url": "https://github.com/revoltphp/event-loop.git", + "reference": "25de49af7223ba039f64da4ae9a28ec2d10d0254" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/revoltphp/event-loop/zipball/25de49af7223ba039f64da4ae9a28ec2d10d0254", + "reference": "25de49af7223ba039f64da4ae9a28ec2d10d0254", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-json": "*", + "jetbrains/phpstorm-stubs": "^2019.3", + "phpunit/phpunit": "^9", + "psalm/phar": "^5.15" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Revolt\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aaron Piotrowski", + "email": "aaron@trowski.com" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + }, + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + }, + { + "name": "Niklas Keller", + "email": "me@kelunik.com" + } + ], + "description": "Rock-solid event loop for concurrent PHP applications.", + "keywords": [ + "async", + "asynchronous", + "concurrency", + "event", + "event-loop", + "non-blocking", + "scheduler" + ], + "support": { + "issues": "https://github.com/revoltphp/event-loop/issues", + "source": "https://github.com/revoltphp/event-loop/tree/v1.0.6" + }, + "time": "2023-11-30T05:34:44+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.1", @@ -3705,16 +4703,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.2", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -3779,9 +4777,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-12-11T16:04:26+00:00" + "time": "2025-01-23T17:04:15+00:00" }, { "name": "symfony/console", @@ -4549,21 +5551,22 @@ }, { "name": "vimeo/psalm", - "version": "5.26.1", + "version": "6.2.0", "source": { "type": "git", "url": "https://github.com/vimeo/psalm.git", - "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0" + "reference": "814dfde37b43a1fe6d9b0996e08b19661af53bc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/vimeo/psalm/zipball/d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", - "reference": "d747f6500b38ac4f7dfc5edbcae6e4b637d7add0", + "url": "https://api.github.com/repos/vimeo/psalm/zipball/814dfde37b43a1fe6d9b0996e08b19661af53bc5", + "reference": "814dfde37b43a1fe6d9b0996e08b19661af53bc5", "shasum": "" }, "require": { - "amphp/amp": "^2.4.2", - "amphp/byte-stream": "^1.5", + "amphp/amp": "^3", + "amphp/byte-stream": "^2", + "amphp/parallel": "^2.3", "composer-runtime-api": "^2", "composer/semver": "^1.4 || ^2.0 || ^3.0", "composer/xdebug-handler": "^2.0 || ^3.0", @@ -4576,26 +5579,24 @@ "ext-simplexml": "*", "ext-tokenizer": "*", "felixfbecker/advanced-json-rpc": "^3.1", - "felixfbecker/language-server-protocol": "^1.5.2", + "felixfbecker/language-server-protocol": "^1.5.3", "fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0", "netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0", - "nikic/php-parser": "^4.17", - "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0", + "nikic/php-parser": "^5.0.0", + "php": "~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0", "sebastian/diff": "^4.0 || ^5.0 || ^6.0", "spatie/array-to-xml": "^2.17.0 || ^3.0", - "symfony/console": "^4.1.6 || ^5.0 || ^6.0 || ^7.0", - "symfony/filesystem": "^5.4 || ^6.0 || ^7.0" - }, - "conflict": { - "nikic/php-parser": "4.17.0" + "symfony/console": "^6.0 || ^7.0", + "symfony/filesystem": "^6.0 || ^7.0" }, "provide": { "psalm/psalm": "self.version" }, "require-dev": { - "amphp/phpunit-util": "^2.0", + "amphp/phpunit-util": "^3", "bamarni/composer-bin-plugin": "^1.4", "brianium/paratest": "^6.9", + "dg/bypass-finals": "^1.5", "ext-curl": "*", "mockery/mockery": "^1.5", "nunomaduro/mock-final-classes": "^1.1", @@ -4603,10 +5604,10 @@ "phpstan/phpdoc-parser": "^1.6", "phpunit/phpunit": "^9.6", "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18", + "psalm/plugin-phpunit": "^0.19", "slevomat/coding-standard": "^8.4", "squizlabs/php_codesniffer": "^3.6", - "symfony/process": "^4.4 || ^5.0 || ^6.0 || ^7.0" + "symfony/process": "^6.0 || ^7.0" }, "suggest": { "ext-curl": "In order to send data to shepherd", @@ -4626,7 +5627,9 @@ "dev-2.x": "2.x-dev", "dev-3.x": "3.x-dev", "dev-4.x": "4.x-dev", - "dev-master": "5.x-dev" + "dev-5.x": "5.x-dev", + "dev-6.x": "6.x-dev", + "dev-master": "7.x-dev" } }, "autoload": { @@ -4641,6 +5644,10 @@ "authors": [ { "name": "Matthew Brown" + }, + { + "name": "Daniil Gentili", + "email": "daniil@daniil.it" } ], "description": "A static analysis tool for finding errors in PHP applications", @@ -4655,7 +5662,7 @@ "issues": "https://github.com/vimeo/psalm/issues", "source": "https://github.com/vimeo/psalm" }, - "time": "2024-09-08T18:53:08+00:00" + "time": "2025-02-01T16:30:21+00:00" }, { "name": "webimpress/coding-standard", diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 50999eb1..e3814642 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + @@ -54,12 +54,12 @@ - - - + + + @@ -125,11 +125,6 @@ - - - ]]> - - alreadyFiltered[$alreadyFilteredKey]]]> alreadyFiltered[$fileName]]]> @@ -179,20 +174,6 @@ - - - - - - - - - - - - - - diff --git a/src/Compress/Bz2Adapter.php b/src/Compress/Bz2Adapter.php index 7b654f02..870eb08f 100644 --- a/src/Compress/Bz2Adapter.php +++ b/src/Compress/Bz2Adapter.php @@ -58,8 +58,8 @@ public function decompress(string $value): string { $decompressed = bzdecompress($value); - if (is_int($decompressed)) { - throw new RuntimeException(sprintf('Error during decompression: Bz Error code %d', $decompressed)); + if (is_int($decompressed) || $decompressed === false) { + throw new RuntimeException(sprintf('Error during decompression: Bz Error code %d', (string) $decompressed)); } assert($decompressed !== ''); diff --git a/src/EncodingOption.php b/src/EncodingOption.php index 38d45753..9c5dc62f 100644 --- a/src/EncodingOption.php +++ b/src/EncodingOption.php @@ -22,7 +22,7 @@ final class EncodingOption public static function assert(string $encoding): string { $encoding = strtolower($encoding); - $available = array_map('strtolower', mb_list_encodings()); + $available = array_map(strtolower(...), mb_list_encodings()); if (! in_array($encoding, $available, true)) { throw new InvalidArgumentException(sprintf( "Encoding '%s' is not supported by the mbstring extension", diff --git a/src/File/FileInformation.php b/src/File/FileInformation.php index 2e46a9a5..7b14175b 100644 --- a/src/File/FileInformation.php +++ b/src/File/FileInformation.php @@ -4,6 +4,7 @@ namespace Laminas\Filter\File; +use finfo; use Laminas\Filter\Exception\RuntimeException; use Psr\Http\Message\UploadedFileInterface; @@ -38,6 +39,7 @@ public function detectMimeType(): string { if ($this->mediaType === null) { $fileInfo = finfo_open(FILEINFO_MIME_TYPE); + assert($fileInfo instanceof finfo); $mime = $fileInfo->file($this->path); assert(is_string($mime)); diff --git a/src/File/RenameUpload.php b/src/File/RenameUpload.php index b08218c5..53ea4b52 100644 --- a/src/File/RenameUpload.php +++ b/src/File/RenameUpload.php @@ -11,11 +11,13 @@ use Psr\Http\Message\UploadedFileFactoryInterface; use Psr\Http\Message\UploadedFileInterface; +use function assert; use function basename; use function file_exists; use function filesize; use function is_array; use function is_dir; +use function is_int; use function is_string; use function move_uploaded_file; use function pathinfo; @@ -457,9 +459,12 @@ private function filterPsr7UploadedFile(UploadedFileInterface $uploadedFile) )); } + $size = filesize($targetFile); + assert(is_int($size)); + $this->alreadyFiltered[$alreadyFilteredKey] = $uploadedFileFactory->createUploadedFile( $stream, - filesize($targetFile), + $size, UPLOAD_ERR_OK, $uploadedFile->getClientFilename(), $uploadedFile->getClientMediaType() diff --git a/src/HtmlEntities.php b/src/HtmlEntities.php index 36d2d757..ae0be2b0 100644 --- a/src/HtmlEntities.php +++ b/src/HtmlEntities.php @@ -4,6 +4,7 @@ namespace Laminas\Filter; +use function assert; use function function_exists; use function htmlentities; use function iconv; @@ -70,7 +71,9 @@ public function filter(mixed $value): mixed if (! function_exists('iconv')) { throw new Exception\DomainException('Encoding mismatch has resulted in htmlentities errors'); } - $value = iconv('', $this->encoding . '//IGNORE', $value); + + $value = iconv('', $this->encoding . '//IGNORE', $value); + assert(is_string($value)); $filtered = htmlentities($value, $this->quoteStyle, $this->encoding, $this->doubleQuote); if (strlen($filtered) === 0) { throw new Exception\DomainException('Encoding mismatch has resulted in htmlentities errors'); diff --git a/src/Inflector.php b/src/Inflector.php index a41abc1c..db256d9d 100644 --- a/src/Inflector.php +++ b/src/Inflector.php @@ -153,6 +153,7 @@ public function filter(mixed $value): mixed // all of the values of processedParts would have been str_replace('\\', '\\\\', ..)'d // to disable preg_replace backreferences $inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->target); + assert($inflectedTarget !== null); if ( $this->throwTargetExceptionsOn diff --git a/src/PregReplace.php b/src/PregReplace.php index b3fd489d..35c2878d 100644 --- a/src/PregReplace.php +++ b/src/PregReplace.php @@ -8,6 +8,7 @@ use function array_filter; use function array_values; +use function assert; use function is_array; use function is_string; use function preg_match; @@ -46,7 +47,12 @@ public function filter(mixed $value): mixed { return ScalarOrArrayFilterCallback::applyRecursively( $value, - fn (string $value): string => preg_replace($this->pattern, $this->replacement, $value), + function (string $value): string { + $result = preg_replace($this->pattern, $this->replacement, $value); + assert(is_string($result)); + + return $result; + }, ); } diff --git a/src/RealPath.php b/src/RealPath.php index 7992bd0c..6bb557f9 100644 --- a/src/RealPath.php +++ b/src/RealPath.php @@ -5,6 +5,7 @@ namespace Laminas\Filter; use function array_pop; +use function assert; use function explode; use function file_exists; use function getcwd; @@ -50,7 +51,10 @@ public function filter(mixed $value): mixed $path = $value; if (! str_starts_with($path, DIRECTORY_SEPARATOR)) { - $path = getcwd() . DIRECTORY_SEPARATOR . $path; + $cwd = getcwd(); + assert(is_string($cwd)); + + $path = $cwd . DIRECTORY_SEPARATOR . $path; } $stack = []; diff --git a/src/StringTrim.php b/src/StringTrim.php index 80951255..2af2664b 100644 --- a/src/StringTrim.php +++ b/src/StringTrim.php @@ -4,6 +4,7 @@ namespace Laminas\Filter; +use function assert; use function is_string; use function preg_replace; @@ -48,10 +49,14 @@ private function unicodeTrim(string $value): string ['\\\\\\0', '\\', '\/'], $this->charlist, ); + assert(is_string($chars)); $pattern = '/^[' . $chars . ']+|[' . $chars . ']+$/usSD'; - return preg_replace($pattern, '', $value); + $value = preg_replace($pattern, '', $value); + assert(is_string($value)); + + return $value; } public function __invoke(mixed $value): mixed diff --git a/src/Word/CamelCaseToSeparator.php b/src/Word/CamelCaseToSeparator.php index d9848959..feb0b904 100644 --- a/src/Word/CamelCaseToSeparator.php +++ b/src/Word/CamelCaseToSeparator.php @@ -7,7 +7,9 @@ use Laminas\Filter\FilterInterface; use Laminas\Filter\ScalarOrArrayFilterCallback; +use function assert; use function implode; +use function is_array; use function preg_split; use const PREG_SPLIT_DELIM_CAPTURE; @@ -37,24 +39,29 @@ public function __invoke(mixed $value): mixed public function filter(mixed $value): mixed { - $pattern = << implode( - $this->separator, - preg_split($pattern, $input, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY), - ) + function (string $input): string { + $pattern = <<separator, + $parts, + ); + }, ); } } diff --git a/src/Word/SeparatorToCamelCase.php b/src/Word/SeparatorToCamelCase.php index ac1420f8..d6120d08 100644 --- a/src/Word/SeparatorToCamelCase.php +++ b/src/Word/SeparatorToCamelCase.php @@ -7,6 +7,7 @@ use Laminas\Filter\FilterInterface; use Laminas\Filter\ScalarOrArrayFilterCallback; +use function assert; use function mb_strtoupper; use function preg_quote; use function preg_replace_callback; @@ -37,8 +38,8 @@ public function filter(mixed $value): mixed '#(^\P{Z}{1})#u', ]; $replacements = [ - static fn($matches): string => mb_strtoupper($matches[2], 'UTF-8'), - static fn($matches): string => mb_strtoupper($matches[1], 'UTF-8'), + static fn(array $matches): string => mb_strtoupper((string) $matches[2], 'UTF-8'), + static fn(array $matches): string => mb_strtoupper((string) $matches[1], 'UTF-8'), ]; return ScalarOrArrayFilterCallback::applyRecursively( @@ -46,7 +47,10 @@ public function filter(mixed $value): mixed function (string $input) use ($patterns, $replacements): string { $filtered = $input; foreach ($patterns as $index => $pattern) { - $filtered = preg_replace_callback($pattern, $replacements[$index], $filtered); + $value = preg_replace_callback($pattern, $replacements[$index], $filtered); + assert($value !== null); + + $filtered = $value; } return $filtered; } diff --git a/src/Word/SeparatorToSeparator.php b/src/Word/SeparatorToSeparator.php index db90823c..4fb7eb89 100644 --- a/src/Word/SeparatorToSeparator.php +++ b/src/Word/SeparatorToSeparator.php @@ -7,6 +7,8 @@ use Laminas\Filter\FilterInterface; use Laminas\Filter\ScalarOrArrayFilterCallback; +use function assert; +use function is_string; use function preg_quote; use function preg_replace; @@ -34,11 +36,16 @@ public function filter(mixed $value): mixed { return ScalarOrArrayFilterCallback::applyRecursively( $value, - fn (string $input): string => preg_replace( - '#' . preg_quote($this->searchSeparator, '#') . '#', - $this->replacementSeparator, - $input - ) + function (string $input): string { + $result = preg_replace( + '#' . preg_quote($this->searchSeparator, '#') . '#', + $this->replacementSeparator, + $input + ); + assert(is_string($result)); + + return $result; + }, ); } diff --git a/test/Compress/TarAdapterTest.php b/test/Compress/TarAdapterTest.php index 4d3de3f4..c2ab858f 100644 --- a/test/Compress/TarAdapterTest.php +++ b/test/Compress/TarAdapterTest.php @@ -118,7 +118,9 @@ public function testASingleFileCanBeCompressed(string|null $mode): void $expectFile = $this->dir . '/File1.txt'; self::assertFileExists($expectFile); - self::assertSame('File 1', trim(file_get_contents($expectFile))); + $contents = file_get_contents($expectFile); + self::assertIsString($contents); + self::assertSame('File 1', trim($contents)); } public function testCompressFileThatDoesNotExist(): void diff --git a/test/CompressToArchiveTest.php b/test/CompressToArchiveTest.php index 93b37364..8a147625 100644 --- a/test/CompressToArchiveTest.php +++ b/test/CompressToArchiveTest.php @@ -128,9 +128,11 @@ public function testPsrUploadedFileCompression(array $options): void { $filter = new CompressToArchive($options); $path = __DIR__ . '/Compress/fixtures/directory-to-compress/File1.txt'; + $size = filesize($path); + self::assertIsInt($size); $upload = new UploadedFile( $path, - filesize($path), + $size, UPLOAD_ERR_OK, 'Foo.txt', 'text/plain', diff --git a/test/DecompressArchiveTest.php b/test/DecompressArchiveTest.php index a6b0daa2..c1d1b74a 100644 --- a/test/DecompressArchiveTest.php +++ b/test/DecompressArchiveTest.php @@ -93,9 +93,12 @@ public function testThatPsr7UploadsWillBeDecompressed(string $value, string $exp { $filter = new DecompressArchive(['target' => $this->target]); + $size = filesize($value); + self::assertIsInt($size); + $upload = new UploadedFile( $value, - filesize($value), + $size, UPLOAD_ERR_OK, 'Foo.txt', 'text/plain', diff --git a/test/File/FileInformationTest.php b/test/File/FileInformationTest.php index a9b7ea42..9236f8df 100644 --- a/test/File/FileInformationTest.php +++ b/test/File/FileInformationTest.php @@ -54,10 +54,12 @@ public function testExpectedValuesForFilePath(): void public function testExpectedValuesForUploadedFile(): void { $path = __DIR__ . '/fixtures/File1.txt'; + $size = filesize($path); + self::assertIsInt($size); $upload = new UploadedFile( $path, - filesize($path), + $size, UPLOAD_ERR_OK, 'Foo.txt', 'text/plain', diff --git a/test/File/LowerCaseTest.php b/test/File/LowerCaseTest.php index dbc7ac66..8c535593 100644 --- a/test/File/LowerCaseTest.php +++ b/test/File/LowerCaseTest.php @@ -45,18 +45,18 @@ public function tearDown(): void public function testInstanceCreationAndNormalWorkflow(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileLowerCase(); $filter($this->testFile); - self::assertStringContainsString('this is a file', file_get_contents($this->testFile)); + self::assertStringContainsString('this is a file', $this->fileGetContents($this->testFile)); } public function testNormalWorkflowWithFilesArray(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileLowerCase(); $filter(['tmp_name' => $this->testFile]); - self::assertStringContainsString('this is a file', file_get_contents($this->testFile)); + self::assertStringContainsString('this is a file', $this->fileGetContents($this->testFile)); } public function testFileNotFoundException(): void @@ -69,10 +69,18 @@ public function testFileNotFoundException(): void public function testCheckSettingOfEncodingInInstance(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileLowerCase(['encoding' => 'ISO-8859-1']); $filter($this->testFile); - self::assertStringContainsString('this is a file', file_get_contents($this->testFile)); + self::assertStringContainsString('this is a file', $this->fileGetContents($this->testFile)); + } + + private function fileGetContents(string $path): string + { + $content = file_get_contents($path); + self::assertIsString($content); + + return $content; } public static function returnUnfilteredDataProvider(): array diff --git a/test/File/RenameUploadTest.php b/test/File/RenameUploadTest.php index 339eb65f..b2506910 100644 --- a/test/File/RenameUploadTest.php +++ b/test/File/RenameUploadTest.php @@ -91,7 +91,9 @@ private function removeDir(string $dir): void return; } - foreach (glob($dir . DIRECTORY_SEPARATOR . '*') as $file) { + $list = glob($dir . DIRECTORY_SEPARATOR . '*'); + self::assertIsArray($list); + foreach ($list as $file) { if (is_file($file)) { unlink($file); continue; diff --git a/test/File/UpperCaseTest.php b/test/File/UpperCaseTest.php index 8329057e..ee6fc106 100644 --- a/test/File/UpperCaseTest.php +++ b/test/File/UpperCaseTest.php @@ -58,18 +58,18 @@ public function tearDown(): void public function testInstanceCreationAndNormalWorkflow(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileUpperCase(); $filter($this->testFile); - self::assertStringContainsString('THIS IS A FILE', file_get_contents($this->testFile)); + self::assertStringContainsString('THIS IS A FILE', $this->fileGetContents($this->testFile)); } public function testNormalWorkflowWithFilesArray(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileUpperCase(); $filter(['tmp_name' => $this->testFile]); - self::assertStringContainsString('THIS IS A FILE', file_get_contents($this->testFile)); + self::assertStringContainsString('THIS IS A FILE', $this->fileGetContents($this->testFile)); } public function testFileNotFoundException(): void @@ -82,10 +82,18 @@ public function testFileNotFoundException(): void public function testCheckSettingOfEncodingInInstance(): void { - self::assertStringContainsString('This is a File', file_get_contents($this->testFile)); + self::assertStringContainsString('This is a File', $this->fileGetContents($this->testFile)); $filter = new FileUpperCase(['encoding' => 'ISO-8859-1']); $filter($this->testFile); - self::assertStringContainsString('THIS IS A FILE', file_get_contents($this->testFile)); + self::assertStringContainsString('THIS IS A FILE', $this->fileGetContents($this->testFile)); + } + + private function fileGetContents(string $path): string + { + $content = file_get_contents($path); + self::assertIsString($content); + + return $content; } public static function returnUnfilteredDataProvider(): array diff --git a/test/RealPathTest.php b/test/RealPathTest.php index 943c7e6e..2850b35c 100644 --- a/test/RealPathTest.php +++ b/test/RealPathTest.php @@ -63,7 +63,9 @@ public function testBSDAllowsLastPortionToNotExist(): void $path = './nonexistent'; if (str_contains(PHP_OS, 'BSD')) { - self::assertSame(getcwd() . '/nonexistent', $filter($path)); + $cwd = getcwd(); + self::assertIsString($cwd); + self::assertSame($cwd . '/nonexistent', $filter($path)); } else { self::assertSame($path, $filter($path)); } @@ -71,12 +73,15 @@ public function testBSDAllowsLastPortionToNotExist(): void public static function returnNonExistentPathDataProvider(): array { + $cwd = getcwd(); + self::assertIsString($cwd); + return [ ['/nonexistent/absolute/path', '/nonexistent/absolute/path'], ['/nonexistent/absolute/extra///slashes', '/nonexistent/absolute/extra/slashes'], - ['./nonexistent/relative/path', getcwd() . '/nonexistent/relative/path'], - ['./dropped/parts/../../path', getcwd() . '/path'], - ['../relative/from/parent', dirname(getcwd()) . '/relative/from/parent'], + ['./nonexistent/relative/path', $cwd . '/nonexistent/relative/path'], + ['./dropped/parts/../../path', $cwd . '/path'], + ['../relative/from/parent', dirname($cwd) . '/relative/from/parent'], ]; } diff --git a/test/StringTrimTest.php b/test/StringTrimTest.php index e518c3a6..87afff5b 100644 --- a/test/StringTrimTest.php +++ b/test/StringTrimTest.php @@ -9,6 +9,8 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; +use function assert; +use function is_string; use function mb_chr; use function str_repeat; @@ -17,14 +19,21 @@ class StringTrimTest extends TestCase /** @return array */ public static function defaultBehaviourDataProvider(): array { + $mbChr = static function (int $code): string { + $value = mb_chr($code); + assert(is_string($value)); + + return $value; + }; + return [ 'Ascii, no whitespace' => ['string', 'string'], 'Empty String' => ['', ''], 'Only Ascii whitespace' => [" \n\t ", ''], - 'Only Unicode whitespace' => [str_repeat(mb_chr(0x2029), 10), ''], - 'Narrow Spaces' => [mb_chr(0x202F) . 'Foo' . mb_chr(0x202F), 'Foo'], - 'Em Spaces' => [mb_chr(0x2003) . 'Foo' . mb_chr(0x2003), 'Foo'], - 'Thin Spaces' => [mb_chr(0x2009) . 'Foo' . mb_chr(0x2009), 'Foo'], + 'Only Unicode whitespace' => [str_repeat($mbChr(0x2029), 10), ''], + 'Narrow Spaces' => [$mbChr(0x202F) . 'Foo' . $mbChr(0x202F), 'Foo'], + 'Em Spaces' => [$mbChr(0x2003) . 'Foo' . $mbChr(0x2003), 'Foo'], + 'Thin Spaces' => [$mbChr(0x2009) . 'Foo' . $mbChr(0x2009), 'Foo'], 'ZF-7183' => ['Зенд', 'Зенд'], 'ZF-170' => ['Расчет', 'Расчет'], 'ZF-7902' => ['/', '/'],