From f55efb62c759d409849aeee9d5897d7d163e63bd Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 09:06:51 -0500 Subject: [PATCH 1/9] feat: prepare for PHP 8.1 support - Adds `~8.1.0` to list of allowed PHP versions - Removes dev requirement on laminas-config; testing can be done with vanilla `Traversable` classes. - Bumps laminas-coding-standard to 2.2 series - Bumps PHPUnit to 9.5 series - Bumps laminas-stdlib, laminas-uri, laminas-loader, and laminas-validator dependencies to versions known to work with PHP 8.1 - Changes how the package replaces zend-http - Renames the "replace" section in the packager to "conflict" - Changes the zend-http constraint to "*" - Removes the dependency on laminas-zendframework-bridge - Adds the lockfile to the repository Signed-off-by: Matthew Weier O'Phinney --- .gitignore | 4 +- .laminas-ci.json | 5 + composer.json | 20 +- composer.lock | 2871 ++++++++++++++++++++++++++++++++++++ phpcs.xml | 9 - phpcs.xml.dist | 22 + test/Client/CurlTest.php | 10 +- test/Client/SocketTest.php | 10 +- test/Client/StaticTest.php | 10 +- 9 files changed, 2924 insertions(+), 37 deletions(-) create mode 100644 .laminas-ci.json create mode 100644 composer.lock delete mode 100644 phpcs.xml create mode 100644 phpcs.xml.dist diff --git a/.gitignore b/.gitignore index 978b2108..f6f6e633 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ +/.phpcs-cache +/.phpunit.result.cache /clover.xml -/composer.lock /coveralls-upload.json /docs/html/ /laminas-mkdoc-theme.tgz /laminas-mkdoc-theme/ /phpunit.xml /vendor/ -/.phpunit.result.cache diff --git a/.laminas-ci.json b/.laminas-ci.json new file mode 100644 index 00000000..bce3fa21 --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,5 @@ +{ + "ignore_php_platform_requirements": { + "8.1": true + } +} diff --git a/composer.json b/composer.json index 7ee29fe2..4284db42 100644 --- a/composer.json +++ b/composer.json @@ -20,17 +20,15 @@ "sort-packages": true }, "require": { - "php": "^7.3 || ~8.0.0", - "laminas/laminas-loader": "^2.5.1", - "laminas/laminas-stdlib": "^3.2.1", - "laminas/laminas-uri": "^2.5.2", - "laminas/laminas-validator": "^2.10.1", - "laminas/laminas-zendframework-bridge": "^1.0" + "php": "^7.3 || ~8.0.0 || ~8.1.0", + "laminas/laminas-loader": "^2.8", + "laminas/laminas-stdlib": "^3.6", + "laminas/laminas-uri": "^2.9", + "laminas/laminas-validator": "^2.15" }, "require-dev": { - "laminas/laminas-coding-standard": "~1.0.0", - "laminas/laminas-config": "^3.1 || ^2.6", - "phpunit/phpunit": "^9.3" + "laminas/laminas-coding-standard": "~2.2.1", + "phpunit/phpunit": "^9.5.5" }, "suggest": { "paragonie/certainty": "For automated management of cacert.pem" @@ -55,7 +53,7 @@ "test": "phpunit --colors=always", "test-coverage": "phpunit --colors=always --coverage-clover clover.xml" }, - "replace": { - "zendframework/zend-http": "^2.11.2" + "conflict": { + "zendframework/zend-http": "*" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..6c554eab --- /dev/null +++ b/composer.lock @@ -0,0 +1,2871 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "6156759afffef21f7325de36a76338df", + "packages": [ + { + "name": "container-interop/container-interop", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "shasum": "" + }, + "require": { + "psr/container": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "homepage": "https://github.com/container-interop/container-interop", + "support": { + "issues": "https://github.com/container-interop/container-interop/issues", + "source": "https://github.com/container-interop/container-interop/tree/master" + }, + "abandoned": "psr/container", + "time": "2017-02-14T19:40:03+00:00" + }, + { + "name": "laminas/laminas-escaper", + "version": "2.9.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-escaper.git", + "reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/891ad70986729e20ed2e86355fcf93c9dc238a5f", + "reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f", + "shasum": "" + }, + "require": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "conflict": { + "zendframework/zend-escaper": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.3.0", + "phpunit/phpunit": "^9.3", + "psalm/plugin-phpunit": "^0.12.2", + "vimeo/psalm": "^3.16" + }, + "suggest": { + "ext-iconv": "*", + "ext-mbstring": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Escaper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs", + "homepage": "https://laminas.dev", + "keywords": [ + "escaper", + "laminas" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-escaper/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-escaper/issues", + "rss": "https://github.com/laminas/laminas-escaper/releases.atom", + "source": "https://github.com/laminas/laminas-escaper" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-09-02T17:10:53+00:00" + }, + { + "name": "laminas/laminas-loader", + "version": "2.8.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-loader.git", + "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-loader/zipball/d0589ec9dd48365fd95ad10d1c906efd7711c16b", + "reference": "d0589ec9dd48365fd95ad10d1c906efd7711c16b", + "shasum": "" + }, + "require": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "conflict": { + "zendframework/zend-loader": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.2.1", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Loader\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Autoloading and plugin loading strategies", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "loader" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-loader/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-loader/issues", + "rss": "https://github.com/laminas/laminas-loader/releases.atom", + "source": "https://github.com/laminas/laminas-loader" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-09-02T18:30:53+00:00" + }, + { + "name": "laminas/laminas-stdlib", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-stdlib.git", + "reference": "c53d8537f108fac3fae652677a19735db730ba46" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-stdlib/zipball/c53d8537f108fac3fae652677a19735db730ba46", + "reference": "c53d8537f108fac3fae652677a19735db730ba46", + "shasum": "" + }, + "require": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "conflict": { + "zendframework/zend-stdlib": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.3.0", + "phpbench/phpbench": "^0.17.1", + "phpunit/phpunit": "~9.3.7", + "psalm/plugin-phpunit": "^0.16.0", + "vimeo/psalm": "^4.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Stdlib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "SPL extensions, array utilities, error handlers, and more", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "stdlib" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-stdlib/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-stdlib/issues", + "rss": "https://github.com/laminas/laminas-stdlib/releases.atom", + "source": "https://github.com/laminas/laminas-stdlib" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-09-02T16:11:32+00:00" + }, + { + "name": "laminas/laminas-uri", + "version": "2.9.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-uri.git", + "reference": "34c9386b7058bd52b3ea3b150bb34e0c97812c55" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/34c9386b7058bd52b3ea3b150bb34e0c97812c55", + "reference": "34c9386b7058bd52b3ea3b150bb34e0c97812c55", + "shasum": "" + }, + "require": { + "laminas/laminas-escaper": "^2.9", + "laminas/laminas-validator": "^2.15", + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "conflict": { + "zendframework/zend-uri": "*" + }, + "require-dev": { + "laminas/laminas-coding-standard": "~2.2.1", + "phpunit/phpunit": "^9.5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Laminas\\Uri\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "A component that aids in manipulating and validating ยป Uniform Resource Identifiers (URIs)", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "uri" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-uri/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-uri/issues", + "rss": "https://github.com/laminas/laminas-uri/releases.atom", + "source": "https://github.com/laminas/laminas-uri" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-09-09T13:57:23+00:00" + }, + { + "name": "laminas/laminas-validator", + "version": "2.15.0", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-validator.git", + "reference": "270380e87904f5a1a1fba3059989d4ca157e16a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-validator/zipball/270380e87904f5a1a1fba3059989d4ca157e16a9", + "reference": "270380e87904f5a1a1fba3059989d4ca157e16a9", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "^1.1", + "laminas/laminas-stdlib": "^3.6", + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "conflict": { + "zendframework/zend-validator": "*" + }, + "require-dev": { + "laminas/laminas-cache": "^2.6.1", + "laminas/laminas-coding-standard": "~2.2.1", + "laminas/laminas-db": "^2.7", + "laminas/laminas-filter": "^2.6", + "laminas/laminas-http": "^2.14.2", + "laminas/laminas-i18n": "^2.6", + "laminas/laminas-math": "^2.6", + "laminas/laminas-servicemanager": "^2.7.11 || ^3.0.3", + "laminas/laminas-session": "^2.8", + "laminas/laminas-uri": "^2.7", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5.5", + "psalm/plugin-phpunit": "^0.15.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "vimeo/psalm": "^4.3" + }, + "suggest": { + "laminas/laminas-db": "Laminas\\Db component, required by the (No)RecordExists validator", + "laminas/laminas-filter": "Laminas\\Filter component, required by the Digits validator", + "laminas/laminas-i18n": "Laminas\\I18n component to allow translation of validation error messages", + "laminas/laminas-i18n-resources": "Translations of validator messages", + "laminas/laminas-math": "Laminas\\Math component, required by the Csrf validator", + "laminas/laminas-servicemanager": "Laminas\\ServiceManager component to allow using the ValidatorPluginManager and validator chains", + "laminas/laminas-session": "Laminas\\Session component, ^2.8; required by the Csrf validator", + "laminas/laminas-uri": "Laminas\\Uri component, required by the Uri and Sitemap\\Loc validators", + "psr/http-message": "psr/http-message, required when validating PSR-7 UploadedFileInterface instances via the Upload and UploadFile validators" + }, + "type": "library", + "extra": { + "laminas": { + "component": "Laminas\\Validator", + "config-provider": "Laminas\\Validator\\ConfigProvider" + } + }, + "autoload": { + "psr-4": { + "Laminas\\Validator\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria", + "homepage": "https://laminas.dev", + "keywords": [ + "laminas", + "validator" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-validator/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-validator/issues", + "rss": "https://github.com/laminas/laminas-validator/releases.atom", + "source": "https://github.com/laminas/laminas-validator" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-09-08T23:16:56+00:00" + }, + { + "name": "psr/container", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/1.1.1" + }, + "time": "2021-03-05T17:36:06+00:00" + } + ], + "packages-dev": [ + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.7.1", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/fe390591e0241955f22eb9ba327d137e501c771c", + "reference": "fe390591e0241955f22eb9ba327d137e501c771c", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, + "time": "2020-12-07T18:04:37+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.0", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-11-10T18:47:58+00:00" + }, + { + "name": "laminas/laminas-coding-standard", + "version": "2.2.1", + "source": { + "type": "git", + "url": "https://github.com/laminas/laminas-coding-standard.git", + "reference": "c953ecb1d37034f4aa326046e2c24a10fe0a2845" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laminas/laminas-coding-standard/zipball/c953ecb1d37034f4aa326046e2c24a10fe0a2845", + "reference": "c953ecb1d37034f4aa326046e2c24a10fe0a2845", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.3 || ~8.0.0", + "slevomat/coding-standard": "^6.4.1", + "squizlabs/php_codesniffer": "^3.5.8", + "webimpress/coding-standard": "^1.1.6" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "LaminasCodingStandard\\": "src/LaminasCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Laminas Coding Standard", + "homepage": "https://laminas.dev", + "keywords": [ + "Coding Standard", + "laminas" + ], + "support": { + "chat": "https://laminas.dev/chat", + "docs": "https://docs.laminas.dev/laminas-coding-standard/", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-coding-standard/issues", + "rss": "https://github.com/laminas/laminas-coding-standard/releases.atom", + "source": "https://github.com/laminas/laminas-coding-standard" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-05-17T17:39:41+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v4.12.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=7.0" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.9-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, + "time": "2021-07-21T10:44:31+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" + }, + { + "name": "phar-io/version", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "bae7c545bef187884426f042434e561ab1ddb182" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, + "time": "2021-02-23T14:00:09+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.2.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "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/master" + }, + "time": "2020-09-03T19:13:55+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "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.4.0" + }, + "time": "2020-09-17T18:55:26+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.13.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.1", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + }, + "time": "2021-03-17T13:42:18+00:00" + }, + { + "name": "phpstan/phpdoc-parser", + "version": "0.4.9", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpdoc-parser.git", + "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/98a088b17966bdf6ee25c8a4b634df313d8aa531", + "reference": "98a088b17966bdf6ee25c8a4b634df313d8aa531", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "consistence/coding-standard": "^3.5", + "ergebnis/composer-normalize": "^2.0.2", + "jakub-onderka/php-parallel-lint": "^0.9.2", + "phing/phing": "^2.16.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.26", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^6.3", + "slevomat/coding-standard": "^4.7.2", + "symfony/process": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.4-dev" + } + }, + "autoload": { + "psr-4": { + "PHPStan\\PhpDocParser\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/master" + }, + "time": "2020-08-03T20:32:43+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f6293e1b30a2354e8428e004689671b83871edde" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", + "reference": "f6293e1b30a2354e8428e004689671b83871edde", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.10.2", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-03-28T07:26:59+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:57:25+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.5.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b", + "reference": "ea8c2dfb1065eb35a79b3681eee6e6fb0a6f273b", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.3", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3.4", + "sebastian/version": "^3.0.2" + }, + "require-dev": { + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.5-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.9" + }, + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-08-31T06:47:40+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:49:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:52:38+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:24:23+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-11T13:31:12+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-11-28T06:42:11+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:17:30+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "abandoned": true, + "time": "2020-09-28T06:45:17+00:00" + }, + { + "name": "sebastian/type", + "version": "2.3.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-06-15T12:49:02+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "slevomat/coding-standard", + "version": "6.4.1", + "source": { + "type": "git", + "url": "https://github.com/slevomat/coding-standard.git", + "reference": "696dcca217d0c9da2c40d02731526c1e25b65346" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/696dcca217d0c9da2c40d02731526c1e25b65346", + "reference": "696dcca217d0c9da2c40d02731526c1e25b65346", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.1 || ^8.0", + "phpstan/phpdoc-parser": "0.4.5 - 0.4.9", + "squizlabs/php_codesniffer": "^3.5.6" + }, + "require-dev": { + "phing/phing": "2.16.3", + "php-parallel-lint/php-parallel-lint": "1.2.0", + "phpstan/phpstan": "0.12.48", + "phpstan/phpstan-deprecation-rules": "0.12.5", + "phpstan/phpstan-phpunit": "0.12.16", + "phpstan/phpstan-strict-rules": "0.12.5", + "phpunit/phpunit": "7.5.20|8.5.5|9.4.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + } + }, + "autoload": { + "psr-4": { + "SlevomatCodingStandard\\": "SlevomatCodingStandard" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/6.4.1" + }, + "funding": [ + { + "url": "https://github.com/kukulich", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard", + "type": "tidelift" + } + ], + "time": "2020-10-05T12:39:37+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, + "time": "2021-04-09T00:54:41+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.23.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2021-07-28T10:34:58+00:00" + }, + { + "name": "webimpress/coding-standard", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/webimpress/coding-standard.git", + "reference": "8f4a220de33f471a8101836f7ec72b852c3f9f03" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webimpress/coding-standard/zipball/8f4a220de33f471a8101836f7ec72b852c3f9f03", + "reference": "8f4a220de33f471a8101836f7ec72b852c3f9f03", + "shasum": "" + }, + "require": { + "php": "^7.3 || ^8.0", + "squizlabs/php_codesniffer": "^3.6" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "dev-master": "1.2.x-dev", + "dev-develop": "1.3.x-dev" + }, + "autoload": { + "psr-4": { + "WebimpressCodingStandard\\": "src/WebimpressCodingStandard/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "description": "Webimpress Coding Standard", + "keywords": [ + "Coding Standard", + "PSR-2", + "phpcs", + "psr-12", + "webimpress" + ], + "support": { + "issues": "https://github.com/webimpress/coding-standard/issues", + "source": "https://github.com/webimpress/coding-standard/tree/1.2.2" + }, + "funding": [ + { + "url": "https://github.com/michalbundyra", + "type": "github" + } + ], + "time": "2021-04-12T12:51:27+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" + }, + "require-dev": { + "phpunit/phpunit": "^8.5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, + "time": "2021-03-09T10:59:23+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^7.3 || ~8.0.0 || ~8.1.0" + }, + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index 60d234c4..00000000 --- a/phpcs.xml +++ /dev/null @@ -1,9 +0,0 @@ -๏ปฟ - - - - - src - test - */_files/* - \ No newline at end of file diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 00000000..c85bc42e --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,22 @@ +๏ปฟ + + + + + + + + + + + + + src + test + */_files/* + + + + diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 6507288c..279867b2 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -8,7 +8,7 @@ namespace LaminasTest\Http\Client; -use Laminas\Config\Config; +use ArrayObject; use Laminas\Http\Client; use Laminas\Http\Client\Adapter; use Laminas\Http\Client\Adapter\Curl; @@ -78,13 +78,13 @@ public function testConfigSetAsArray() } /** - * Test that a Laminas_Config object can be used to set configuration + * Test that a Traversable object can be used to set configuration * - * @link https://getlaminas.org/issues/browse/Laminas-5577 + * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsLaminasConfig() + public function testConfigSetAsTraversable() { - $config = new Config([ + $config = new ArrayObject([ 'timeout' => 400, 'nested' => [ 'item' => 'value', diff --git a/test/Client/SocketTest.php b/test/Client/SocketTest.php index 5f595e34..87494269 100644 --- a/test/Client/SocketTest.php +++ b/test/Client/SocketTest.php @@ -8,7 +8,7 @@ namespace LaminasTest\Http\Client; -use Laminas\Config\Config; +use ArrayObject; use Laminas\Http\Client\Adapter; use Laminas\Http\Client\Adapter\Exception\InvalidArgumentException; use Laminas\Http\Client\Adapter\Exception\RuntimeException; @@ -137,13 +137,13 @@ public function testConnectingViaSslUsesCertificateFileContext() } /** - * Test that a Laminas\Config object can be used to set configuration + * Test that a Traversable object can be used to set configuration * - * @link https://getlaminas.org/issues/browse/Laminas-5577 + * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsLaminasConfig() + public function testConfigSetAsTraversable() { - $config = new Config([ + $config = new ArrayObject([ 'timeout' => 400, 'nested' => [ 'item' => 'value', diff --git a/test/Client/StaticTest.php b/test/Client/StaticTest.php index fdfe957f..f28de459 100644 --- a/test/Client/StaticTest.php +++ b/test/Client/StaticTest.php @@ -8,7 +8,7 @@ namespace LaminasTest\Http\Client; -use Laminas\Config\Config; +use ArrayObject; use Laminas\Http\Client\Adapter\Exception as ClientAdapterException; use Laminas\Http\Client\Adapter\Test; use Laminas\Http\Client as HTTPClient; @@ -230,13 +230,13 @@ public function testConfigSetAsArray() } /** - * Test that a Laminas_Config object can be used to set configuration + * Test that a Traversable object can be used to set configuration * - * @link https://getlaminas.org/issues/browse/Laminas-5577 + * @link https://framework.zend.com/issues/browse/ZEND-5577 */ - public function testConfigSetAsLaminasConfig() + public function testConfigSetAsTraversable() { - $config = new Config([ + $config = new ArrayObject([ 'timeout' => 400, 'nested' => [ 'item' => 'value', From efe45b35c727e86760164a50954a990563aa165e Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 12:00:44 -0500 Subject: [PATCH 2/9] qa: apply laminas-coding-standard 2.2 ruleset Signed-off-by: Matthew Weier O'Phinney --- src/AbstractMessage.php | 28 +-- src/Client.php | 211 ++++++++-------- src/Client/Adapter/AdapterInterface.php | 11 +- src/Client/Adapter/Curl.php | 122 +++++++--- .../Adapter/Exception/ExceptionInterface.php | 6 - .../Exception/InitializationException.php | 6 - .../Exception/InvalidArgumentException.php | 6 - .../Adapter/Exception/OutOfRangeException.php | 6 - .../Adapter/Exception/RuntimeException.php | 6 - .../Adapter/Exception/TimeoutException.php | 8 +- src/Client/Adapter/Proxy.php | 36 ++- src/Client/Adapter/Socket.php | 167 +++++++------ src/Client/Adapter/StreamInterface.php | 7 - src/Client/Adapter/Test.php | 27 +-- src/Client/Exception/ExceptionInterface.php | 6 - .../Exception/InvalidArgumentException.php | 6 - src/Client/Exception/OutOfRangeException.php | 6 - src/Client/Exception/RuntimeException.php | 6 - src/ClientStatic.php | 12 +- src/Cookies.php | 64 +++-- src/Exception/ExceptionInterface.php | 6 - src/Exception/InvalidArgumentException.php | 6 - src/Exception/OutOfRangeException.php | 6 - src/Exception/RuntimeException.php | 6 - src/Header/AbstractAccept.php | 99 +++++--- src/Header/AbstractDate.php | 61 ++--- src/Header/AbstractLocation.php | 16 +- src/Header/Accept.php | 25 +- .../FieldValuePart/AbstractFieldValuePart.php | 13 +- .../FieldValuePart/AcceptFieldValuePart.php | 6 - .../FieldValuePart/CharsetFieldValuePart.php | 6 - .../FieldValuePart/EncodingFieldValuePart.php | 6 - .../FieldValuePart/LanguageFieldValuePart.php | 9 +- src/Header/AcceptCharset.php | 13 +- src/Header/AcceptEncoding.php | 13 +- src/Header/AcceptLanguage.php | 23 +- src/Header/AcceptRanges.php | 24 +- src/Header/Age.php | 17 +- src/Header/Allow.php | 17 +- src/Header/AuthenticationInfo.php | 26 +- src/Header/Authorization.php | 26 +- src/Header/CacheControl.php | 35 ++- src/Header/Connection.php | 17 +- src/Header/ContentDisposition.php | 26 +- src/Header/ContentEncoding.php | 25 +- src/Header/ContentLanguage.php | 26 +- src/Header/ContentLength.php | 26 +- src/Header/ContentLocation.php | 6 - src/Header/ContentMD5.php | 25 +- src/Header/ContentRange.php | 26 +- src/Header/ContentSecurityPolicy.php | 30 ++- .../ContentSecurityPolicyReportOnly.php | 6 - src/Header/ContentTransferEncoding.php | 26 +- src/Header/ContentType.php | 75 +++--- src/Header/Cookie.php | 44 +++- src/Header/Date.php | 6 - src/Header/Etag.php | 25 +- src/Header/Exception/DomainException.php | 6 - src/Header/Exception/ExceptionInterface.php | 6 - .../Exception/InvalidArgumentException.php | 6 - src/Header/Exception/RuntimeException.php | 6 - src/Header/Expect.php | 25 +- src/Header/Expires.php | 14 +- src/Header/FeaturePolicy.php | 27 ++- src/Header/From.php | 25 +- src/Header/GenericHeader.php | 24 +- src/Header/GenericMultiHeader.php | 22 +- src/Header/HeaderInterface.php | 9 +- src/Header/HeaderValue.php | 19 +- src/Header/Host.php | 25 +- src/Header/IfMatch.php | 25 +- src/Header/IfModifiedSince.php | 6 - src/Header/IfNoneMatch.php | 26 +- src/Header/IfRange.php | 25 +- src/Header/IfUnmodifiedSince.php | 6 - src/Header/KeepAlive.php | 22 +- src/Header/LastModified.php | 6 - src/Header/Location.php | 6 - src/Header/MaxForwards.php | 26 +- src/Header/MultipleHeaderInterface.php | 6 - src/Header/Origin.php | 25 +- src/Header/Pragma.php | 25 +- src/Header/ProxyAuthenticate.php | 28 ++- src/Header/ProxyAuthorization.php | 26 +- src/Header/Range.php | 25 +- src/Header/Referer.php | 6 - src/Header/Refresh.php | 22 +- src/Header/RetryAfter.php | 13 +- src/Header/Server.php | 25 +- src/Header/SetCookie.php | 91 ++++--- src/Header/TE.php | 25 +- src/Header/Trailer.php | 25 +- src/Header/TransferEncoding.php | 25 +- src/Header/Upgrade.php | 25 +- src/Header/UserAgent.php | 26 +- src/Header/Vary.php | 25 +- src/Header/Via.php | 25 +- src/Header/WWWAuthenticate.php | 28 ++- src/Header/Warning.php | 25 +- src/HeaderLoader.php | 10 +- src/Headers.php | 84 ++++--- src/PhpEnvironment/RemoteAddress.php | 22 +- src/PhpEnvironment/Request.php | 60 +++-- src/PhpEnvironment/Response.php | 28 +-- src/Request.php | 115 +++++---- src/Response.php | 228 ++++++++++-------- src/Response/Stream.php | 33 ++- test/Client/CommonHttpTests.php | 145 ++++++----- test/Client/CurlTest.php | 80 +++--- test/Client/ProxyAdapterTest.php | 47 ++-- test/Client/SocketKeepaliveTest.php | 10 +- test/Client/SocketPersistentTest.php | 10 +- test/Client/SocketTest.php | 93 +++---- test/Client/StaticClientTest.php | 25 +- test/Client/StaticTest.php | 53 ++-- test/Client/TestAdapterTest.php | 10 +- test/Client/TestAsset/MockAdapter.php | 7 +- test/Client/TestAsset/MockClient.php | 7 +- test/Client/UseCaseTest.php | 21 +- test/Client/_files/Laminas7683-chunked.php | 6 - .../Laminas9404-doubleContentLength.php | 6 - test/Client/_files/fwrite.php | 6 - test/Client/_files/testConnectTimeout.php | 6 - test/Client/_files/testCookies.php | 6 - test/Client/_files/testCurlGzipData.php | 6 - test/Client/_files/testDeleteData.php | 6 - .../_files/testExceptionOnReadTimeout.php | 7 - test/Client/_files/testGetData.php | 6 - test/Client/_files/testHeadMethod.php | 9 +- test/Client/_files/testHttpAuth.php | 16 +- ...estMultibyteChunkedResponseLaminas6218.php | 6 - test/Client/_files/testOptionsData.php | 6 - test/Client/_files/testPatchData.php | 6 - test/Client/_files/testPostData.php | 6 - test/Client/_files/testRawGetData.php | 6 - test/Client/_files/testRawPostData.php | 6 - test/Client/_files/testRedirections.php | 10 +- .../_files/testRelativeRedirections.php | 6 - test/Client/_files/testResetParameters.php | 6 - test/Client/_files/testStreamRequest.php | 6 - test/Client/_files/testTimeout.php | 6 - test/Client/_files/testUploads.php | 6 - test/ClientTest.php | 78 +++--- test/CookiesTest.php | 22 +- test/Header/AcceptCharsetTest.php | 13 +- test/Header/AcceptEncodingTest.php | 13 +- test/Header/AcceptLanguageTest.php | 15 +- test/Header/AcceptRangesTest.php | 8 +- test/Header/AcceptTest.php | 39 ++- test/Header/AgeTest.php | 10 +- test/Header/AllowTest.php | 20 +- test/Header/AuthenticationInfoTest.php | 8 +- test/Header/AuthorizationTest.php | 8 +- test/Header/CacheControlTest.php | 11 +- test/Header/ConnectionTest.php | 8 +- test/Header/ContentDispositionTest.php | 8 +- test/Header/ContentEncodingTest.php | 8 +- test/Header/ContentLanguageTest.php | 8 +- test/Header/ContentLengthTest.php | 8 +- test/Header/ContentLocationTest.php | 14 +- test/Header/ContentMD5Test.php | 10 +- test/Header/ContentRangeTest.php | 8 +- .../ContentSecurityPolicyReportOnlyTest.php | 6 - test/Header/ContentSecurityPolicyTest.php | 22 +- test/Header/ContentTransferEncodingTest.php | 8 +- test/Header/ContentTypeTest.php | 71 +++--- test/Header/CookieTest.php | 15 +- test/Header/DateTest.php | 14 +- test/Header/EtagTest.php | 8 +- test/Header/ExpectTest.php | 8 +- test/Header/ExpiresTest.php | 8 +- test/Header/FeaturePolicyTest.php | 12 +- test/Header/FromTest.php | 8 +- test/Header/GenericHeaderTest.php | 14 +- test/Header/HeaderValueTest.php | 22 +- test/Header/HostTest.php | 8 +- test/Header/IfMatchTest.php | 8 +- test/Header/IfModifiedSinceTest.php | 8 +- test/Header/IfNoneMatchTest.php | 8 +- test/Header/IfRangeTest.php | 8 +- test/Header/IfUnmodifiedSinceTest.php | 8 +- test/Header/KeepAliveTest.php | 8 +- test/Header/LastModifiedTest.php | 8 +- test/Header/LocationTest.php | 22 +- test/Header/MaxForwardsTest.php | 8 +- test/Header/OriginTest.php | 7 +- test/Header/PragmaTest.php | 8 +- test/Header/ProxyAuthenticateTest.php | 8 +- test/Header/ProxyAuthorizationTest.php | 8 +- test/Header/RangeTest.php | 8 +- test/Header/RefererTest.php | 14 +- test/Header/RefreshTest.php | 8 +- test/Header/RetryAfterTest.php | 7 +- test/Header/ServerTest.php | 8 +- test/Header/SetCookieTest.php | 68 +++--- test/Header/TETest.php | 10 +- test/Header/TrailerTest.php | 8 +- test/Header/TransferEncodingTest.php | 8 +- test/Header/UpgradeTest.php | 8 +- test/Header/UserAgentTest.php | 8 +- test/Header/VaryTest.php | 8 +- test/Header/ViaTest.php | 8 +- test/Header/WWWAuthenticateTest.php | 14 +- test/Header/WarningTest.php | 8 +- test/HeaderTest.php | 30 ++- test/HeadersTest.php | 17 +- test/PhpEnvironment/RemoteAddressTest.php | 14 +- test/PhpEnvironment/RequestTest.php | 177 +++++++------- test/PhpEnvironment/ResponseTest.php | 12 +- test/RequestTest.php | 33 ++- test/Response/ResponseStreamTest.php | 31 ++- test/ResponseTest.php | 68 ++++-- test/TestAsset/ExtendedClient.php | 8 +- 213 files changed, 2399 insertions(+), 2564 deletions(-) diff --git a/src/AbstractMessage.php b/src/AbstractMessage.php index fc961eb2..eb20bc9d 100644 --- a/src/AbstractMessage.php +++ b/src/AbstractMessage.php @@ -1,15 +1,12 @@ headers === null || is_string($this->headers)) { // this is only here for fromString lazy loading - $this->headers = (is_string($this->headers)) ? Headers::fromString($this->headers) : new Headers(); + $this->headers = is_string($this->headers) ? Headers::fromString($this->headers) : new Headers(); } return $this->headers; diff --git a/src/Client.php b/src/Client.php index 482f923b..2e675aaf 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1,16 +1,11 @@ adapter = $adapter; - $config = $this->config; + $config = $this->config; unset($config['adapter']); $this->adapter->setOptions($config); return $this; @@ -229,7 +250,6 @@ public function getAdapter() /** * Set request * - * @param Request $request * @return $this */ public function setRequest(Request $request) @@ -255,7 +275,6 @@ public function getRequest() /** * Set response * - * @param Response $response * @return $this */ public function setResponse(Response $response) @@ -328,8 +347,8 @@ public function setUri($uri) $this->clearAuth(); } - $uri = $this->getUri(); - $user = $uri->getUser(); + $uri = $this->getUri(); + $user = $uri->getUser(); $password = $uri->getPassword(); // Set auth if username and password has been specified in the uri @@ -365,7 +384,8 @@ public function setMethod($method) { $method = $this->getRequest()->setMethod($method)->getMethod(); - if (empty($this->encType) + if ( + empty($this->encType) && in_array( $method, [ @@ -493,10 +513,9 @@ public function setParameterGet(array $query) * Reset all the HTTP parameters (request, response, etc) * * @param bool $clearCookies Also clear all valid cookies? (defaults to false) - * @param bool $clearAuth Also clear http authentication? (defaults to true) * @return $this */ - public function resetParameters($clearCookies = false /*, $clearAuth = true */) + public function resetParameters($clearCookies = false) { $clearAuth = true; if (func_num_args() > 1) { @@ -538,12 +557,12 @@ public function getCookies() /** * Get the cookie Id (name+domain+path) * - * @param Header\SetCookie|Header\Cookie $cookie + * @param SetCookie|Header\Cookie $cookie * @return string|bool */ protected function getCookieId($cookie) { - if (($cookie instanceof Header\SetCookie) || ($cookie instanceof Header\Cookie)) { + if ($cookie instanceof Header\SetCookie || $cookie instanceof Header\Cookie) { return $cookie->getName() . $cookie->getDomain() . $cookie->getPath(); } return false; @@ -552,7 +571,7 @@ protected function getCookieId($cookie) /** * Add a cookie * - * @param array|ArrayIterator|Header\SetCookie|string $cookie + * @param array|ArrayIterator|SetCookie|string $cookie * @param string $value * @param string $expire * @param string $path @@ -584,7 +603,7 @@ public function addCookie( } } } elseif (is_string($cookie) && $value !== null) { - $setCookie = new Header\SetCookie( + $setCookie = new SetCookie( $cookie, $value, $expire, @@ -706,6 +725,7 @@ public function setStream($streamfile = true) /** * Get status of streaming for received data + * * @return bool|string */ public function getStream() @@ -730,8 +750,8 @@ protected function openTempStream() if (! is_string($this->streamName)) { // If name is not given, create temp name $this->streamName = tempnam( - isset($this->config['streamtmpdir']) ? $this->config['streamtmpdir'] : sys_get_temp_dir(), - Client::class + $this->config['streamtmpdir'] ?? sys_get_temp_dir(), + self::class ); } @@ -792,6 +812,7 @@ public function clearAuth() * Calculate the response value according to the HTTP authentication type * * @see http://www.faqs.org/rfcs/rfc2617.html + * * @param string $user * @param string $password * @param string $type @@ -832,9 +853,9 @@ protected function calcAuthDigest($user, $password, $type = self::AUTH_BASIC, $d } } $ha1 = md5($user . ':' . $digest['realm'] . ':' . $password); - if (empty($digest['qop']) || strtolower($digest['qop']) == 'auth') { + if (empty($digest['qop']) || strtolower($digest['qop']) === 'auth') { $ha2 = md5($this->getMethod() . ':' . $this->getUri()->getPath()); - } elseif (strtolower($digest['qop']) == 'auth-int') { + } elseif (strtolower($digest['qop']) === 'auth-int') { if (empty($entityBody)) { throw new Exception\InvalidArgumentException( 'I cannot use the auth-int digest authentication without the entity body' @@ -856,11 +877,9 @@ protected function calcAuthDigest($user, $password, $type = self::AUTH_BASIC, $d /** * Dispatch * - * @param RequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function dispatch(RequestInterface $request, ResponseInterface $response = null) + public function dispatch(RequestInterface $request, ?ResponseInterface $response = null) { return $this->send($request); } @@ -868,12 +887,11 @@ public function dispatch(RequestInterface $request, ResponseInterface $response /** * Send HTTP request * - * @param Request|null $request * @return Response * @throws Exception\RuntimeException - * @throws Client\Exception\RuntimeException + * @throws RuntimeException */ - public function send(Request $request = null) + public function send(?Request $request = null) { if ($request !== null) { $this->setRequest($request); @@ -895,7 +913,7 @@ public function send(Request $request = null) $queryArray = $query->toArray(); if (! empty($queryArray)) { - $newUri = $uri->toString(); + $newUri = $uri->toString(); $queryString = http_build_query($queryArray, null, $this->getArgSeparator()); if ($this->config['rfc3986strict']) { @@ -928,7 +946,7 @@ public function send(Request $request = null) // headers $headers = $this->prepareHeaders($body, $uri); - $secure = $uri->getScheme() == 'https'; + $secure = $uri->getScheme() === 'https'; // cookies $cookie = $this->prepareCookies($uri->getHost(), $uri->getPath(), $secure); @@ -937,15 +955,15 @@ public function send(Request $request = null) } // check that adapter supports streaming before using it - if (is_resource($body) && ! ($adapter instanceof Client\Adapter\StreamInterface)) { - throw new Client\Exception\RuntimeException('Adapter does not support streaming'); + if (is_resource($body) && ! $adapter instanceof Client\Adapter\StreamInterface) { + throw new RuntimeException('Adapter does not support streaming'); } $this->streamHandle = null; // calling protected method to allow extending classes // to wrap the interaction with the adapter - $response = $this->doRequest($uri, $method, $secure, $headers, $body); - $stream = $this->streamHandle; + $response = $this->doRequest($uri, $method, $secure, $headers, $body); + $stream = $this->streamHandle; $this->streamHandle = null; if (! $response) { @@ -998,24 +1016,26 @@ public function send(Request $request = null) // Check whether we send the exact same request again, or drop the parameters // and send a GET request - if ($response->getStatusCode() == 303 + if ( + $response->getStatusCode() === 303 || ((! $this->config['strictredirects']) - && ($response->getStatusCode() == 302 || $response->getStatusCode() == 301)) + && ($response->getStatusCode() === 302 || $response->getStatusCode() === 301)) ) { $this->resetParameters(false, false); $this->setMethod(Request::METHOD_GET); } // If we got a well formed absolute URI - if (($scheme = substr($location, 0, 6)) - && ($scheme == 'http:/' || $scheme == 'https:') + if ( + ($scheme = substr($location, 0, 6)) + && ($scheme === 'http:/' || $scheme === 'https:') ) { // setURI() clears parameters if host changed, see #4215 $this->setUri($location); } else { // Split into path and query and set the query if (strpos($location, '?') !== false) { - list($location, $query) = explode('?', $location, 2); + [$location, $query] = explode('?', $location, 2); } else { $query = ''; } @@ -1097,8 +1117,8 @@ public function setFileUpload($filename, $formname, $data = null, $ctype = null) $this->getRequest()->getFiles()->set($filename, [ 'formname' => $formname, 'filename' => basename($filename), - 'ctype' => $ctype, - 'data' => $data, + 'ctype' => $ctype, + 'data' => $data, ]); return $this; @@ -1165,11 +1185,12 @@ protected function prepareHeaders($body, $uri) $headers = []; // Set the host header - if ($this->config['httpversion'] == Request::VERSION_11) { + if ($this->config['httpversion'] === Request::VERSION_11) { $host = $uri->getHost(); // If the port is not default, add it - if (! (($uri->getScheme() == 'http' && $uri->getPort() == 80) - || ($uri->getScheme() == 'https' && $uri->getPort() == 443)) + if ( + ! (($uri->getScheme() === 'http' && $uri->getPort() === 80) + || ($uri->getScheme() === 'https' && $uri->getPort() === 443)) ) { $host .= ':' . $uri->getPort(); } @@ -1229,7 +1250,7 @@ protected function prepareHeaders($body, $uri) if (! empty($body)) { if (is_resource($body)) { - $fstat = fstat($body); + $fstat = fstat($body); $headers['Content-Length'] = $fstat['size']; } else { $headers['Content-Length'] = strlen($body); @@ -1249,7 +1270,7 @@ protected function prepareHeaders($body, $uri) * Prepare the request body (for PATCH, POST and PUT requests) * * @return string - * @throws \Laminas\Http\Client\Exception\RuntimeException + * @throws RuntimeException */ protected function prepareBody() { @@ -1263,7 +1284,7 @@ protected function prepareBody() return $rawBody; } - $body = ''; + $body = ''; $hasFiles = false; if (! $this->getRequest()->getHeaders()->has('Content-Type')) { @@ -1304,7 +1325,7 @@ protected function prepareBody() // Encode body as application/x-www-form-urlencoded $body = http_build_query($this->getRequest()->getPost()->toArray(), null, '&'); } else { - throw new Client\Exception\RuntimeException(sprintf( + throw new RuntimeException(sprintf( 'Cannot handle content type \'%s\' automatically', $this->encType )); @@ -1314,7 +1335,6 @@ protected function prepareBody() return $body; } - /** * Attempt to detect the MIME type of a file using available extensions * @@ -1394,7 +1414,6 @@ public function encodeFormData($boundary, $name, $value, $filename = null, $head * key to indicate an array. * * @since 1.9 - * * @param array $parray * @param string $prefix * @return array @@ -1433,7 +1452,6 @@ protected function flattenParametersArray($parray, $prefix = null) * Separating this from send method allows subclasses to wrap * the interaction with the adapter * - * @param Http $uri * @param string $method * @param bool $secure * @param array $headers @@ -1471,6 +1489,7 @@ protected function doRequest(Http $uri, $method, $secure = false, $headers = [], * specified user, password and authentication method. * * @see http://www.faqs.org/rfcs/rfc2617.html + * * @param string $user * @param string $password * @param string $type diff --git a/src/Client/Adapter/AdapterInterface.php b/src/Client/Adapter/AdapterInterface.php index 31ffeed5..e1d4c388 100644 --- a/src/Client/Adapter/AdapterInterface.php +++ b/src/Client/Adapter/AdapterInterface.php @@ -1,13 +1,9 @@ curl = curl_init(); - if ($port != 80) { + if ($port !== 80) { curl_setopt($this->curl, CURLOPT_PORT, intval($port)); } @@ -273,7 +333,7 @@ public function connect($host, $port = 80, $secure = false) * Send request to the remote server * * @param string $method - * @param \Laminas\Uri\Uri $uri + * @param Uri $uri * @param float $httpVersion * @param array $headers * @param string $body @@ -281,8 +341,8 @@ public function connect($host, $port = 80, $secure = false) * @throws AdapterException\RuntimeException If connection fails, connected * to wrong host, no PUT file defined, unsupported method, or unsupported * cURL option. - * @throws AdapterException\InvalidArgumentException if $method is currently not supported - * @throws AdapterException\TimeoutException if connection timed out + * @throws AdapterException\InvalidArgumentException If $method is currently not supported. + * @throws AdapterException\TimeoutException If connection timed out. */ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = '') { @@ -291,7 +351,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = throw new AdapterException\RuntimeException('Trying to write but we are not connected'); } - if ($this->connectedTo[0] != $uri->getHost() || $this->connectedTo[1] != $uri->getPort()) { + if ($this->connectedTo[0] !== $uri->getHost() || $this->connectedTo[1] !== $uri->getPort()) { throw new AdapterException\RuntimeException('Trying to write but we are connected to the wrong host'); } @@ -318,7 +378,8 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = if (isset($this->config['curloptions'][CURLOPT_INFILE])) { // Now we will probably already have Content-Length set, so that we have to delete it // from $headers at this point: - if (! isset($headers['Content-Length']) + if ( + ! isset($headers['Content-Length']) && ! isset($this->config['curloptions'][CURLOPT_INFILESIZE]) ) { throw new AdapterException\RuntimeException( @@ -339,33 +400,33 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = $curlMethod = CURLOPT_UPLOAD; } else { $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'PUT'; + $curlValue = 'PUT'; } break; case 'PATCH': $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'PATCH'; + $curlValue = 'PATCH'; break; case 'DELETE': $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'DELETE'; + $curlValue = 'DELETE'; break; case 'OPTIONS': $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'OPTIONS'; + $curlValue = 'OPTIONS'; break; case 'TRACE': $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'TRACE'; + $curlValue = 'TRACE'; break; case 'HEAD': $curlMethod = CURLOPT_CUSTOMREQUEST; - $curlValue = 'HEAD'; + $curlValue = 'HEAD'; break; default: @@ -376,12 +437,12 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = )); } - if (is_resource($body) && $curlMethod != CURLOPT_UPLOAD) { + if (is_resource($body) && $curlMethod !== CURLOPT_UPLOAD) { throw new AdapterException\RuntimeException('Streaming requests are allowed only with PUT'); } // get http version to use - $curlHttp = $httpVersion == 1.1 ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0; + $curlHttp = $httpVersion === 1.1 ? CURL_HTTP_VERSION_1_1 : CURL_HTTP_VERSION_1_0; // mark as HTTP request and set HTTP method curl_setopt($this->curl, CURLOPT_HTTP_VERSION, $curlHttp); @@ -408,7 +469,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = } // Treating basic auth headers in a special way - if (array_key_exists('Authorization', $headers) && 'Basic' == substr($headers['Authorization'], 0, 5)) { + if (array_key_exists('Authorization', $headers) && 'Basic' === substr($headers['Authorization'], 0, 5)) { curl_setopt($this->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($this->curl, CURLOPT_USERPWD, base64_decode(substr($headers['Authorization'], 6))); unset($headers['Authorization']); @@ -427,9 +488,10 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = /** * Make sure POSTFIELDS is set after $curlMethod is set: + * * @link http://de2.php.net/manual/en/function.curl-setopt.php#81161 */ - if ($curlMethod == CURLOPT_UPLOAD) { + if ($curlMethod === CURLOPT_UPLOAD) { // this covers a PUT by file-handle: // Make the setting of this options explicit (rather than setting it through the loop following a bit lower) // to group common functionality together. @@ -445,7 +507,7 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = if (isset($this->config['curloptions'])) { foreach ((array) $this->config['curloptions'] as $k => $v) { if (! in_array($k, $this->invalidOverwritableCurlOptions)) { - if (curl_setopt($this->curl, $k, $v) == false) { + if (curl_setopt($this->curl, $k, $v) === false) { throw new AdapterException\RuntimeException(sprintf( 'Unknown or erroreous cURL option "%s" set', $k @@ -483,15 +545,16 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = // separating header from body because it is dangerous to accidentially replace strings in the body $responseHeaderSize = curl_getinfo($this->curl, CURLINFO_HEADER_SIZE); - $responseHeaders = substr($this->response, 0, $responseHeaderSize); + $responseHeaders = substr($this->response, 0, $responseHeaderSize); // cURL automatically decodes chunked-messages, this means we have to // disallow the Laminas\Http\Response to do it again. $responseHeaders = preg_replace("/Transfer-Encoding:\s*chunked\\r\\n/i", '', $responseHeaders); // cURL can automatically handle content encoding; prevent double-decoding from occurring - if (isset($this->config['curloptions'][CURLOPT_ENCODING]) - && '' == $this->config['curloptions'][CURLOPT_ENCODING] + if ( + isset($this->config['curloptions'][CURLOPT_ENCODING]) + && '' === $this->config['curloptions'][CURLOPT_ENCODING] ) { $responseHeaders = preg_replace("/Content-Encoding:\s*gzip\\r\\n/i", '', $responseHeaders); } @@ -532,14 +595,13 @@ public function read() /** * Close the connection to the server - * */ public function close() { if (is_resource($this->curl)) { curl_close($this->curl); } - $this->curl = null; + $this->curl = null; $this->connectedTo = [null, null]; } diff --git a/src/Client/Adapter/Exception/ExceptionInterface.php b/src/Client/Adapter/Exception/ExceptionInterface.php index 790e1db5..8965be90 100644 --- a/src/Client/Adapter/Exception/ExceptionInterface.php +++ b/src/Client/Adapter/Exception/ExceptionInterface.php @@ -1,11 +1,5 @@ config['sslusecontext'] = true; - $this->setSslCryptoMethod = false; + $this->setSslCryptoMethod = false; } // Connect (a non-secure connection) to the proxy server @@ -122,7 +132,7 @@ public function connect($host, $port = 80, $secure = false) * Send request to the proxy server * * @param string $method - * @param \Laminas\Uri\Uri $uri + * @param Uri $uri * @param string $httpVer * @param array $headers * @param string $body @@ -144,7 +154,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' $host = $this->config['proxy_host']; $port = $this->config['proxy_port']; - $isSecure = strtolower($uri->getScheme()) === 'https'; + $isSecure = strtolower($uri->getScheme()) === 'https'; $connectedHost = ($isSecure ? $this->config['ssltransport'] : 'tcp') . '://' . $host; if ($this->connectedTo[1] !== $port || $this->connectedTo[0] !== $connectedHost) { @@ -175,7 +185,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' $headers['Authorization'] = 'Basic ' . base64_encode($uri->getUserInfo()); } - $path = $uri->getPath(); + $path = $uri->getPath(); $query = $uri->getQuery(); $path .= $query ? '?' . $query : ''; @@ -210,7 +220,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' } if (is_resource($body)) { - if (stream_copy_to_stream($body, $this->socket) == 0) { + if (stream_copy_to_stream($body, $this->socket) === 0) { throw new AdapterException\RuntimeException('Error writing request to server'); } } @@ -255,7 +265,7 @@ protected function connectHandshake($host, $port = 443, $httpVer = '1.1', array } // Read response headers only - $response = ''; + $response = ''; $gotStatus = false; ErrorHandler::start(); while ($line = fgets($this->socket)) { @@ -270,7 +280,7 @@ protected function connectHandshake($host, $port = 443, $httpVer = '1.1', array ErrorHandler::stop(); // Check that the response from the proxy is 200 - if (Response::fromString($response)->getStatusCode() != 200) { + if (Response::fromString($response)->getStatusCode() !== 200) { throw new AdapterException\RuntimeException(sprintf( 'Unable to connect to HTTPS proxy. Server response: %s', $response diff --git a/src/Client/Adapter/Socket.php b/src/Client/Adapter/Socket.php index b4c9c553..a5542bb6 100644 --- a/src/Client/Adapter/Socket.php +++ b/src/Client/Adapter/Socket.php @@ -1,11 +1,5 @@ false, - 'ssltransport' => 'tls', - 'sslcert' => null, - 'sslpassphrase' => null, - 'sslverifypeer' => true, - 'sslcafile' => null, - 'sslcapath' => null, - 'sslallowselfsigned' => false, - 'sslusecontext' => false, - 'sslverifypeername' => true, + 'persistent' => false, + 'ssltransport' => 'tls', + 'sslcert' => null, + 'sslpassphrase' => null, + 'sslverifypeer' => true, + 'sslcafile' => null, + 'sslcapath' => null, + 'sslallowselfsigned' => false, + 'sslusecontext' => false, + 'sslverifypeername' => true, ]; /** @@ -102,14 +129,11 @@ class Socket implements HttpAdapter, StreamInterface */ protected $context; - /** - * @var bool - */ + /** @var bool */ protected $setSslCryptoMethod = true; /** * Adapter constructor, currently empty. Config is set using setOptions() - * */ public function __construct() { @@ -156,14 +180,13 @@ public function getConfig() * will be created using the passed options. * * @since Laminas 1.9 - * * @param mixed $context Stream context or array of context options * @throws Exception\InvalidArgumentException * @return $this */ public function setStreamContext($context) { - if (is_resource($context) && get_resource_type($context) == 'stream-context') { + if (is_resource($context) && get_resource_type($context) === 'stream-context') { $this->context = $context; } elseif (is_array($context)) { $this->context = stream_context_create($context); @@ -205,11 +228,11 @@ public function getStreamContext() public function connect($host, $port = 80, $secure = false) { // If we are connected to the wrong host, disconnect first - $connectedHost = (strpos($this->connectedTo[0], '://')) - ? substr($this->connectedTo[0], (strpos($this->connectedTo[0], '://') + 3), strlen($this->connectedTo[0])) + $connectedHost = strpos($this->connectedTo[0], '://') + ? substr($this->connectedTo[0], strpos($this->connectedTo[0], '://') + 3, strlen($this->connectedTo[0])) : $this->connectedTo[0]; - if ($connectedHost != $host || $this->connectedTo[1] != $port) { + if ($connectedHost !== $host || $this->connectedTo[1] !== $port) { if (is_resource($this->socket)) { $this->close(); } @@ -239,12 +262,14 @@ public function connect($host, $port = 80, $secure = false) } if ($this->config['sslallowselfsigned'] !== null) { - if (! stream_context_set_option( - $context, - 'ssl', - 'allow_self_signed', - $this->config['sslallowselfsigned'] - )) { + if ( + ! stream_context_set_option( + $context, + 'ssl', + 'allow_self_signed', + $this->config['sslallowselfsigned'] + ) + ) { throw new AdapterException\RuntimeException('Unable to set sslallowselfsigned option'); } } @@ -262,12 +287,14 @@ public function connect($host, $port = 80, $secure = false) } if ($this->config['sslverifypeername'] !== null) { - if (! stream_context_set_option( - $context, - 'ssl', - 'verify_peer_name', - $this->config['sslverifypeername'] - )) { + if ( + ! stream_context_set_option( + $context, + 'ssl', + 'verify_peer_name', + $this->config['sslverifypeername'] + ) + ) { throw new AdapterException\RuntimeException('Unable to set sslverifypeername option'); } } @@ -300,7 +327,7 @@ public function connect($host, $port = 80, $secure = false) $flags, $context ); - $error = ErrorHandler::stop(); + $error = ErrorHandler::stop(); if (! $this->socket) { $this->close(); @@ -309,7 +336,7 @@ public function connect($host, $port = 80, $secure = false) 'Unable to connect to %s:%d%s', $host, $port, - ($error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '') + $error ? ' . Error #' . $error->getCode() . ': ' . $error->getMessage() : '' ), 0, $error @@ -357,10 +384,11 @@ protected function enableCryptoTransport($sslTransport, $socket, $host) // We can do this because STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT is available // in enum but not registered as php constant. // @see https://github.com/php/php-src/blob/php-5.6.7/main/streams/php_stream_transport.h#L179 - if (version_compare(PHP_VERSION, '7.2.0', '<') + if ( + version_compare(PHP_VERSION, '7.2.0', '<') && $sslCryptoMethod === STREAM_CRYPTO_METHOD_TLS_CLIENT ) { - $sslCryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT; + $sslCryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT; $sslCryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; $sslCryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; } @@ -371,7 +399,7 @@ protected function enableCryptoTransport($sslTransport, $socket, $host) // Error handling is kind of difficult when it comes to SSL $errorString = ''; if (extension_loaded('openssl')) { - while (($sslError = openssl_error_string()) != false) { + while (($sslError = openssl_error_string()) !== false) { $errorString .= sprintf('; SSL error: %s', $sslError); } } @@ -410,7 +438,7 @@ protected function enableCryptoTransport($sslTransport, $socket, $host) * Send request to the remote server * * @param string $method - * @param \Laminas\Uri\Uri $uri + * @param Uri $uri * @param string $httpVer * @param array $headers * @param string $body @@ -425,8 +453,8 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' } $host = $uri->getHost(); - $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host; - if ($this->connectedTo[0] != $host || $this->connectedTo[1] != $uri->getPort()) { + $host = (strtolower($uri->getScheme()) === 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host; + if ($this->connectedTo[0] !== $host || $this->connectedTo[1] !== $uri->getPort()) { throw new AdapterException\RuntimeException('Trying to write but we are connected to the wrong host'); } @@ -434,9 +462,9 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' $this->method = $method; // Build request headers - $path = $uri->getPath(); - $query = $uri->getQuery(); - $path .= $query ? '?' . $query : ''; + $path = $uri->getPath(); + $query = $uri->getQuery(); + $path .= $query ? '?' . $query : ''; $request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n"; foreach ($headers as $k => $v) { if (is_string($k)) { @@ -461,7 +489,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' } if (is_resource($body)) { - if (stream_copy_to_stream($body, $this->socket) == 0) { + if (stream_copy_to_stream($body, $this->socket) === 0) { throw new AdapterException\RuntimeException('Error writing request to server'); } } @@ -478,7 +506,7 @@ public function write($method, $uri, $httpVer = '1.1', $headers = [], $body = '' public function read() { // First, read headers only - $response = ''; + $response = ''; $gotStatus = false; while (($line = fgets($this->socket)) !== false) { @@ -498,7 +526,7 @@ public function read() $statusCode = $responseObj->getStatusCode(); // Handle 100 and 101 responses internally by restarting the read again - if ($statusCode == 100 || $statusCode == 101) { + if ($statusCode === 100 || $statusCode === 101) { return $this->read(); } @@ -509,13 +537,14 @@ public function read() * Responses to HEAD requests and 204 or 304 responses are not expected * to have a body - stop reading here */ - if ($statusCode == 304 - || $statusCode == 204 - || $this->method == Request::METHOD_HEAD + if ( + $statusCode === 304 + || $statusCode === 204 + || $this->method === Request::METHOD_HEAD ) { // Close the connection if requested to do so by the server $connection = $headers->get('connection'); - if ($connection && $connection->getFieldValue() == 'close') { + if ($connection && $connection->getFieldValue() === 'close') { $this->close(); } return $response; @@ -523,11 +552,11 @@ public function read() // If we got a 'transfer-encoding: chunked' header $transferEncoding = $headers->get('transfer-encoding'); - $contentLength = $headers->get('content-length'); + $contentLength = $headers->get('content-length'); if ($transferEncoding !== false) { - if (strtolower($transferEncoding->getFieldValue()) == 'chunked') { + if (strtolower($transferEncoding->getFieldValue()) === 'chunked') { do { - $line = fgets($this->socket); + $line = fgets($this->socket); $this->_checkSocketReadTimeout(); $chunk = $line; @@ -555,7 +584,7 @@ public function read() } if ($this->outStream) { - if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) == 0) { + if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) === 0) { $this->_checkSocketReadTimeout(); break; } @@ -602,11 +631,13 @@ public function read() $currentPos = ftell($this->socket); - for ($readTo = $currentPos + $contentLength; + for ( + $readTo = $currentPos + $contentLength; $readTo > $currentPos; - $currentPos = ftell($this->socket)) { + $currentPos = ftell($this->socket) + ) { if ($this->outStream) { - if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) == 0) { + if (stream_copy_to_stream($this->socket, $this->outStream, $readTo - $currentPos) === 0) { $this->_checkSocketReadTimeout(); break; } @@ -630,7 +661,7 @@ public function read() } else { do { if ($this->outStream) { - if (stream_copy_to_stream($this->socket, $this->outStream) == 0) { + if (stream_copy_to_stream($this->socket, $this->outStream) === 0) { $this->_checkSocketReadTimeout(); break; } @@ -650,7 +681,7 @@ public function read() // Close the connection if requested to do so by the server $connection = $headers->get('connection'); - if ($connection && $connection->getFieldValue() == 'close') { + if ($connection && $connection->getFieldValue() === 'close') { $this->close(); } @@ -659,7 +690,6 @@ public function read() /** * Close the connection to the server - * */ public function close() { @@ -668,7 +698,7 @@ public function close() fclose($this->socket); ErrorHandler::stop(); } - $this->socket = null; + $this->socket = null; $this->connectedTo = [null, null]; } @@ -683,7 +713,7 @@ protected function _checkSocketReadTimeout() { // @codingStandardsIgnoreEnd if ($this->socket) { - $info = stream_get_meta_data($this->socket); + $info = stream_get_meta_data($this->socket); $timedout = $info['timed_out']; if ($timedout) { $this->close(); @@ -699,7 +729,7 @@ protected function _checkSocketReadTimeout() * Set output stream for the response * * @param resource $stream - * @return \Laminas\Http\Client\Adapter\Socket + * @return Socket */ public function setOutputStream($stream) { @@ -711,7 +741,6 @@ public function setOutputStream($stream) * Destructor: make sure the socket is disconnected * * If we are in persistent TCP mode, will not close the connection - * */ public function __destruct() { diff --git a/src/Client/Adapter/StreamInterface.php b/src/Client/Adapter/StreamInterface.php index 5ad1d246..8149e574 100644 --- a/src/Client/Adapter/StreamInterface.php +++ b/src/Client/Adapter/StreamInterface.php @@ -1,11 +1,5 @@ getQuery(); - $path .= $query ? '?' . $query : ''; + $query = $uri->getQuery(); + $path .= $query ? '?' . $query : ''; $request = $method . ' ' . $path . ' HTTP/' . $httpVer . "\r\n"; foreach ($headers as $k => $v) { if (is_string($k)) { @@ -161,7 +161,6 @@ public function read() /** * Close the connection (dummy) - * */ public function close() { @@ -170,7 +169,7 @@ public function close() /** * Set the HTTP response(s) to be returned by this adapter * - * @param \Laminas\Http\Response|array|string $response + * @param Response|array|string $response */ public function setResponse($response) { @@ -178,7 +177,7 @@ public function setResponse($response) $response = $response->toString(); } - $this->responses = (array) $response; + $this->responses = (array) $response; $this->responseIndex = 0; } diff --git a/src/Client/Exception/ExceptionInterface.php b/src/Client/Exception/ExceptionInterface.php index 111e93f4..e6daf23a 100644 --- a/src/Client/Exception/ExceptionInterface.php +++ b/src/Client/Exception/ExceptionInterface.php @@ -1,11 +1,5 @@ cookies[$domain][$path] = []; } $this->cookies[$domain][$path][$cookie->getName()] = $cookie; - $this->rawCookies[] = $cookie; + $this->rawCookies[] = $cookie; } else { throw new Exception\InvalidArgumentException('Supplient argument is not a valid cookie string or object'); } @@ -116,7 +114,6 @@ public function addCookie($cookie, $refUri = null) /** * Parse an HTTP response, adding all the cookies set in that response * - * @param Response $response * @param Uri\Uri|string $refUri Requested URI */ public function addCookiesFromResponse(Response $response, $refUri) @@ -140,8 +137,7 @@ public function addCookiesFromResponse(Response $response, $refUri) */ public function getAllCookies($retAs = self::COOKIE_OBJECT) { - $cookies = $this->_flattenCookiesArray($this->cookies, $retAs); - return $cookies; + return $this->_flattenCookiesArray($this->cookies, $retAs); } /** @@ -153,7 +149,7 @@ public function getAllCookies($retAs = self::COOKIE_OBJECT) * @param bool $matchSessionCookies Whether to send session cookies * @param int $retAs Whether to return cookies as objects of \Laminas\Http\Header\Cookie or as strings * @param int $now Override the current time when checking for expiry time - * @throws Exception\InvalidArgumentException if invalid URI specified + * @throws Exception\InvalidArgumentException If invalid URI specified. * @return array|string */ public function getMatchingCookies( @@ -197,7 +193,7 @@ public function getMatchingCookies( * @param Uri\Uri|string $uri The uri (domain and path) to match * @param string $cookieName The cookie's name * @param int $retAs Whether to return cookies as objects of \Laminas\Http\Header\SetCookie or as strings - * @throws Exception\InvalidArgumentException if invalid URI specified or invalid $retAs value + * @throws Exception\InvalidArgumentException If invalid URI specified or invalid $retAs value. * @return SetCookie|string */ public function getCookie($uri, $cookieName, $retAs = self::COOKIE_OBJECT) @@ -214,9 +210,9 @@ public function getCookie($uri, $cookieName, $retAs = self::COOKIE_OBJECT) } // Get correct cookie path - $path = $uri->getPath(); + $path = $uri->getPath(); $lastSlashPos = strrpos($path, '/') ?: 0; - $path = substr($path, 0, $lastSlashPos); + $path = substr($path, 0, $lastSlashPos); if (! $path) { $path = '/'; } @@ -247,7 +243,7 @@ public function getCookie($uri, $cookieName, $retAs = self::COOKIE_OBJECT) * Helper function to recursively flatten an array. Should be used when exporting the * cookies array (or parts of it) * - * @param \Laminas\Http\Header\SetCookie|array $ptr + * @param SetCookie|array $ptr * @param int $retAs What value to return * @return array|string */ @@ -256,9 +252,9 @@ protected function _flattenCookiesArray($ptr, $retAs = self::COOKIE_OBJECT) { // @codingStandardsIgnoreEnd if (is_array($ptr)) { - $ret = ($retAs == self::COOKIE_STRING_CONCAT ? '' : []); + $ret = $retAs === self::COOKIE_STRING_CONCAT ? '' : []; foreach ($ptr as $item) { - if ($retAs == self::COOKIE_STRING_CONCAT) { + if ($retAs === self::COOKIE_STRING_CONCAT) { $ret .= $this->_flattenCookiesArray($item, $retAs); } else { $ret = array_merge($ret, $this->_flattenCookiesArray($item, $retAs)); @@ -278,8 +274,6 @@ protected function _flattenCookiesArray($ptr, $retAs = self::COOKIE_OBJECT) return [$ptr]; } } - - return; } /** @@ -356,7 +350,7 @@ public static function fromResponse(Response $response, $refUri) */ public function isEmpty() { - return count($this) == 0; + return count($this) === 0; } /** diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index d15d7ab1..dd9b3736 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -1,11 +1,5 @@ getFieldName())) { $value = $headerLine; // This is just for preserve the BC. } @@ -91,13 +106,14 @@ public static function fromString($headerLine) * Parse the Field Value Parts represented by a header line * * @param string $headerLine - * @throws Exception\InvalidArgumentException If header is invalid + * @throws Exception\InvalidArgumentException If header is invalid. * @return array */ public function getFieldValuePartsFromHeaderLine($headerLine) { // process multiple accept values, they may be between quotes - if (! preg_match_all('/(?:[^,"]|"(?:[^\\\"]|\\\.)*")+/', $headerLine, $values) + if ( + ! preg_match_all('/(?:[^,"]|"(?:[^\\\"]|\\\.)*")+/', $headerLine, $values) || ! isset($values[0]) ) { throw new Exception\InvalidArgumentException( @@ -133,7 +149,7 @@ protected function parseFieldValuePart($fieldValuePart) $fieldValuePart = trim(substr($fieldValuePart, 0, $pos)); } - $format = '*'; + $format = '*'; $subtype = '*'; return (object) [ @@ -142,7 +158,7 @@ protected function parseFieldValuePart($fieldValuePart) 'subtype' => $subtype, 'subtypeRaw' => $subtypeWhole, 'format' => $format, - 'priority' => isset($params['q']) ? $params['q'] : 1, + 'priority' => $params['q'] ?? 1, 'params' => $params, 'raw' => trim($raw), ]; @@ -157,7 +173,7 @@ protected function parseFieldValuePart($fieldValuePart) protected function getParametersFromFieldValuePart($fieldValuePart) { $params = []; - if ((($pos = strpos($fieldValuePart, ';')) !== false)) { + if (($pos = strpos($fieldValuePart, ';')) !== false) { preg_match_all('/(?:[^;"]|"(?:[^\\\"]|\\\.)*")+/', $fieldValuePart, $paramsStrings); if (isset($paramsStrings[0])) { @@ -174,7 +190,7 @@ protected function getParametersFromFieldValuePart($fieldValuePart) $value = null; } - if (isset($value[0]) && $value[0] == '"' && substr($value, -1) == '"') { + if (isset($value[0]) && $value[0] === '"' && substr($value, -1) === '"') { $value = substr(substr($value, 1), 0, -1); } @@ -227,7 +243,7 @@ function ($v) { $value ); - if ($escaped == $value && ! array_intersect(str_split($value), $separators)) { + if ($escaped === $value && ! array_intersect(str_split($value), $separators)) { $value = $key . ($value ? '=' . $value : ''); } else { $value = $key . ($value ? '="' . $escaped . '"' : ''); @@ -255,7 +271,8 @@ protected function addType($type, $priority = 1, array $params = []) )); } - if (! is_int($priority) && ! is_float($priority) && ! is_numeric($priority) + if ( + ! is_int($priority) && ! is_float($priority) && ! is_numeric($priority) || $priority > 1 || $priority < 0 ) { throw new Exception\InvalidArgumentException(sprintf( @@ -265,7 +282,7 @@ protected function addType($type, $priority = 1, array $params = []) )); } - if ($priority != 1) { + if ($priority !== 1) { $params = ['q' => sprintf('%01.1f', $priority)] + $params; } @@ -303,7 +320,7 @@ public function match($matchAgainst) foreach ($this->getPrioritized() as $left) { foreach ($matchAgainst as $right) { - if ($right->type == '*' || $left->type == '*') { + if ($right->type === '*' || $left->type === '*') { if ($this->matchAcceptParams($left, $right)) { $left->setMatchedAgainst($right); @@ -311,9 +328,10 @@ public function match($matchAgainst) } } - if ($left->type == $right->type) { - if (($left->subtype == $right->subtype || ($right->subtype == '*' || $left->subtype == '*')) - && ($left->format == $right->format || $right->format == '*' || $left->format == '*') + if ($left->type === $right->type) { + if ( + ($left->subtype === $right->subtype || ($right->subtype === '*' || $left->subtype === '*')) + && ($left->format === $right->format || $right->format === '*' || $left->format === '*') ) { if ($this->matchAcceptParams($left, $right)) { $left->setMatchedAgainst($right); @@ -346,7 +364,8 @@ protected function matchAcceptParams($match1, $match2) $pieces ); - if (count($pieces) == 3 + if ( + count($pieces) === 3 && (version_compare($pieces[1], $match1->params[$key], '<=') xor version_compare($pieces[2], $match1->params[$key], '>=')) ) { @@ -354,9 +373,9 @@ protected function matchAcceptParams($match1, $match2) } } elseif (strpos($value, '|')) { $options = explode('|', $value); - $good = false; + $good = false; foreach ($options as $option) { - if ($option == $match1->params[$key]) { + if ($option === $match1->params[$key]) { $good = true; break; } @@ -365,7 +384,7 @@ protected function matchAcceptParams($match1, $match2) if (! $good) { return false; } - } elseif ($match1->params[$key] != $value) { + } elseif ($match1->params[$key] !== $value) { return false; } } @@ -378,18 +397,18 @@ protected function matchAcceptParams($match1, $match2) * Add a key/value combination to the internal queue * * @param stdClass $value - * @return number + * @return void */ protected function addFieldValuePartToQueue($value) { $this->fieldValueParts[] = $value; - $this->sorted = false; + $this->sorted = false; } /** * Sort the internal Field Value Parts * - * @See rfc2616 sect 14.1 + * @see rfc2616 sect 14.1 * Media ranges can be overridden by more specific media ranges or * specific media types. If more than one media range applies to a given * type, the most specific reference has precedence. For example, @@ -403,11 +422,11 @@ protected function addFieldValuePartToQueue($value) * 3) text/* * 4) * /* * - * @return number + * @return void */ protected function sortFieldValueParts() { - $sort = function ($a, $b) { + $sort = static function (object $a, object $b): int { // If A has higher precedence than B, return -1. if ($a->priority > $b->priority) { return -1; @@ -418,26 +437,26 @@ protected function sortFieldValueParts() // Asterisks $values = ['type', 'subtype', 'format']; foreach ($values as $value) { - if ($a->$value == '*' && $b->$value != '*') { + if ($a->$value === '*' && $b->$value !== '*') { return 1; - } elseif ($b->$value == '*' && $a->$value != '*') { + } elseif ($b->$value === '*' && $a->$value !== '*') { return -1; } } - if ($a->type == 'application' && $b->type != 'application') { + if ($a->type === 'application' && $b->type !== 'application') { return -1; - } elseif ($b->type == 'application' && $a->type != 'application') { + } elseif ($b->type === 'application' && $a->type !== 'application') { return 1; } // @todo count number of dots in case of type==application in subtype // So far they're still the same. Longest string length may be more specific - if (strlen($a->raw) == strlen($b->raw)) { + if (strlen($a->raw) === strlen($b->raw)) { return 0; } - return (strlen($a->raw) > strlen($b->raw)) ? -1 : 1; + return strlen($a->raw) > strlen($b->raw) ? -1 : 1; }; usort($this->fieldValueParts, $sort); diff --git a/src/Header/AbstractDate.php b/src/Header/AbstractDate.php index 5d56c3de..9ff0fe0c 100644 --- a/src/Header/AbstractDate.php +++ b/src/Header/AbstractDate.php @@ -1,15 +1,17 @@ getFieldName())) { - throw new Exception\InvalidArgumentException( + throw new InvalidArgumentException( 'Invalid header line for "' . $dateHeader->getFieldName() . '" header string' ); } @@ -92,7 +96,7 @@ public static function fromString($headerLine) * * @param int|string $time * @return static - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public static function fromTimeString($time) { @@ -104,14 +108,14 @@ public static function fromTimeString($time) * * @param int $time * @return static - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public static function fromTimestamp($time) { $dateHeader = new static(); if (! $time || ! is_numeric($time)) { - throw new Exception\InvalidArgumentException( + throw new InvalidArgumentException( 'Invalid time for "' . $dateHeader->getFieldName() . '" header string' ); } @@ -125,12 +129,12 @@ public static function fromTimestamp($time) * Set date output format * * @param int $format - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public static function setDateFormat($format) { if (! isset(static::$dateFormats[$format])) { - throw new Exception\InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( 'No constant defined for provided date format: %s', $format )); @@ -154,22 +158,22 @@ public static function getDateFormat() * * @param string|DateTime $date * @return $this - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public function setDate($date) { if (is_string($date)) { try { $date = new DateTime($date, new DateTimeZone('GMT')); - } catch (\Exception $e) { - throw new Exception\InvalidArgumentException( + } catch (Exception $e) { + throw new InvalidArgumentException( sprintf('Invalid date passed as string (%s)', (string) $date), $e->getCode(), $e ); } - } elseif (! ($date instanceof DateTime)) { - throw new Exception\InvalidArgumentException('Date must be an instance of \DateTime or a string'); + } elseif (! $date instanceof DateTime) { + throw new InvalidArgumentException('Date must be an instance of \DateTime or a string'); } $date->setTimezone(new DateTimeZone('GMT')); @@ -204,32 +208,33 @@ public function date() /** * Compare provided date to date for this header * Returns < 0 if date in header is less than $date; > 0 if it's greater, and 0 if they are equal. + * * @see \strcmp() * * @param string|DateTime $date * @return int - * @throws Exception\InvalidArgumentException + * @throws InvalidArgumentException */ public function compareTo($date) { if (is_string($date)) { try { $date = new DateTime($date, new DateTimeZone('GMT')); - } catch (\Exception $e) { - throw new Exception\InvalidArgumentException( + } catch (Exception $e) { + throw new InvalidArgumentException( sprintf('Invalid Date passed as string (%s)', (string) $date), $e->getCode(), $e ); } - } elseif (! ($date instanceof DateTime)) { - throw new Exception\InvalidArgumentException('Date must be an instance of \DateTime or a string'); + } elseif (! $date instanceof DateTime) { + throw new InvalidArgumentException('Date must be an instance of \DateTime or a string'); } $dateTimestamp = $date->getTimestamp(); $thisTimestamp = $this->date()->getTimestamp(); - return ($thisTimestamp === $dateTimestamp) ? 0 : (($thisTimestamp > $dateTimestamp) ? 1 : -1); + return $thisTimestamp === $dateTimestamp ? 0 : ($thisTimestamp > $dateTimestamp ? 1 : -1); } /** diff --git a/src/Header/AbstractLocation.php b/src/Header/AbstractLocation.php index 442e54f5..ce5933ec 100644 --- a/src/Header/AbstractLocation.php +++ b/src/Header/AbstractLocation.php @@ -1,20 +1,20 @@ getFieldName())) { @@ -84,7 +84,7 @@ public function setUri($uri) $e ); } - } elseif (! ($uri instanceof UriInterface)) { + } elseif (! $uri instanceof UriInterface) { throw new Exception\InvalidArgumentException('URI must be an instance of Laminas\Uri\Http or a string'); } $this->uri = $uri; diff --git a/src/Header/Accept.php b/src/Header/Accept.php index b962e2bf..cb1a494f 100644 --- a/src/Header/Accept.php +++ b/src/Header/Accept.php @@ -1,15 +1,13 @@ $subtype, 'subtypeRaw' => $subtypeWhole, 'format' => $format, - 'priority' => isset($params['q']) ? $params['q'] : 1, + 'priority' => $params['q'] ?? 1, 'params' => $params, 'raw' => trim($raw), ]; diff --git a/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php b/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php index 22dda7de..40604003 100644 --- a/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php +++ b/src/Header/Accept/FieldValuePart/AbstractFieldValuePart.php @@ -1,13 +1,9 @@ getInternalValues()->typeString; } + /** @return string */ public function getPrimaryTag() { return $this->getInternalValues()->type; } + /** @return string */ public function getSubTag() { return $this->getInternalValues()->subtype; diff --git a/src/Header/AcceptCharset.php b/src/Header/AcceptCharset.php index 75d5c818..baec40b7 100644 --- a/src/Header/AcceptCharset.php +++ b/src/Header/AcceptCharset.php @@ -1,14 +1,9 @@ $subtype, 'subtypeRaw' => $subtypeWhole, 'format' => $format, - 'priority' => isset($params['q']) ? $params['q'] : 1, + 'priority' => $params['q'] ?? 1, 'params' => $params, 'raw' => trim($raw), ]; diff --git a/src/Header/AcceptRanges.php b/src/Header/AcceptRanges.php index 562cd4d1..800ab649 100644 --- a/src/Header/AcceptRanges.php +++ b/src/Header/AcceptRanges.php @@ -1,13 +1,9 @@ getRangeUnit(); } + /** + * @param string $rangeUnit + * @return static + */ public function setRangeUnit($rangeUnit) { HeaderValue::assertValid($rangeUnit); @@ -55,11 +63,13 @@ public function setRangeUnit($rangeUnit) return $this; } + /** @return string */ public function getRangeUnit() { return (string) $this->rangeUnit; } + /** @return string */ public function toString() { return 'Accept-Ranges: ' . $this->getFieldValue(); diff --git a/src/Header/Age.php b/src/Header/Age.php index 9baa8e96..59e6a32d 100644 --- a/src/Header/Age.php +++ b/src/Header/Age.php @@ -1,13 +1,13 @@ deltaSeconds >= PHP_INT_MAX) ? '2147483648' : $this->deltaSeconds); + return 'Age: ' . ($this->deltaSeconds >= PHP_INT_MAX ? '2147483648' : $this->deltaSeconds); } } diff --git a/src/Header/Allow.php b/src/Header/Allow.php index 287eaa86..747c261b 100644 --- a/src/Header/Allow.php +++ b/src/Header/Allow.php @@ -1,15 +1,18 @@ value; } + /** @return string */ public function toString() { return 'Authentication-Info: ' . $this->getFieldValue(); diff --git a/src/Header/Authorization.php b/src/Header/Authorization.php index cb260a01..ef73ad63 100644 --- a/src/Header/Authorization.php +++ b/src/Header/Authorization.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Authorization: ' . $this->getFieldValue(); diff --git a/src/Header/CacheControl.php b/src/Header/CacheControl.php index 001e510a..47d1368e 100644 --- a/src/Header/CacheControl.php +++ b/src/Header/CacheControl.php @@ -1,22 +1,27 @@ $token) { if (preg_match('/^' . $token . '/', $value, $matches)) { $lastMatch = $matches[0]; - $string = substr($value, strlen($matches[0])); + $string = substr($value, strlen($matches[0])); return $i; } } diff --git a/src/Header/Connection.php b/src/Header/Connection.php index 6590511d..52919f13 100644 --- a/src/Header/Connection.php +++ b/src/Header/Connection.php @@ -1,13 +1,10 @@ value === self::CONNECTION_KEEP_ALIVE); + return $this->value === self::CONNECTION_KEEP_ALIVE; } /** diff --git a/src/Header/ContentDisposition.php b/src/Header/ContentDisposition.php index 2d086423..73cb65c4 100644 --- a/src/Header/ContentDisposition.php +++ b/src/Header/ContentDisposition.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Content-Disposition: ' . $this->getFieldValue(); diff --git a/src/Header/ContentEncoding.php b/src/Header/ContentEncoding.php index 34cbc4e4..469c623b 100644 --- a/src/Header/ContentEncoding.php +++ b/src/Header/ContentEncoding.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Content-Encoding: ' . $this->getFieldValue(); diff --git a/src/Header/ContentLanguage.php b/src/Header/ContentLanguage.php index 19831ae7..4aa1e6f3 100644 --- a/src/Header/ContentLanguage.php +++ b/src/Header/ContentLanguage.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Content-Language: ' . $this->getFieldValue(); diff --git a/src/Header/ContentLength.php b/src/Header/ContentLength.php index ed55b624..446b89f7 100644 --- a/src/Header/ContentLength.php +++ b/src/Header/ContentLength.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Content-Length: ' . $this->getFieldValue(); diff --git a/src/Header/ContentLocation.php b/src/Header/ContentLocation.php index b01d8dda..eb83742c 100644 --- a/src/Header/ContentLocation.php +++ b/src/Header/ContentLocation.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Content-MD5: ' . $this->getFieldValue(); diff --git a/src/Header/ContentRange.php b/src/Header/ContentRange.php index d028e4d2..0ed2a13c 100644 --- a/src/Header/ContentRange.php +++ b/src/Header/ContentRange.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Content-Range: ' . $this->getFieldValue(); diff --git a/src/Header/ContentSecurityPolicy.php b/src/Header/ContentSecurityPolicy.php index 1247c79e..ab8eecda 100644 --- a/src/Header/ContentSecurityPolicy.php +++ b/src/Header/ContentSecurityPolicy.php @@ -1,13 +1,17 @@ getFieldName(); - list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $header = new static(); + $headerName = $header->getFieldName(); + [$name, $value] = GenericHeader::splitHeaderLine($headerLine); // Ensure the proper header name - if (strcasecmp($name, $headerName) != 0) { + if (strcasecmp($name, $headerName) !== 0) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid header line for %s string: "%s"', $headerName, @@ -156,7 +161,7 @@ public static function fromString($headerLine) foreach ($tokens as $token) { $token = trim($token); if ($token) { - list($directiveName, $directiveValue) = array_pad(explode(' ', $token, 2), 2, null); + [$directiveName, $directiveValue] = array_pad(explode(' ', $token, 2), 2, null); if (! isset($header->directives[$directiveName])) { $header->setDirective( $directiveName, @@ -202,6 +207,7 @@ public function toString() return sprintf('%s: %s', $this->getFieldName(), $this->getFieldValue()); } + /** @return string */ public function toStringMultipleHeaders(array $headers) { $strings = [$this->toString()]; diff --git a/src/Header/ContentSecurityPolicyReportOnly.php b/src/Header/ContentSecurityPolicyReportOnly.php index 0d3ac237..adcc8082 100644 --- a/src/Header/ContentSecurityPolicyReportOnly.php +++ b/src/Header/ContentSecurityPolicyReportOnly.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Content-Transfer-Encoding: ' . $this->getFieldValue(); diff --git a/src/Header/ContentType.php b/src/Header/ContentType.php index 86921743..02ae0a62 100644 --- a/src/Header/ContentType.php +++ b/src/Header/ContentType.php @@ -1,34 +1,41 @@ getMediaTypeObjectFromString($matchType); // Is the right side a wildcard type? - if ($right->type == '*') { + if ($right->type === '*') { if ($this->validateSubtype($right, $left)) { return $matchType; } } // Do the types match? - if ($right->type == $left->type) { + if ($right->type === $left->type) { if ($this->validateSubtype($right, $left)) { return $matchType; } @@ -213,7 +224,7 @@ public function setCharset($charset) { HeaderValue::assertValid($charset); $this->parameters['charset'] = $charset; - $this->value = null; + $this->value = null; return $this; } @@ -284,12 +295,12 @@ protected function getMediaTypeObjectFromString($string) if (! is_string($string)) { throw new Exception\InvalidArgumentException(sprintf( 'Non-string mediatype "%s" provided', - (is_object($string) ? get_class($string) : gettype($string)) + is_object($string) ? get_class($string) : gettype($string) )); } $parts = explode('/', $string, 2); - if (1 == count($parts)) { + if (1 === count($parts)) { throw new Exception\DomainException(sprintf( 'Invalid mediatype "%s" provided', $string @@ -305,13 +316,11 @@ protected function getMediaTypeObjectFromString($string) $format = array_shift($parts); } - $mediaType = (object) [ + return (object) [ 'type' => $type, 'subtype' => $subtype, 'format' => $format, ]; - - return $mediaType; } /** @@ -324,17 +333,17 @@ protected function getMediaTypeObjectFromString($string) protected function validateSubtype($right, $left) { // Is the right side a wildcard subtype? - if ($right->subtype == '*') { + if ($right->subtype === '*') { return $this->validateFormat($right, $left); } // Do the right side and left side subtypes match? - if ($right->subtype == $left->subtype) { + if ($right->subtype === $left->subtype) { return $this->validateFormat($right, $left); } // Is the right side a partial wildcard? - if ('*' == substr($right->subtype, -1)) { + if ('*' === substr($right->subtype, -1)) { // validate partial-wildcard subtype if (! $this->validatePartialWildcard($right->subtype, $left->subtype)) { return false; @@ -344,7 +353,7 @@ protected function validateSubtype($right, $left) } // Does the right side subtype match the left side format? - if ($right->subtype == $left->format) { + if ($right->subtype === $left->format) { return true; } @@ -364,10 +373,10 @@ protected function validateSubtype($right, $left) protected function validateFormat($right, $left) { if ($right->format && $left->format) { - if ($right->format == '*') { + if ($right->format === '*') { return true; } - if ($right->format == $left->format) { + if ($right->format === $left->format) { return true; } return false; @@ -386,7 +395,7 @@ protected function validateFormat($right, $left) protected function validatePartialWildcard($right, $left) { $requiredSegment = substr($right, 0, strlen($right) - 1); - if ($requiredSegment == $left) { + if ($requiredSegment === $left) { return true; } diff --git a/src/Header/Cookie.php b/src/Header/Cookie.php index c6bcbb2c..87874a14 100644 --- a/src/Header/Cookie.php +++ b/src/Header/Cookie.php @@ -1,23 +1,34 @@ encodeValue; } + /** @return string */ public function getFieldName() { return 'Cookie'; } + /** @return string */ public function getFieldValue() { $nvPairs = []; foreach ($this->flattenCookies($this) as $name => $value) { - $nvPairs[] = $name . '=' . (($this->encodeValue) ? urlencode($value) : $value); + $nvPairs[] = $name . '=' . ($this->encodeValue ? urlencode($value) : $value); } return implode('; ', $nvPairs); } + /** + * @param iterable $data + * @param null|string $prefix + * @return array + */ protected function flattenCookies($data, $prefix = null) { $result = []; @@ -126,6 +147,7 @@ protected function flattenCookies($data, $prefix = null) return $result; } + /** @return string */ public function toString() { return 'Cookie: ' . $this->getFieldValue(); diff --git a/src/Header/Date.php b/src/Header/Date.php index 700e3830..01a21590 100644 --- a/src/Header/Date.php +++ b/src/Header/Date.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Etag: ' . $this->getFieldValue(); diff --git a/src/Header/Exception/DomainException.php b/src/Header/Exception/DomainException.php index 98d62190..5f865005 100644 --- a/src/Header/Exception/DomainException.php +++ b/src/Header/Exception/DomainException.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Expect: ' . $this->getFieldValue(); diff --git a/src/Header/Expires.php b/src/Header/Expires.php index e55fb05f..6735e07c 100644 --- a/src/Header/Expires.php +++ b/src/Header/Expires.php @@ -1,13 +1,11 @@ getFieldName(); - list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + $header = new static(); + $headerName = $header->getFieldName(); + [$name, $value] = GenericHeader::splitHeaderLine($headerLine); // Ensure the proper header name if (strcasecmp($name, $headerName) !== 0) { throw new Exception\InvalidArgumentException(sprintf( @@ -136,7 +139,7 @@ public static function fromString($headerLine) foreach ($tokens as $token) { $token = trim($token); if ($token) { - list($directiveName, $directiveValue) = array_pad(explode(' ', $token, 2), 2, null); + [$directiveName, $directiveValue] = array_pad(explode(' ', $token, 2), 2, null); if (! isset($header->directives[$directiveName])) { $header->setDirective( $directiveName, diff --git a/src/Header/From.php b/src/Header/From.php index c97eada0..7ed1592b 100644 --- a/src/Header/From.php +++ b/src/Header/From.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'From: ' . $this->getFieldValue(); diff --git a/src/Header/GenericHeader.php b/src/Header/GenericHeader.php index 817dbd48..fdf9bf35 100644 --- a/src/Header/GenericHeader.php +++ b/src/Header/GenericHeader.php @@ -1,26 +1,22 @@ getFieldName(); + $name = $this->getFieldName(); $values = [$this->getFieldValue()]; foreach ($headers as $header) { if (! $header instanceof static) { diff --git a/src/Header/HeaderInterface.php b/src/Header/HeaderInterface.php index 2bc35985..bce35c74 100644 --- a/src/Header/HeaderInterface.php +++ b/src/Header/HeaderInterface.php @@ -1,11 +1,5 @@ 254 ) { @@ -64,6 +63,7 @@ public static function filter($value) * between visible characters. * * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @param string $value * @return bool */ @@ -79,7 +79,8 @@ public static function isValid($value) // 32-126, 128-254 === visible // 127 === DEL // 255 === null byte - if (($ascii < 32 && $ascii !== 9) + if ( + ($ascii < 32 && $ascii !== 9) || $ascii === 127 || $ascii > 254 ) { @@ -94,7 +95,7 @@ public static function isValid($value) * Assert a header value is valid. * * @param string $value - * @throws Exception\RuntimeException for invalid values + * @throws Exception\RuntimeException For invalid values. * @return void */ public static function assertValid($value) diff --git a/src/Header/Host.php b/src/Header/Host.php index dd5bda93..ec3f3504 100644 --- a/src/Header/Host.php +++ b/src/Header/Host.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Host: ' . $this->getFieldValue(); diff --git a/src/Header/IfMatch.php b/src/Header/IfMatch.php index 73a179e1..0dfe106e 100644 --- a/src/Header/IfMatch.php +++ b/src/Header/IfMatch.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'If-Match: ' . $this->getFieldValue(); diff --git a/src/Header/IfModifiedSince.php b/src/Header/IfModifiedSince.php index 8f0b671d..fa87e180 100644 --- a/src/Header/IfModifiedSince.php +++ b/src/Header/IfModifiedSince.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'If-None-Match: ' . $this->getFieldValue(); diff --git a/src/Header/IfRange.php b/src/Header/IfRange.php index b2a02c65..c5ece72c 100644 --- a/src/Header/IfRange.php +++ b/src/Header/IfRange.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'If-Range: ' . $this->getFieldValue(); diff --git a/src/Header/IfUnmodifiedSince.php b/src/Header/IfUnmodifiedSince.php index fa9b6860..4a792b56 100644 --- a/src/Header/IfUnmodifiedSince.php +++ b/src/Header/IfUnmodifiedSince.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Keep-Alive: ' . $this->getFieldValue(); diff --git a/src/Header/LastModified.php b/src/Header/LastModified.php index d876715e..e7f57713 100644 --- a/src/Header/LastModified.php +++ b/src/Header/LastModified.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Max-Forwards: ' . $this->getFieldValue(); diff --git a/src/Header/MultipleHeaderInterface.php b/src/Header/MultipleHeaderInterface.php index 8c6a511f..9c8306ce 100644 --- a/src/Header/MultipleHeaderInterface.php +++ b/src/Header/MultipleHeaderInterface.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Origin: ' . $this->getFieldValue(); diff --git a/src/Header/Pragma.php b/src/Header/Pragma.php index d913b486..8ae8b711 100644 --- a/src/Header/Pragma.php +++ b/src/Header/Pragma.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Pragma: ' . $this->getFieldValue(); diff --git a/src/Header/ProxyAuthenticate.php b/src/Header/ProxyAuthenticate.php index fcc5bb58..0637efb9 100644 --- a/src/Header/ProxyAuthenticate.php +++ b/src/Header/ProxyAuthenticate.php @@ -1,27 +1,28 @@ value; } + /** @return string */ public function toString() { return 'Proxy-Authenticate: ' . $this->getFieldValue(); } + /** @return string */ public function toStringMultipleHeaders(array $headers) { $strings = [$this->toString()]; diff --git a/src/Header/ProxyAuthorization.php b/src/Header/ProxyAuthorization.php index ff372e79..ebfdae93 100644 --- a/src/Header/ProxyAuthorization.php +++ b/src/Header/ProxyAuthorization.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'Proxy-Authorization: ' . $this->getFieldValue(); diff --git a/src/Header/Range.php b/src/Header/Range.php index 102782a9..c8c78af4 100644 --- a/src/Header/Range.php +++ b/src/Header/Range.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Range: ' . $this->getFieldValue(); diff --git a/src/Header/Referer.php b/src/Header/Referer.php index bcde31c0..6cef9c8f 100644 --- a/src/Header/Referer.php +++ b/src/Header/Referer.php @@ -1,11 +1,5 @@ value; } + /** @return string */ public function toString() { return 'Refresh: ' . $this->getFieldValue(); diff --git a/src/Header/RetryAfter.php b/src/Header/RetryAfter.php index 62bb9ea8..dd962a6e 100644 --- a/src/Header/RetryAfter.php +++ b/src/Header/RetryAfter.php @@ -1,13 +1,10 @@ getFieldName())) { @@ -91,7 +88,7 @@ public function getFieldName() */ public function getFieldValue() { - return ($this->date === null) ? $this->deltaSeconds : $this->getDate(); + return $this->date === null ? $this->deltaSeconds : $this->getDate(); } /** diff --git a/src/Header/Server.php b/src/Header/Server.php index b3f4aee6..92252452 100644 --- a/src/Header/Server.php +++ b/src/Header/Server.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Server: ' . $this->getFieldValue(); diff --git a/src/Header/SetCookie.php b/src/Header/SetCookie.php index e5a2500e..0341a109 100644 --- a/src/Header/SetCookie.php +++ b/src/Header/SetCookie.php @@ -1,25 +1,42 @@ self::SAME_SITE_STRICT, - 'lax' => self::SAME_SITE_LAX, - 'none' => self::SAME_SITE_NONE, + 'lax' => self::SAME_SITE_LAX, + 'none' => self::SAME_SITE_NONE, ]; /** @@ -113,25 +130,19 @@ class SetCookie implements MultipleHeaderInterface */ protected $quoteFieldValue = false; - /** - * @var bool|null - */ + /** @var bool|null */ protected $httponly; - /** - * @var string|null - */ + /** @var string|null */ protected $sameSite; - /** - * @var bool - */ + /** @var bool */ protected $encodeValue = true; /** * @static * @throws Exception\InvalidArgumentException - * @param $headerLine + * @param string $headerLine * @param bool $bypassHeaderFieldName * @return array|SetCookie */ @@ -140,18 +151,18 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) static $setCookieProcessor = null; if ($setCookieProcessor === null) { - $setCookieClass = get_called_class(); + $setCookieClass = static::class; $setCookieProcessor = function ($headerLine) use ($setCookieClass) { /** @var SetCookie $header */ - $header = new $setCookieClass(); + $header = new $setCookieClass(); $keyValuePairs = preg_split('#;\s*#', $headerLine); foreach ($keyValuePairs as $keyValue) { if (preg_match('#^(?P[^=]+)=\s*("?)(?P[^"]*)\2#', $keyValue, $matches)) { - $headerKey = $matches['headerKey']; + $headerKey = $matches['headerKey']; $headerValue = $matches['headerValue']; } else { - $headerKey = $keyValue; + $headerKey = $keyValue; $headerValue = null; } @@ -202,11 +213,11 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) }; } - list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + [$name, $value] = GenericHeader::splitHeaderLine($headerLine); HeaderValue::assertValid($value); // some sites return set-cookie::value, this is to get rid of the second : - $name = strtolower($name) == 'set-cookie:' ? 'set-cookie' : $name; + $name = strtolower($name) === 'set-cookie:' ? 'set-cookie' : $name; // check to ensure proper header type for this factory if (strtolower($name) !== 'set-cookie') { @@ -230,7 +241,6 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) * Cookie object constructor * * @todo Add validation of each one of the parameters (legal domain, etc.) - * * @param string|null $name * @param string|null $value * @param int|string|DateTime|null $expires @@ -298,7 +308,8 @@ public function getFieldName() */ public function getFieldValue() { - if ($this->getName() == '') { + $name = $this->getName(); + if ($name === '' || $name === null) { return ''; } @@ -307,7 +318,7 @@ public function getFieldValue() $value = '"' . $value . '"'; } - $fieldValue = $this->getName() . '=' . $value; + $fieldValue = $name . '=' . $value; $version = $this->getVersion(); if ($version !== null) { @@ -606,7 +617,7 @@ public function isExpired($now = null) */ public function isSessionCookie() { - return ($this->expires === null); + return $this->expires === null; } /** @@ -674,7 +685,7 @@ public function isValidForRequest($requestDomain, $path, $isSecure = false) /** * Checks whether the cookie should be sent or not in a specific scenario * - * @param string|\Laminas\Uri\Uri $uri URI to check against (secure, domain, path) + * @param string|Uri $uri URI to check against (secure, domain, path) * @param bool $matchSessionCookies Whether to send session cookies * @param int|null $now Override the current time when checking for expiry time * @return bool @@ -687,12 +698,12 @@ public function match($uri, $matchSessionCookies = true, $now = null) } // Make sure we have a valid Laminas_Uri_Http object - if (! ($uri->isValid() && ($uri->getScheme() == 'http' || $uri->getScheme() == 'https'))) { + if (! ($uri->isValid() && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https'))) { throw new Exception\InvalidArgumentException('Passed URI is not a valid HTTP or HTTPS URI'); } // Check that the cookie is secure (if required) and not expired - if ($this->secure && $uri->getScheme() != 'https') { + if ($this->secure && $uri->getScheme() !== 'https') { return false; } if ($this->isExpired($now)) { @@ -728,9 +739,9 @@ public function match($uri, $matchSessionCookies = true, $now = null) public static function matchCookieDomain($cookieDomain, $host) { $cookieDomain = strtolower($cookieDomain); - $host = strtolower($host); + $host = strtolower($host); // Check for either exact match or suffix match - return $cookieDomain == $host + return $cookieDomain === $host || preg_match('/' . preg_quote($cookieDomain) . '$/', $host); } @@ -745,7 +756,7 @@ public static function matchCookieDomain($cookieDomain, $host) */ public static function matchCookiePath($cookiePath, $path) { - return (strpos($path, $cookiePath) === 0); + return strpos($path, $cookiePath) === 0; } /** @@ -764,7 +775,7 @@ public function toString() public function toStringMultipleHeaders(array $headers) { $headerLine = $this->toString(); - /* @var $header SetCookie */ + /** @var SetCookie $header */ foreach ($headers as $header) { if (! $header instanceof SetCookie) { throw new Exception\RuntimeException( diff --git a/src/Header/TE.php b/src/Header/TE.php index a8129316..edc81c66 100644 --- a/src/Header/TE.php +++ b/src/Header/TE.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'TE: ' . $this->getFieldValue(); diff --git a/src/Header/Trailer.php b/src/Header/Trailer.php index a82b87a6..971916e2 100644 --- a/src/Header/Trailer.php +++ b/src/Header/Trailer.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Trailer: ' . $this->getFieldValue(); diff --git a/src/Header/TransferEncoding.php b/src/Header/TransferEncoding.php index 971b6e0d..0f829afb 100644 --- a/src/Header/TransferEncoding.php +++ b/src/Header/TransferEncoding.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Transfer-Encoding: ' . $this->getFieldValue(); diff --git a/src/Header/Upgrade.php b/src/Header/Upgrade.php index 5555d1a4..34be7f43 100644 --- a/src/Header/Upgrade.php +++ b/src/Header/Upgrade.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Upgrade: ' . $this->getFieldValue(); diff --git a/src/Header/UserAgent.php b/src/Header/UserAgent.php index 6a420a7d..db682e2a 100644 --- a/src/Header/UserAgent.php +++ b/src/Header/UserAgent.php @@ -1,27 +1,27 @@ value; } + /** @return string */ public function toString() { return 'User-Agent: ' . $this->getFieldValue(); diff --git a/src/Header/Vary.php b/src/Header/Vary.php index a0077e33..b0dc1d46 100644 --- a/src/Header/Vary.php +++ b/src/Header/Vary.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Vary: ' . $this->getFieldValue(); diff --git a/src/Header/Via.php b/src/Header/Via.php index 20b212eb..3a2e9112 100644 --- a/src/Header/Via.php +++ b/src/Header/Via.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Via: ' . $this->getFieldValue(); diff --git a/src/Header/WWWAuthenticate.php b/src/Header/WWWAuthenticate.php index 551621e6..9d38712e 100644 --- a/src/Header/WWWAuthenticate.php +++ b/src/Header/WWWAuthenticate.php @@ -1,27 +1,28 @@ value; } + /** @return string */ public function toString() { return 'WWW-Authenticate: ' . $this->getFieldValue(); } + /** @return string */ public function toStringMultipleHeaders(array $headers) { $strings = [$this->toString()]; diff --git a/src/Header/Warning.php b/src/Header/Warning.php index 510900fd..b13437fc 100644 --- a/src/Header/Warning.php +++ b/src/Header/Warning.php @@ -1,27 +1,26 @@ value; } + /** @return string */ public function toString() { return 'Warning: ' . $this->getFieldValue(); diff --git a/src/HeaderLoader.php b/src/HeaderLoader.php index b55d393e..efef4954 100644 --- a/src/HeaderLoader.php +++ b/src/HeaderLoader.php @@ -1,11 +1,5 @@ Header\Accept::class, 'acceptcharset' => Header\AcceptCharset::class, diff --git a/src/Headers.php b/src/Headers.php index 2dc35e38..84e1915b 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -1,11 +1,5 @@ addHeaderLine($value); - } elseif (is_array($value) && count($value) == 1) { + } elseif (is_array($value) && count($value) === 1) { $this->addHeaderLine(key($value), current($value)); - } elseif (is_array($value) && count($value) == 2) { + } elseif (is_array($value) && count($value) === 2) { $this->addHeaderLine($value[0], $value[1]); } elseif ($value instanceof Header\HeaderInterface) { $this->addHeader($value); @@ -184,12 +195,14 @@ public function addHeaders($headers) public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null) { $matches = null; - if (preg_match('/^(?P[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $headerFieldNameOrLine, $matches) - && $fieldValue === null) { + if ( + preg_match('/^(?P[^()><@,;:\"\\/\[\]?=}{ \t]+):.*$/', $headerFieldNameOrLine, $matches) + && $fieldValue === null + ) { // is a header $headerName = $matches['name']; $headerKey = static::createKey($matches['name']); - $line = $headerFieldNameOrLine; + $line = $headerFieldNameOrLine; } elseif ($fieldValue === null) { throw new Exception\InvalidArgumentException('A field name was provided without a field value'); } else { @@ -210,12 +223,11 @@ public function addHeaderLine($headerFieldNameOrLine, $fieldValue = null) /** * Add a Header to this container, for raw values @see addHeaderLine() and addHeaders() * - * @param Header\HeaderInterface $header * @return $this */ public function addHeader(Header\HeaderInterface $header) { - $key = static::createKey($header->getFieldName()); + $key = static::createKey($header->getFieldName()); $index = array_search($key, $this->headersKeys); // No header by that key presently; append key and header to list. @@ -227,10 +239,10 @@ public function addHeader(Header\HeaderInterface $header) // Header exists, and is a multi-value header; append key and header to // list (as multi-value headers are aggregated on retrieval) - $class = ($this->getPluginClassLoader()->load(str_replace('-', '', $key))) ?: Header\GenericHeader::class; - if (in_array(Header\MultipleHeaderInterface::class, class_implements($class, true))) { + $class = $this->getPluginClassLoader()->load(str_replace('-', '', $key)) ?: GenericHeader::class; + if (in_array(MultipleHeaderInterface::class, class_implements($class, true))) { $this->headersKeys[] = $key; - $this->headers[] = $header; + $this->headers[] = $header; return $this; } @@ -243,7 +255,6 @@ public function addHeader(Header\HeaderInterface $header) /** * Remove a Header from the container * - * @param Header\HeaderInterface $header * @return bool */ public function removeHeader(Header\HeaderInterface $header) @@ -284,7 +295,7 @@ public function get($name) return false; } - $class = ($this->getPluginClassLoader()->load(str_replace('-', '', $key))) ?: GenericHeader::class; + $class = $this->getPluginClassLoader()->load(str_replace('-', '', $key)) ?: GenericHeader::class; if (in_array(MultipleHeaderInterface::class, class_implements($class, true))) { $headers = []; @@ -339,7 +350,7 @@ public function next() */ public function key() { - return (key($this->headers)); + return key($this->headers); } /** @@ -349,7 +360,7 @@ public function key() */ public function valid() { - return (current($this->headers) !== false); + return current($this->headers) !== false; } /** @@ -421,7 +432,7 @@ public function toString() public function toArray() { $headers = []; - /* @var $header Header\HeaderInterface */ + /** @var Header\HeaderInterface $header */ foreach ($this->headers as $index => $header) { if (is_array($header)) { $header = $this->lazyLoadHeader($index); @@ -447,6 +458,7 @@ public function toArray() */ public function forceLoading() { + // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedForeach foreach ($this as $item) { // $item should now be loaded } @@ -454,7 +466,7 @@ public function forceLoading() } /** - * @param $index + * @param int|string $index * @param bool $isGeneric If true, there is no need to parse $index and call the ClassLoader. * @return mixed|void */ @@ -463,7 +475,7 @@ protected function lazyLoadHeader($index, $isGeneric = false) $current = $this->headers[$index]; $key = $this->headersKeys[$index]; - /* @var $class Header\HeaderInterface */ + /** @var Header\HeaderInterface $class */ $class = $this->getPluginClassLoader()->load(str_replace('-', '', $key)); if ($isGeneric || ! $class) { $class = GenericHeader::class; @@ -489,8 +501,8 @@ protected function lazyLoadHeader($index, $isGeneric = false) return $current; } - $this->headers[$index] = $current = $headers; - return $current; + $this->headers[$index] = $headers; + return $headers; } /** diff --git a/src/PhpEnvironment/RemoteAddress.php b/src/PhpEnvironment/RemoteAddress.php index 68e4c975..ae4948b9 100644 --- a/src/PhpEnvironment/RemoteAddress.php +++ b/src/PhpEnvironment/RemoteAddress.php @@ -1,13 +1,16 @@ useProxy + if ( + ! $this->useProxy || (isset($_SERVER['REMOTE_ADDR']) && ! in_array($_SERVER['REMOTE_ADDR'], $this->trustedProxies)) ) { return false; @@ -144,8 +149,7 @@ protected function getIpAddressFromProxy() // not know if it is a proxy server, or a client. As such, we treat it // as the originating IP. // @see http://en.wikipedia.org/wiki/X-Forwarded-For - $ip = array_pop($ips); - return $ip; + return array_pop($ips); } /** diff --git a/src/PhpEnvironment/Request.php b/src/PhpEnvironment/Request.php index 9eb52844..80c20342 100644 --- a/src/PhpEnvironment/Request.php +++ b/src/PhpEnvironment/Request.php @@ -1,11 +1,5 @@ $cookie * @return $this */ public function setCookies($cookie) @@ -196,7 +212,6 @@ public function getBasePath() * Provide an alternate Parameter Container implementation for server parameters in this object, * (this is NOT the primary API for value setting, for that see getServer()) * - * @param ParametersInterface $server * @return $this */ public function setServer(ParametersInterface $server) @@ -229,7 +244,7 @@ public function setServer(ParametersInterface $server) $headers[strtr(ucwords(strtolower(strtr(substr($key, 5), '_', ' '))), ' ', '-')] = $value; } elseif (strpos($key, 'CONTENT_') === 0) { $name = substr($key, 8); // Remove "Content-" - $headers['Content-' . (($name == 'MD5') ? $name : ucfirst(strtolower($name)))] = $value; + $headers['Content-' . ($name === 'MD5' ? $name : ucfirst(strtolower($name)))] = $value; } } } @@ -242,7 +257,8 @@ public function setServer(ParametersInterface $server) } // set HTTP version - if (isset($this->serverParams['SERVER_PROTOCOL']) + if ( + isset($this->serverParams['SERVER_PROTOCOL']) && strpos($this->serverParams['SERVER_PROTOCOL'], self::VERSION_10) !== false ) { $this->setVersion(self::VERSION_10); @@ -252,9 +268,10 @@ public function setServer(ParametersInterface $server) $uri = new HttpUri(); // URI scheme - if ((! empty($this->serverParams['HTTPS']) && strtolower($this->serverParams['HTTPS']) !== 'off') + if ( + (! empty($this->serverParams['HTTPS']) && strtolower($this->serverParams['HTTPS']) !== 'off') || (! empty($this->serverParams['HTTP_X_FORWARDED_PROTO']) - && $this->serverParams['HTTP_X_FORWARDED_PROTO'] == 'https') + && $this->serverParams['HTTP_X_FORWARDED_PROTO'] === 'https') ) { $scheme = 'https'; } else { @@ -299,7 +316,7 @@ public function setServer(ParametersInterface $server) // Reported at least for Safari on Windows if (isset($this->serverParams['SERVER_ADDR']) && preg_match('/^\[[0-9a-fA-F\:]+\]$/', $host)) { $host = '[' . $this->serverParams['SERVER_ADDR'] . ']'; - if ($port . ']' == substr($host, strrpos($host, ':') + 1)) { + if ($port . ']' === substr($host, strrpos($host, ':') + 1)) { // The last digit of the IPv6-Address has been taken as port // Unset the port so the default port can be used $port = null; @@ -330,10 +347,11 @@ public function setServer(ParametersInterface $server) /** * Return the parameter container responsible for server parameters or a single parameter value. * + * @see http://www.faqs.org/rfcs/rfc3875.html + * * @param string|null $name Parameter name to retrieve, or null to get the whole container. * @param mixed|null $default Default value to use when the parameter is missing. - * @see http://www.faqs.org/rfcs/rfc3875.html - * @return \Laminas\Stdlib\ParametersInterface|mixed + * @return ParametersInterface|mixed */ public function getServer($name = null, $default = null) { @@ -352,7 +370,6 @@ public function getServer($name = null, $default = null) * Provide an alternate Parameter Container implementation for env parameters in this object, * (this is NOT the primary API for value setting, for that see env()) * - * @param ParametersInterface $env * @return $this */ public function setEnv(ParametersInterface $env) @@ -366,7 +383,7 @@ public function setEnv(ParametersInterface $env) * * @param string|null $name Parameter name to retrieve, or null to get the whole container. * @param mixed|null $default Default value to use when the parameter is missing. - * @return \Laminas\Stdlib\ParametersInterface|mixed + * @return ParametersInterface|mixed */ public function getEnv($name = null, $default = null) { @@ -440,7 +457,7 @@ protected function detectRequestUri() // (double slash problem). $iisUrlRewritten = $server->get('IIS_WasUrlRewritten'); $unencodedUrl = $server->get('UNENCODED_URL', ''); - if ('1' == $iisUrlRewritten && '' !== $unencodedUrl) { + if ('1' === $iisUrlRewritten && '' !== $unencodedUrl) { return $unencodedUrl; } @@ -503,7 +520,7 @@ protected function detectBaseUrl() $baseUrl = '/'; $basename = basename($filename); if ($basename) { - $path = ($phpSelf ? trim($phpSelf, '/') : ''); + $path = $phpSelf ? trim($phpSelf, '/') : ''; $basePos = strpos($path, $basename) ?: 0; $baseUrl .= substr($path, 0, $basePos) . $basename; } @@ -544,7 +561,8 @@ protected function detectBaseUrl() // If using mod_rewrite or ISAPI_Rewrite strip the script filename // out of the base path. $pos !== 0 makes sure it is not matching a // value from PATH_INFO or QUERY_STRING. - if (strlen($requestUri) >= strlen($baseUrl) + if ( + strlen($requestUri) >= strlen($baseUrl) && (false !== ($pos = strpos($requestUri, $baseUrl)) && $pos !== 0) ) { $baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl)); @@ -562,7 +580,7 @@ protected function detectBaseUrl() */ protected function detectBasePath() { - $baseUrl = $this->getBaseUrl(); + $baseUrl = $this->getBaseUrl(); // Empty base url detected if ($baseUrl === '') { diff --git a/src/PhpEnvironment/Response.php b/src/PhpEnvironment/Response.php index 4a6984d6..55c7fcc1 100644 --- a/src/PhpEnvironment/Response.php +++ b/src/PhpEnvironment/Response.php @@ -1,16 +1,15 @@ renderStatusLine(); + $status = $this->renderStatusLine(); header($status); - /** @var \Laminas\Http\Header\HeaderInterface $header */ + /** @var HeaderInterface $header */ foreach ($this->getHeaders() as $header) { if ($header instanceof MultipleHeaderInterface) { header($header->toString(), false); diff --git a/src/Request.php b/src/Request.php index e23f830d..a962308c 100644 --- a/src/Request.php +++ b/src/Request.php @@ -1,19 +1,29 @@ headers === null || is_string($this->headers)) { // this is only here for fromString lazy loading - $this->headers = (is_string($this->headers)) ? Headers::fromString($this->headers) : new Headers(); + $this->headers = is_string($this->headers) ? Headers::fromString($this->headers) : new Headers(); } if ($name === null) { @@ -385,9 +383,10 @@ public function getHeaders($name = null, $default = false) * Get all headers of a certain name/type. * * @see Request::getHeaders() + * * @param string|null $name Header name to retrieve, or null to get the whole container. * @param mixed|null $default Default value to use when the requested header is missing. - * @return \Laminas\Http\Headers|bool|\Laminas\Http\Header\HeaderInterface|\ArrayIterator + * @return Headers|bool|HeaderInterface|ArrayIterator */ public function getHeader($name, $default = false) { @@ -401,7 +400,7 @@ public function getHeader($name, $default = false) */ public function isOptions() { - return ($this->method === self::METHOD_OPTIONS); + return $this->method === self::METHOD_OPTIONS; } /** @@ -411,7 +410,7 @@ public function isOptions() */ public function isPropFind() { - return ($this->method === self::METHOD_PROPFIND); + return $this->method === self::METHOD_PROPFIND; } /** @@ -421,7 +420,7 @@ public function isPropFind() */ public function isGet() { - return ($this->method === self::METHOD_GET); + return $this->method === self::METHOD_GET; } /** @@ -431,7 +430,7 @@ public function isGet() */ public function isHead() { - return ($this->method === self::METHOD_HEAD); + return $this->method === self::METHOD_HEAD; } /** @@ -441,7 +440,7 @@ public function isHead() */ public function isPost() { - return ($this->method === self::METHOD_POST); + return $this->method === self::METHOD_POST; } /** @@ -451,7 +450,7 @@ public function isPost() */ public function isPut() { - return ($this->method === self::METHOD_PUT); + return $this->method === self::METHOD_PUT; } /** @@ -461,7 +460,7 @@ public function isPut() */ public function isDelete() { - return ($this->method === self::METHOD_DELETE); + return $this->method === self::METHOD_DELETE; } /** @@ -471,7 +470,7 @@ public function isDelete() */ public function isTrace() { - return ($this->method === self::METHOD_TRACE); + return $this->method === self::METHOD_TRACE; } /** @@ -481,7 +480,7 @@ public function isTrace() */ public function isConnect() { - return ($this->method === self::METHOD_CONNECT); + return $this->method === self::METHOD_CONNECT; } /** @@ -491,7 +490,7 @@ public function isConnect() */ public function isPatch() { - return ($this->method === self::METHOD_PATCH); + return $this->method === self::METHOD_PATCH; } /** @@ -504,7 +503,7 @@ public function isPatch() public function isXmlHttpRequest() { $header = $this->getHeaders()->get('X_REQUESTED_WITH'); - return false !== $header && $header->getFieldValue() == 'XMLHttpRequest'; + return false !== $header && $header->getFieldValue() === 'XMLHttpRequest'; } /** @@ -533,7 +532,7 @@ public function renderRequestLine() */ public function toString() { - $str = $this->renderRequestLine() . "\r\n"; + $str = $this->renderRequestLine() . "\r\n"; $str .= $this->getHeaders()->toString(); $str .= "\r\n"; $str .= $this->getContent(); diff --git a/src/Response.php b/src/Response.php index d56a92de..99e8afd9 100644 --- a/src/Response.php +++ b/src/Response.php @@ -1,17 +1,31 @@ 'Continue', @@ -174,14 +187,10 @@ class Response extends AbstractMessage implements ResponseInterface 599 => 'Network Connect Timeout Error', ]; - /** - * @var int Status code - */ + /** @var int Status code */ protected $statusCode = 200; - /** - * @var string|null Null means it will be looked up from the $reasonPhrase list above - */ + /** @var string|null Null means it will be looked up from the $reasonPhrase list above */ protected $reasonPhrase; /** @@ -217,7 +226,7 @@ public static function fromString($string) } $isHeader = true; - $headers = $content = []; + $headers = $content = []; foreach ($lines as $line) { if ($isHeader && $line === '') { @@ -233,7 +242,8 @@ public static function fromString($string) continue; } - if (empty($content) + if ( + empty($content) && preg_match('/^[a-z0-9!#$%&\'*+.^_`|~-]+:$/i', $line) ) { throw new Exception\RuntimeException('CRLF injection detected'); @@ -256,7 +266,7 @@ public static function fromString($string) /** * @param string $line * @throws Exception\InvalidArgumentException - * @throws Exception\RuntimeException + * @throws RuntimeException */ protected function parseStatusLine($line) { @@ -270,7 +280,7 @@ protected function parseStatusLine($line) $this->version = $matches['version']; $this->setStatusCode($matches['status']); - $this->setReasonPhrase((isset($matches['reason']) ? $matches['reason'] : '')); + $this->setReasonPhrase($matches['reason'] ?? ''); } /** @@ -290,7 +300,8 @@ public function getCookie() */ public function setStatusCode($code) { - if (! is_numeric($code) + if ( + ! is_numeric($code) || is_float($code) || $code < static::MIN_STATUS_CODE_VALUE || $code > static::MAX_STATUS_CODE_VALUE @@ -345,7 +356,7 @@ public function setCustomStatusCode($code) protected function saveStatusCode($code) { $this->reasonPhrase = null; - $this->statusCode = (int) $code; + $this->statusCode = (int) $code; return $this; } @@ -366,7 +377,7 @@ public function setReasonPhrase($reasonPhrase) */ public function getReasonPhrase() { - if (null == $this->reasonPhrase && isset($this->recommendedReasonPhrases[$this->statusCode])) { + if (empty($this->reasonPhrase) && isset($this->recommendedReasonPhrases[$this->statusCode])) { $this->reasonPhrase = $this->recommendedReasonPhrases[$this->statusCode]; } return $this->reasonPhrase; @@ -411,7 +422,7 @@ public function getBody() public function isClientError() { $code = $this->getStatusCode(); - return ($code < 500 && $code >= 400); + return $code < 500 && $code >= 400; } /** @@ -421,7 +432,7 @@ public function isClientError() */ public function isForbidden() { - return (403 === $this->getStatusCode()); + return 403 === $this->getStatusCode(); } /** @@ -432,7 +443,7 @@ public function isForbidden() public function isInformational() { $code = $this->getStatusCode(); - return ($code >= 100 && $code < 200); + return $code >= 100 && $code < 200; } /** @@ -442,7 +453,7 @@ public function isInformational() */ public function isNotFound() { - return (404 === $this->getStatusCode()); + return 404 === $this->getStatusCode(); } /** @@ -452,7 +463,7 @@ public function isNotFound() */ public function isGone() { - return (410 === $this->getStatusCode()); + return 410 === $this->getStatusCode(); } /** @@ -462,7 +473,7 @@ public function isGone() */ public function isOk() { - return (200 === $this->getStatusCode()); + return 200 === $this->getStatusCode(); } /** @@ -473,7 +484,7 @@ public function isOk() public function isServerError() { $code = $this->getStatusCode(); - return (500 <= $code && 600 > $code); + return 500 <= $code && 600 > $code; } /** @@ -484,7 +495,7 @@ public function isServerError() public function isRedirect() { $code = $this->getStatusCode(); - return (300 <= $code && 400 > $code); + return 300 <= $code && 400 > $code; } /** @@ -495,7 +506,7 @@ public function isRedirect() public function isSuccess() { $code = $this->getStatusCode(); - return (200 <= $code && 300 > $code); + return 200 <= $code && 300 > $code; } /** @@ -533,7 +544,7 @@ public function toString() * * @param string $body * @return string - * @throws Exception\RuntimeException + * @throws RuntimeException */ protected function decodeChunkedBody($body) { @@ -556,7 +567,7 @@ protected function decodeChunkedBody($body) $length = hexdec(trim($m[1])); $cut = strlen($m[0]); $decBody .= substr($body, $offset + $cut, $length); - $offset += $cut + $length + 2; + $offset += $cut + $length + 2; } return $decBody; @@ -569,7 +580,7 @@ protected function decodeChunkedBody($body) * * @param string $body * @return string - * @throws Exception\RuntimeException + * @throws RuntimeException */ protected function decodeGzip($body) { @@ -579,7 +590,8 @@ protected function decodeGzip($body) ); } - if ($body === '' + if ( + $body === '' || ($this->getHeaders()->has('content-length') && (int) $this->getHeaders()->get('content-length')->getFieldValue() === 0) ) { @@ -588,7 +600,7 @@ protected function decodeGzip($body) ErrorHandler::start(); $return = gzinflate(substr($body, 10)); - $test = ErrorHandler::stop(); + $test = ErrorHandler::stop(); if ($test) { throw new Exception\RuntimeException( 'Error occurred during gzip inflation', @@ -606,7 +618,7 @@ protected function decodeGzip($body) * * @param string $body * @return string - * @throws Exception\RuntimeException + * @throws RuntimeException */ protected function decodeDeflate($body) { @@ -616,8 +628,10 @@ protected function decodeDeflate($body) ); } - if ($this->getHeaders()->has('content-length') - && 0 === (int) $this->getHeaders()->get('content-length')->getFieldValue()) { + if ( + $this->getHeaders()->has('content-length') + && 0 === (int) $this->getHeaders()->get('content-length')->getFieldValue() + ) { return ''; } diff --git a/src/Response/Stream.php b/src/Response/Stream.php index 7c71fe69..aa50ac12 100644 --- a/src/Response/Stream.php +++ b/src/Response/Stream.php @@ -1,17 +1,28 @@ getHeaders(); foreach ($headers as $header) { - if ($header instanceof \Laminas\Http\Header\ContentLength) { + if ($header instanceof ContentLength) { $response->setContentLength((int) $header->getFieldValue()); $contentLength = $response->getContentLength(); if (strlen($response->content) > $contentLength) { @@ -267,14 +278,14 @@ protected function readStream() $bytes = -1; // Read the whole buffer } - if (! is_resource($this->stream) || $bytes == 0) { + if (! is_resource($this->stream) || $bytes === 0) { return ''; } $this->content .= stream_get_contents($this->stream, $bytes); $this->contentStreamed += strlen($this->content); - if ($this->getContentLength() == $this->contentStreamed) { + if ($this->getContentLength() === $this->contentStreamed) { $this->stream = null; } } diff --git a/test/Client/CommonHttpTests.php b/test/Client/CommonHttpTests.php index 8aaeb1c1..1074e9aa 100644 --- a/test/Client/CommonHttpTests.php +++ b/test/Client/CommonHttpTests.php @@ -1,25 +1,51 @@ -baseuri . $name . '.php'; - $this->_adapter = new $this->config['adapter'](); - $this->client = new HTTPClient($uri, $this->config); - $this->client->setAdapter($this->_adapter); + $this->adapter = new $this->config['adapter'](); + $this->client = new HTTPClient($uri, $this->config); + $this->client->setAdapter($this->adapter); } else { // Skip tests $this->markTestSkipped(sprintf( @@ -108,15 +132,14 @@ protected function setUp(): void */ protected function tearDown(): void { - $this->client = null; - $this->_adapter = null; + $this->client = null; + $this->adapter = null; } - /** - * Simple request tests - */ + // Simple request tests - public function methodProvider() + /** @psalm-return array */ + public function methodProvider(): array { return [ [Request::METHOD_GET], @@ -132,7 +155,6 @@ public function methodProvider() * Test simple requests * * @dataProvider methodProvider - * * @param string $method */ public function testSimpleRequests($method) @@ -155,7 +177,7 @@ public function testGetLastRawRequest() $this->client->setMethod('TRACE'); $res = $this->client->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } @@ -174,7 +196,6 @@ public function testGetLastRawRequest() * Test we can properly send GET parameters * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testGetData(array $params) @@ -190,7 +211,6 @@ public function testGetData(array $params) * application/x-www-form-urlencoded content type * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testPostDataUrlEncoded(array $params) @@ -211,7 +231,6 @@ public function testPostDataUrlEncoded(array $params) * application/x-www-form-urlencoded content type * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testPatchData(array $params) @@ -233,7 +252,6 @@ public function testPatchData(array $params) * application/x-www-form-urlencoded content type * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testDeleteData(array $params) @@ -255,7 +273,6 @@ public function testDeleteData(array $params) * application/x-www-form-urlencoded content type * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testOptionsData(array $params) @@ -277,7 +294,6 @@ public function testOptionsData(array $params) * multipart/form-data content type * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testPostDataMultipart(array $params) @@ -310,10 +326,10 @@ public function testRawPostData() public function testResetParameters() { $params = [ - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', + 'quest' => 'To seek the holy grail', + 'YourMother' => 'Was a hamster', 'specialChars' => '<>$+ &?=[]^%', - 'array' => ['firstItem', 'secondItem', '3rdItem'], + 'array' => ['firstItem', 'secondItem', '3rdItem'], ]; $headers = ['X-Foo' => 'bar']; @@ -340,8 +356,10 @@ public function testResetParameters() $res->getBody(), "returned body contains GET or POST parameters (it shouldn't!)" ); + // phpcs:disable WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps $headerXFoo = $this->client->getHeader('X-Foo'); $this->assertEmpty($headerXFoo, 'Header not preserved by reset'); + // phpcs:enable } /** @@ -394,16 +412,16 @@ public function testHeadersSingle() $headers = [ 'Accept-encoding' => 'gzip, deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => 'A large wooden badger', - 'Accept' => 'text/xml, text/html, */*', + 'X-baz' => 'Foo', + 'X-powered-by' => 'A large wooden badger', + 'Accept' => 'text/xml, text/html, */*', ]; $this->client->setHeaders($headers); $this->client->setMethod('TRACE'); $res = $this->client->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } @@ -423,8 +441,8 @@ public function testHeadersArray() $headers = [ 'Accept-encoding' => 'gzip, deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => 'A large wooden badger', + 'X-baz' => 'Foo', + 'X-powered-by' => 'A large wooden badger', 'Accept: text/xml, text/html, */*', ]; @@ -432,7 +450,7 @@ public function testHeadersArray() $this->client->setMethod('TRACE'); $res = $this->client->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } @@ -455,13 +473,13 @@ public function testMultipleHeader() $this->client->setUri($this->baseuri . 'testHeaders.php'); $headers = [ 'Accept-encoding' => 'gzip, deflate', - 'X-baz' => 'Foo', - 'X-powered-by' => [ + 'X-baz' => 'Foo', + 'X-powered-by' => [ 'A large wooden badger', 'My Shiny Metal Ass', 'Dark Matter', ], - 'Cookie' => [ + 'Cookie' => [ 'foo=bar', 'baz=waka', ], @@ -471,7 +489,7 @@ public function testMultipleHeader() $this->client->setMethod('TRACE'); $res = $this->client->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } $body = strtolower($res->getBody()); @@ -512,8 +530,9 @@ public function testRedirectDefault() } /** - * @group Laminas-4136 * @link https://getlaminas.org/issues/browse/Laminas-122 + * + * @group Laminas-4136 */ public function testRedirectPersistsCookies() { @@ -623,8 +642,8 @@ public function testAbsolutePathRedirect() $this->client->setOptions(['maxredirects' => 1]); // Get the host and port part of our baseuri - $port = $this->client->getUri()->getPort() == 80 ? '' : ':' . $this->client->getUri()->getPort(); - $uri = $this->client->getUri()->getScheme() . '://' . $this->client->getUri()->getHost() . $port; + $port = $this->client->getUri()->getPort() === 80 ? '' : ':' . $this->client->getUri()->getPort(); + $uri = $this->client->getUri()->getScheme() . '://' . $this->client->getUri()->getHost() . $port; $res = $this->client->send(); @@ -749,8 +768,8 @@ public function testSetCookieObjectArray() $cookies = [ 'chocolate' => 'chips', - 'crumble' => 'apple', - 'another' => 'cookie', + 'crumble' => 'apple', + 'another' => 'cookie', ]; $this->client->setCookies($cookies); @@ -891,7 +910,7 @@ public function testStaticLargeFileDownload() { $this->client->setUri($this->baseuri . 'staticFile.jpg'); - $got = $this->client->send()->getBody(); + $got = $this->client->send()->getBody(); $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $got, 'Downloaded file does not seem to match!'); @@ -941,7 +960,7 @@ public function testLaminas4238FalseLinesInResponse() { $this->client->setUri($this->baseuri . 'Laminas4238-zerolineresponse.txt'); - $got = $this->client->send()->getBody(); + $got = $this->client->send()->getBody(); $expected = $this->getTestFileContents('Laminas4238-zerolineresponse.txt'); $this->assertEquals($expected, $got); } @@ -963,7 +982,7 @@ public function testStreamResponse() $streamName = $response->getStreamName(); $streamRead = stream_get_contents($response->getStream()); - $fileRead = file_get_contents($streamName); + $fileRead = file_get_contents($streamName); $expected = $this->getTestFileContents('staticFile.jpg'); @@ -1011,7 +1030,7 @@ public function testStreamResponseNamed() $this->assertEquals($outfile, $response->getStreamName()); $streamRead = stream_get_contents($response->getStream()); - $fileRead = file_get_contents($outfile); + $fileRead = file_get_contents($outfile); $expected = $this->getTestFileContents('staticFile.jpg'); @@ -1029,7 +1048,7 @@ public function testStreamRequest() $this->client->setRawBody($data); $this->client->setEncType('image/jpeg'); $this->client->setMethod('PUT'); - $res = $this->client->send(); + $res = $this->client->send(); $expected = $this->getTestFileContents('staticFile.jpg'); $this->assertEquals($expected, $res->getBody(), 'Response body does not contain the expected data'); } @@ -1051,7 +1070,7 @@ public function testLaminas9404DoubleContentLengthHeader() $clen = $response->getHeaders()->get('Content-Length'); - if (! (is_array($clen))) { + if (! is_array($clen)) { $this->markTestSkipped("Didn't get multiple Content-length headers"); } @@ -1060,9 +1079,7 @@ public function testLaminas9404DoubleContentLengthHeader() /** * @group Laminas-78 - * * @dataProvider parameterArrayProvider - * * @param array $params */ public function testContentTypeAdditionlInfo(array $params) @@ -1121,18 +1138,18 @@ public static function parameterArrayProvider() return [ [ [ - 'quest' => 'To seek the holy grail', - 'YourMother' => 'Was a hamster', + 'quest' => 'To seek the holy grail', + 'YourMother' => 'Was a hamster', 'specialChars' => '<>$+ &?=[]^%', - 'array' => ['firstItem', 'secondItem', '3rdItem'], + 'array' => ['firstItem', 'secondItem', '3rdItem'], ], ], [ [ - 'someData' => [ + 'someData' => [ '1', '2', - 'key' => 'value', + 'key' => 'value', 'nesting' => [ 'a' => 'AAA', 'b' => 'BBB', @@ -1194,10 +1211,10 @@ public function testConnectTimeout1() ->setMethod('GET') ->setOptions([ 'connecttimeout' => $connectTimeout, - 'timeout' => $executeTimeout, + 'timeout' => $executeTimeout, ]); $timeoutException = null; - $startTime = microtime(true); + $startTime = microtime(true); try { $this->client->send(); } catch (Exception $x) { @@ -1227,10 +1244,10 @@ public function testConnectTimeout2() ->setMethod('GET') ->setOptions([ 'connecttimeout' => $connectTimeout, - 'timeout' => $executeTimeout, + 'timeout' => $executeTimeout, ]); $timeoutException = null; - $startTime = microtime(true); + $startTime = microtime(true); try { $this->client->send(); } catch (Exception $x) { diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 279867b2..7cea064d 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -1,14 +1,9 @@ 'hasvalue', ]; - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); - $hasConfig = $this->_adapter->getConfig(); + $hasConfig = $this->adapter->getConfig(); foreach ($config as $k => $v) { $this->assertEquals($v, $hasConfig[$k]); } @@ -85,20 +107,21 @@ public function testConfigSetAsArray() public function testConfigSetAsTraversable() { $config = new ArrayObject([ - 'timeout' => 400, - 'nested' => [ + 'timeout' => 400, + 'nested' => [ 'item' => 'value', ], - ]); + ], ArrayObject::ARRAY_AS_PROPS); - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); - $hasConfig = $this->_adapter->getConfig(); + $hasConfig = $this->adapter->getConfig(); $this->assertEquals($config->timeout, $hasConfig['timeout']); $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); } - public function provideValidTimeoutConfig() + /** @psalm-return array */ + public function provideValidTimeoutConfig(): array { return [ 'integer' => [10], @@ -108,6 +131,7 @@ public function provideValidTimeoutConfig() /** * @dataProvider provideValidTimeoutConfig + * @param int|string $timeout */ public function testPassValidTimeout($timeout) { @@ -132,7 +156,6 @@ public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericString * Check that an exception is thrown when trying to set invalid config * * @dataProvider invalidConfigProvider - * * @param mixed $config */ public function testSetConfigInvalidConfig($config) @@ -140,12 +163,12 @@ public function testSetConfigInvalidConfig($config) $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Array or Traversable object expected'); - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); } public function testSettingInvalidCurlOption() { - $config = [ + $config = [ 'adapter' => Curl::class, 'curloptions' => [-PHP_INT_MAX => true], ]; @@ -158,7 +181,7 @@ public function testSettingInvalidCurlOption() $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Unknown or erroreous cURL option'); } else { - $this->expectException(\ValueError::class); + $this->expectException(ValueError::class); $this->expectExceptionMessage('curl_setopt(): Argument #2 ($option) is not a valid cURL option'); } try { @@ -216,8 +239,9 @@ public function testRedirectPostToGetWithCurlFollowLocationOptionLeadsToTimeout( } /** - * @group Laminas-3758 * @link https://getlaminas.org/issues/browse/Laminas-3758 + * + * @group Laminas-3758 */ public function testPutFileContentWithHttpClient() { @@ -232,8 +256,9 @@ public function testPutFileContentWithHttpClient() } /** - * @group Laminas-3758 * @link https://getlaminas.org/issues/browse/Laminas-3758 + * + * @group Laminas-3758 */ public function testPutFileHandleWithHttpClient() { @@ -241,9 +266,9 @@ public function testPutFileHandleWithHttpClient() $putFileContents = file_get_contents(__DIR__ . '/_files/staticFile.jpg'); // Method 2: Using a File-Handle to the file to PUT the data - $putFilePath = __DIR__ . '/_files/staticFile.jpg'; + $putFilePath = __DIR__ . '/_files/staticFile.jpg'; $putFileHandle = fopen($putFilePath, 'r'); - $putFileSize = filesize($putFilePath); + $putFileSize = filesize($putFilePath); $adapter = new Adapter\Curl(); $this->client->setAdapter($adapter); @@ -323,8 +348,8 @@ public function testWorkWithProxyConfiguration() $expected = [ 'curloptions' => [ CURLOPT_PROXYUSERPWD => 'foo:baz', - CURLOPT_PROXY => 'localhost', - CURLOPT_PROXYPORT => 80, + CURLOPT_PROXY => 'localhost', + CURLOPT_PROXYPORT => 80, ], ]; @@ -455,10 +480,11 @@ public function testSetCurlOptPostFields() } /** - * @group Laminas-7683 * @see https://github.com/zendframework/zend-http/pull/53 * * Note: The headers stored in Laminas7683-chunked.php are case insensitive + * + * @group Laminas-7683 */ public function testNoCaseSensitiveHeaderName() { @@ -528,7 +554,7 @@ public function testTimeoutWithStream() $error = null; try { $this->client->send(); - } catch (\Exception $x) { + } catch (Exception $x) { $error = $x; } $this->assertNotNull($error, 'Failed to detect timeout in cURL adapter'); @@ -544,7 +570,7 @@ public function testMustRemoveProxyConnectionEstablishedLine() $this->markTestSkipped('Proxy is not configured'); } - list($proxyHost, $proxyPort) = explode(':', $proxy); + [$proxyHost, $proxyPort] = explode(':', $proxy); $this->client->setAdapter(new Adapter\Curl()); $this->client->setOptions([ diff --git a/test/Client/ProxyAdapterTest.php b/test/Client/ProxyAdapterTest.php index 3a4237cc..a6a087e2 100644 --- a/test/Client/ProxyAdapterTest.php +++ b/test/Client/ProxyAdapterTest.php @@ -1,16 +1,20 @@ markTestSkipped('No valid proxy host name or address specified.'); @@ -81,13 +86,13 @@ protected function setUp(): void */ public function testFallbackToSocket() { - $this->_adapter->setOptions([ + $this->adapter->setOptions([ 'proxy_host' => null, ]); $this->client->setUri($this->baseuri . 'testGetLastRequest.php'); - $res = $this->client->setMethod(\Laminas\Http\Request::METHOD_TRACE)->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + $res = $this->client->setMethod(Request::METHOD_TRACE)->send(); + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } @@ -107,7 +112,7 @@ public function testGetLastRequest() public function testDefaultConfig() { - $config = $this->_adapter->getConfig(); + $config = $this->adapter->getConfig(); $this->assertEquals(true, $config['sslverifypeer']); $this->assertEquals(false, $config['sslallowselfsigned']); } @@ -141,12 +146,12 @@ public function testGetLastRawRequest() $this->client->setMethod('TRACE'); $res = $this->client->send(); - if ($res->getStatusCode() == 405 || $res->getStatusCode() == 501) { + if ($res->getStatusCode() === 405 || $res->getStatusCode() === 501) { $this->markTestSkipped('Server does not allow the TRACE method'); } - list($schema, $host) = explode('://', $this->baseuri); - $host = trim($host, '/'); + [$schema, $host] = explode('://', $this->baseuri); + $host = trim($host, '/'); $this->assertSame( 'TRACE ' . $this->baseuri . 'testHeaders.php?someinput=somevalue HTTP/1.1' . "\r\n" @@ -174,9 +179,9 @@ public function testGetLastRawRequest() */ public function testProxyKeysCorrectlySetInProxyAdapter() { - $adapterConfig = $this->_adapter->getConfig(); - $adapterHost = $adapterConfig['proxy_host']; - $adapterPort = $adapterConfig['proxy_port']; + $adapterConfig = $this->adapter->getConfig(); + $adapterHost = $adapterConfig['proxy_host']; + $adapterPort = $adapterConfig['proxy_port']; $this->assertSame($this->host, $adapterHost); $this->assertSame($this->port, $adapterPort); @@ -184,10 +189,10 @@ public function testProxyKeysCorrectlySetInProxyAdapter() public function testProxyHasAllSocketConfigs() { - $socket = new Socket(); + $socket = new Socket(); $socketConfig = $socket->getConfig(); - $proxy = new Proxy(); - $proxyConfig = $proxy->getConfig(); + $proxy = new Proxy(); + $proxyConfig = $proxy->getConfig(); foreach (array_keys($socketConfig) as $socketConfigKey) { $this->assertArrayHasKey( $socketConfigKey, diff --git a/test/Client/SocketKeepaliveTest.php b/test/Client/SocketKeepaliveTest.php index 45c4b7f2..3e29daf3 100644 --- a/test/Client/SocketKeepaliveTest.php +++ b/test/Client/SocketKeepaliveTest.php @@ -1,13 +1,9 @@ 'hasvalue', ]; - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); - $hasConfig = $this->_adapter->getConfig(); + $hasConfig = $this->adapter->getConfig(); foreach ($config as $k => $v) { $this->assertEquals($v, $hasConfig[$k]); } @@ -68,7 +70,7 @@ public function testConfigSetAsArray() public function testDefaultConfig() { - $config = $this->_adapter->getConfig(); + $config = $this->adapter->getConfig(); $this->assertEquals(true, $config['sslverifypeer']); $this->assertEquals(false, $config['sslallowselfsigned']); $this->assertEquals(true, $config['sslverifypeername']); @@ -77,14 +79,14 @@ public function testDefaultConfig() public function testConnectingViaSslEnforcesDefaultSslOptionsOnContext() { $config = ['timeout' => 30]; - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); try { - $this->_adapter->connect('localhost', 443, true); + $this->adapter->connect('localhost', 443, true); } catch (RuntimeException $e) { // Test is designed to allow connect failure because we're interested // only in the stream context state created within that method. } - $context = $this->_adapter->getStreamContext(); + $context = $this->adapter->getStreamContext(); $options = stream_context_get_options($context); $this->assertTrue($options['ssl']['verify_peer']); $this->assertFalse($options['ssl']['allow_self_signed']); @@ -99,14 +101,14 @@ public function testConnectingViaSslWithCustomSslOptionsOnContext() 'sslallowselfsigned' => true, 'sslverifypeername' => false, ]; - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); try { - $this->_adapter->connect('localhost', 443, true); + $this->adapter->connect('localhost', 443, true); } catch (RuntimeException $e) { // Test is designed to allow connect failure because we're interested // only in the stream context state created within that method. } - $context = $this->_adapter->getStreamContext(); + $context = $this->adapter->getStreamContext(); $options = stream_context_get_options($context); $this->assertFalse($options['ssl']['verify_peer']); $this->assertTrue($options['ssl']['allow_self_signed']); @@ -124,14 +126,14 @@ public function testConnectingViaSslUsesCertificateFileContext() 'timeout' => 30, 'sslcafile' => __DIR__ . '/_files/ca-bundle.crt', ]; - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); try { - $this->_adapter->connect('localhost', 443, true); + $this->adapter->connect('localhost', 443, true); } catch (RuntimeException $e) { // Test is designed to allow connect failure because we're interested // only in the stream context state created within that method. } - $context = $this->_adapter->getStreamContext(); + $context = $this->adapter->getStreamContext(); $options = stream_context_get_options($context); $this->assertEquals($config['sslcafile'], $options['ssl']['cafile']); } @@ -144,15 +146,15 @@ public function testConnectingViaSslUsesCertificateFileContext() public function testConfigSetAsTraversable() { $config = new ArrayObject([ - 'timeout' => 400, - 'nested' => [ + 'timeout' => 400, + 'nested' => [ 'item' => 'value', ], - ]); + ], ArrayObject::ARRAY_AS_PROPS); - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); - $hasConfig = $this->_adapter->getConfig(); + $hasConfig = $this->adapter->getConfig(); $this->assertEquals($config->timeout, $hasConfig['timeout']); $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); } @@ -161,7 +163,6 @@ public function testConfigSetAsTraversable() * Check that an exception is thrown when trying to set invalid config * * @dataProvider invalidConfigProvider - * * @param mixed $config */ public function testSetConfigInvalidConfig($config) @@ -169,10 +170,11 @@ public function testSetConfigInvalidConfig($config) $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Array or Laminas\Config object expected'); - $this->_adapter->setOptions($config); + $this->adapter->setOptions($config); } - public function provideValidTimeoutConfig() + /** @psalm-return array */ + public function provideValidTimeoutConfig(): array { return [ 'integer' => [10], @@ -182,6 +184,7 @@ public function provideValidTimeoutConfig() /** * @dataProvider provideValidTimeoutConfig + * @param int|string $timeout */ public function testPassValidTimeout($timeout) { @@ -202,15 +205,14 @@ public function testThrowInvalidArgumentExceptionOnNonIntegerAndNonNumericString $adapter->connect('getlaminas.org'); } - /** - * Stream context related tests - */ + // Stream context related tests + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testGetNewStreamContext() { $adapterClass = $this->config['adapter']; - $adapter = new $adapterClass(); - $context = $adapter->getStreamContext(); + $adapter = new $adapterClass(); + $context = $adapter->getStreamContext(); $this->assertEquals('stream-context', get_resource_type($context)); } @@ -218,8 +220,8 @@ public function testGetNewStreamContext() public function testSetNewStreamContextResource() { $adapterClass = $this->config['adapter']; - $adapter = new $adapterClass(); - $context = stream_context_create(); + $adapter = new $adapterClass(); + $context = stream_context_create(); $adapter->setStreamContext($context); @@ -229,12 +231,12 @@ public function testSetNewStreamContextResource() public function testSetNewStreamContextOptions() { $adapterClass = $this->config['adapter']; - $adapter = new $adapterClass(); - $options = [ + $adapter = new $adapterClass(); + $options = [ 'socket' => [ 'bindto' => '1.2.3.4:0', ], - 'ssl' => [ + 'ssl' => [ 'capath' => null, 'verify_peer' => true, 'allow_self_signed' => false, @@ -251,7 +253,6 @@ public function testSetNewStreamContextOptions() * Test that setting invalid options / context causes an exception * * @dataProvider invalidContextProvider - * * @param mixed $invalid */ public function testSetInvalidContextOptions($invalid) @@ -260,21 +261,21 @@ public function testSetInvalidContextOptions($invalid) $this->expectExceptionMessage('Expecting either a stream context resource or array'); $adapterClass = $this->config['adapter']; - $adapter = new $adapterClass(); + $adapter = new $adapterClass(); $adapter->setStreamContext($invalid); } public function testSetHttpsStreamContextParam() { - if ($this->client->getUri()->getScheme() != 'https') { + if ($this->client->getUri()->getScheme() !== 'https') { $this->markTestSkipped(); } $adapterClass = $this->config['adapter']; - $adapter = new $adapterClass(); + $adapter = new $adapterClass(); $adapter->setStreamContext([ 'ssl' => [ - 'capture_peer_cert' => true, + 'capture_peer_cert' => true, 'capture_peer_chain' => true, ], ]); @@ -306,7 +307,7 @@ public function testExceptionOnReadTimeout() $this->assertEquals(Adapter\Exception\TimeoutException::READ_TIMEOUT, $e->getCode()); } - $time = (microtime(true) - $start); + $time = microtime(true) - $start; // We should be very close to 1 second $this->assertLessThan(2, $time); @@ -337,9 +338,9 @@ public function testMultibyteChunkedResponseLaminas6218() */ public function testAllowsZeroWrittenBytes() { - $this->_adapter->connect('localhost'); + $this->adapter->connect('localhost'); require_once __DIR__ . '/_files/fwrite.php'; - $this->_adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', [], 'test body'); + $this->adapter->write('GET', new Uri('tcp://localhost:80/'), '1.1', [], 'test body'); } /** @@ -348,8 +349,8 @@ public function testAllowsZeroWrittenBytes() */ public function testCaseInsensitiveHeaders() { - $this->_adapter->connect('localhost'); - $requestString = $this->_adapter->write( + $this->adapter->connect('localhost'); + $requestString = $this->adapter->write( 'GET', new Uri('tcp://localhost:80/'), '1.1', diff --git a/test/Client/StaticClientTest.php b/test/Client/StaticClientTest.php index d4f0542b..501a6e39 100644 --- a/test/Client/StaticClientTest.php +++ b/test/Client/StaticClientTest.php @@ -1,11 +1,5 @@ baseuri = getenv('TESTS_LAMINAS_HTTP_CLIENT_BASEURI'); - if (substr($this->baseuri, -1) != '/') { + if (substr($this->baseuri, -1) !== '/') { $this->baseuri .= '/'; } } else { @@ -158,7 +161,7 @@ public function testHttpGetUsesAdapterConfig() HTTPClient::get($testUri, [], [], null, $config); $reflectedClass = new ReflectionClass(HTTPClient::class); - $property = $reflectedClass->getProperty('client'); + $property = $reflectedClass->getProperty('client'); $property->setAccessible(true); $client = $property->getValue(); @@ -183,7 +186,7 @@ public function testHttpPostUsesAdapterConfig() HTTPClient::post($testUri, ['foo' => 'bar'], [], null, $config); $reflectedClass = new ReflectionClass(HTTPClient::class); - $property = $reflectedClass->getProperty('client'); + $property = $reflectedClass->getProperty('client'); $property->setAccessible(true); $client = $property->getValue(); diff --git a/test/Client/StaticTest.php b/test/Client/StaticTest.php index f28de459..3804bd72 100644 --- a/test/Client/StaticTest.php +++ b/test/Client/StaticTest.php @@ -1,27 +1,43 @@ 400, - 'nested' => [ + 'timeout' => 400, + 'nested' => [ 'item' => 'value', ], ]); @@ -246,15 +262,14 @@ public function testConfigSetAsTraversable() $this->_client->setOptions($config); $hasConfig = $this->_client->config; - $this->assertEquals($config->timeout, $hasConfig['timeout']); - $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); + $this->assertEquals($config['timeout'], $hasConfig['timeout']); + $this->assertEquals($config['nested']['item'], $hasConfig['nested']['item']); } /** * Test that passing invalid variables to setConfig() causes an exception * * @dataProvider invalidConfigProvider - * * @param mixed $config */ public function testConfigSetInvalid($config) @@ -384,7 +399,6 @@ public function testSocketErrorException() * the request method. * * @dataProvider invalidMethodProvider - * * @param string $method */ public function testSettingInvalidMethodThrowsException($method) @@ -432,11 +446,12 @@ public function testFormDataEncodingWithMultiArrayLaminas7038() $this->assertEquals(count($expectedLines), count($gotLines)); - while (($expected = array_shift($expectedLines)) + while ( + ($expected = array_shift($expectedLines)) && ($got = array_shift($gotLines)) ) { $expected = trim($expected); - $got = trim($got); + $got = trim($got); $this->assertMatchesRegularExpression(sprintf('/^%s$/', $expected), $got); } } @@ -489,7 +504,7 @@ public function testOpenTempStreamWithValidFileDoesntThrowsException() HTTPClient::class )); } - $url = 'http://www.example.com/'; + $url = 'http://www.example.com/'; $config = [ 'outputstream' => realpath(__DIR__ . '/_files/laminas_http_client_stream.file'), ]; @@ -511,7 +526,7 @@ public function testDownloadedFileCanBeDeleted() if (! getenv('TESTS_LAMINAS_HTTP_CLIENT_ONLINE')) { $this->markTestSkipped('Laminas\Http\Client online tests are not enabled'); } - $url = 'http://www.example.com/'; + $url = 'http://www.example.com/'; $outputFile = @tempnam(@sys_get_temp_dir(), 'zht'); if (! is_file($outputFile)) { $this->markTestSkipped('Failed to create a temporary file'); @@ -523,7 +538,7 @@ public function testDownloadedFileCanBeDeleted() $result = $client->send(); - $this->assertInstanceOf('Laminas\Http\Response\Stream', $result); + $this->assertInstanceOf(Stream::class, $result); if (DIRECTORY_SEPARATOR === '\\') { $this->assertFalse(@unlink($outputFile), 'Deleting an open file should fail on Windows'); } @@ -545,7 +560,7 @@ public function testOpenTempStreamWithBogusFileClosesTheConnection() )); } - $url = 'http://www.example.com'; + $url = 'http://www.example.com'; $config = [ 'outputstream' => '/path/to/bogus/file.ext', ]; diff --git a/test/Client/TestAdapterTest.php b/test/Client/TestAdapterTest.php index d96abc9d..33d011d4 100644 --- a/test/Client/TestAdapterTest.php +++ b/test/Client/TestAdapterTest.php @@ -1,13 +1,8 @@ adapter->setResponseIndex($i); $this->fail(); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertInstanceOf(OutOfRangeException::class, $e); $this->assertMatchesRegularExpression('/out of range/i', $e->getMessage()); } diff --git a/test/Client/TestAsset/MockAdapter.php b/test/Client/TestAsset/MockAdapter.php index 0656bfad..a56d9523 100644 --- a/test/Client/TestAsset/MockAdapter.php +++ b/test/Client/TestAsset/MockAdapter.php @@ -1,16 +1,11 @@ */ public $config = [ 'maxredirects' => 5, 'strictredirects' => false, diff --git a/test/Client/UseCaseTest.php b/test/Client/UseCaseTest.php index a73c4e81..3f1736f1 100644 --- a/test/Client/UseCaseTest.php +++ b/test/Client/UseCaseTest.php @@ -1,19 +1,19 @@ baseuri = getenv('TESTS_LAMINAS_HTTP_CLIENT_BASEURI'); $this->client = new HTTPClient($this->baseuri); @@ -95,7 +96,7 @@ public function testStaticHttpGet() public function testRequestHttpGet() { - $client = new HTTPClient(); + $client = new HTTPClient(); $request = new Request(); $request->setUri($this->baseuri); $request->setMethod(Request::METHOD_GET); diff --git a/test/Client/_files/Laminas7683-chunked.php b/test/Client/_files/Laminas7683-chunked.php index 012c13ac..ef9a87fe 100644 --- a/test/Client/_files/Laminas7683-chunked.php +++ b/test/Client/_files/Laminas7683-chunked.php @@ -1,11 +1,5 @@ $file) { if (is_array($file['name'])) { diff --git a/test/ClientTest.php b/test/ClientTest.php index 0d47a8c3..21dd8770 100644 --- a/test/ClientTest.php +++ b/test/ClientTest.php @@ -1,10 +1,4 @@ -setRequest($request); $client->addCookie($initialCookies); - $cookies = new Cookies($client->getRequest()->getHeaders()); + $cookies = new Cookies($client->getRequest()->getHeaders()); $rawHeaders = 'HTTP/1.1 200 OK' . "\r\n" . 'Access-Control-Allow-Origin: *' . "\r\n" . 'Content-Encoding: gzip' . "\r\n" @@ -62,7 +66,7 @@ public function testIfCookiesAreSticky() . 'Vary: Accept-Encoding' . "\r\n" . 'X-Powered-By: PHP/5.3.10-1ubuntu3.4' . "\r\n" . 'Connection: keep-alive' . "\r\n"; - $response = Response::fromString($rawHeaders); + $response = Response::fromString($rawHeaders); $client->setResponse($response); $cookies->addCookiesFromResponse($client->getResponse(), $client->getUri()); @@ -91,7 +95,7 @@ public function testAcceptEncodingHeaderWorksProperly() . 'Accept-Language: en-US,en;q=0.5' . "\r\n" . 'Accept-Encoding: gzip, deflate' . "\r\n" . 'Connection: keep-alive' . "\r\n"; - $request = Request::fromString($requestString); + $request = Request::fromString($requestString); $adapter = new Test(); @@ -108,7 +112,7 @@ public function testAcceptEncodingHeaderWorksProperly() . 'Vary: Accept-Encoding' . "\r\n" . 'X-Powered-By: PHP/5.3.10-1ubuntu3.4' . "\r\n" . 'Connection: keep-alive' . "\r\n"; - $response = Response::fromString($rawHeaders); + $response = Response::fromString($rawHeaders); $client->getAdapter()->setResponse($response); $headers = $method->invoke($client, $requestString, $client->getUri()); @@ -177,7 +181,7 @@ public function testIfArrayIteratorOfHeadersCanBeSet() public function testArgSeparatorDefaultsToIniSetting() { $argSeparator = ini_get('arg_separator.output'); - $client = new Client(); + $client = new Client(); $this->assertEquals($argSeparator, $client->getArgSeparator()); } @@ -255,8 +259,8 @@ public function testIfMaxredirectWorksCorrectly() // create a client which allows one redirect at most! $client = new Client('http://www.example.org/part1', [ - 'adapter' => $testAdapter, - 'maxredirects' => 1, + 'adapter' => $testAdapter, + 'maxredirects' => 1, 'storeresponse' => true, ]); @@ -271,9 +275,9 @@ public function testIfMaxredirectWorksCorrectly() public function testIfClientDoesNotLooseAuthenticationOnRedirect() { // set up user credentials - $user = 'username123'; + $user = 'username123'; $password = 'password456'; - $encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC); + $encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC); // set up two responses that simulate a redirection $testAdapter = new Test(); @@ -289,7 +293,7 @@ public function testIfClientDoesNotLooseAuthenticationOnRedirect() // create client with HTTP basic authentication $client = new Client('http://www.example.org/part1', [ - 'adapter' => $testAdapter, + 'adapter' => $testAdapter, 'maxredirects' => 1, ]); $client->setAuth($user, $password, Client::AUTH_BASIC); @@ -304,12 +308,12 @@ public function testIfClientDoesNotLooseAuthenticationOnRedirect() public function testIfClientDoesNotForwardAuthenticationToForeignHost() { // set up user credentials - $user = 'username123'; + $user = 'username123'; $password = 'password456'; - $encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC); + $encoded = Client::encodeAuthHeader($user, $password, Client::AUTH_BASIC); $testAdapter = new Test(); - $client = new Client(null, ['adapter' => $testAdapter]); + $client = new Client(null, ['adapter' => $testAdapter]); // set up two responses that simulate a redirection from example.org to example.com $testAdapter->setResponse( @@ -375,7 +379,7 @@ public function testIfClientDoesNotForwardAuthenticationToForeignHost() public function testAdapterAlwaysReachableIfSpecified() { $testAdapter = new Test(); - $client = new Client('http://www.example.org/', [ + $client = new Client('http://www.example.org/', [ 'adapter' => $testAdapter, ]); @@ -386,7 +390,7 @@ public function testPrepareHeadersCreateRightHttpField() { $body = json_encode(['foofoo' => 'barbar']); - $client = new Client(); + $client = new Client(); $prepareHeadersReflection = new ReflectionMethod($client, 'prepareHeaders'); $prepareHeadersReflection->setAccessible(true); @@ -412,7 +416,7 @@ public function testPrepareHeadersCurlDigestAuthentication() { $body = json_encode(['foofoo' => 'barbar']); - $client = new Client(); + $client = new Client(); $prepareHeadersReflection = new ReflectionMethod($client, 'prepareHeaders'); $prepareHeadersReflection->setAccessible(true); @@ -533,10 +537,11 @@ public function testFormUrlEncodeSeparator() $this->assertStringContainsString('foo=bar&baz=foo', $rawRequest); } - public function uriDataProvider() + /** @psalm-return array */ + public function uriDataProvider(): array { return [ - 'valid-relative' => ['/example', true], + 'valid-relative' => ['/example', true], 'invalid-absolute' => ['http://localhost/example', false], ]; } @@ -544,8 +549,10 @@ public function uriDataProvider() /** * @dataProvider uriDataProvider */ - public function testUriCorrectlyDeterminesWhetherOrNotItIsAValidRelativeUri($uri, $isValidRelativeURI) - { + public function testUriCorrectlyDeterminesWhetherOrNotItIsAValidRelativeUri( + string $uri, + bool $isValidRelativeURI + ): void { $client = new Client($uri); $this->assertSame($isValidRelativeURI, $client->getUri()->isValidRelative()); @@ -554,19 +561,22 @@ public function testUriCorrectlyDeterminesWhetherOrNotItIsAValidRelativeUri($uri $this->assertSame($isValidRelativeURI, $client->getUri()->isValidRelative()); } - public function portChangeDataProvider() + /** @psalm-return array */ + public function portChangeDataProvider(): array { return [ 'default-https' => ['https://localhost/example', 443], - 'default-http' => ['http://localhost/example', 80] + 'default-http' => ['http://localhost/example', 80], ]; } /** * @dataProvider portChangeDataProvider */ - public function testUriPortIsSetToAppropriateDefaultValueWhenAnUriOmittingThePortIsProvided($absoluteURI, $port) - { + public function testUriPortIsSetToAppropriateDefaultValueWhenAnUriOmittingThePortIsProvided( + string $absoluteURI, + int $port + ): void { $client = new Client(); $client->getUri()->setPort(null); @@ -588,13 +598,15 @@ public function testUriPortIsNotSetWhenUriIsRelative() $this->assertNull($client->getUri()->getPort()); } - public function cookies() + /** @psalm-return iterable|SetCookie[]}> */ + public function cookies(): iterable { yield 'name-value' => [['cookie-name' => 'cookie-value']]; yield 'SetCookie' => [[new SetCookie('cookie-name', 'cookie-value')]]; } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider cookies */ public function testSetCookies(array $cookies) diff --git a/test/CookiesTest.php b/test/CookiesTest.php index 308c6159..b4b81426 100644 --- a/test/CookiesTest.php +++ b/test/CookiesTest.php @@ -1,11 +1,5 @@ setDomain('www.zend.com'); $header->setPath('/'); $headers->addHeader($header); @@ -34,8 +28,8 @@ public function testFromResponseInSetCookie() public function testFromResponseInCookie() { $response = new Response(); - $headers = new Headers(); - $header = new SetCookie('foo', 'bar'); + $headers = new Headers(); + $header = new SetCookie('foo', 'bar'); $header->setDomain('www.zend.com'); $header->setPath('/'); $headers->addHeader($header); @@ -47,17 +41,17 @@ public function testFromResponseInCookie() public function testRequestCanHaveArrayCookies() { - $_COOKIE = [ + $_COOKIE = [ 'test' => [ 'a' => 'value_a', 'b' => 'value_b', ], ]; - $request = new Request(); + $request = new Request(); $fieldValue = $request->getCookie('test')->getFieldValue(); $this->assertSame('test[a]=value_a; test[b]=value_b', $fieldValue); - $_COOKIE = [ + $_COOKIE = [ 'test' => [ 'a' => [ 'a1' => 'va1', @@ -69,7 +63,7 @@ public function testRequestCanHaveArrayCookies() ], ], ]; - $request = new Request(); + $request = new Request(); $fieldValue = $request->getCookie('test')->getFieldValue(); $this->assertSame('test[a][a1]=va1; test[a][a2]=va2; test[b][b1]=vb1; test[b][b2]=vb2', $fieldValue); } diff --git a/test/Header/AcceptCharsetTest.php b/test/Header/AcceptCharsetTest.php index 50cbedcb..47f05a66 100644 --- a/test/Header/AcceptCharsetTest.php +++ b/test/Header/AcceptCharsetTest.php @@ -1,11 +1,5 @@ assertEquals('Accept-Charset: iso-8859-5;q=0.8, unicode-1-1', $acceptCharsetHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testCanParseCommaSeparatedValues() { $header = AcceptCharset::fromString('Accept-Charset: iso-8859-5;q=0.8,unicode-1-1'); @@ -91,6 +88,7 @@ public function testWildcharCharset() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -101,6 +99,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaSetters() diff --git a/test/Header/AcceptEncodingTest.php b/test/Header/AcceptEncodingTest.php index 638077e0..5b9dac1b 100644 --- a/test/Header/AcceptEncodingTest.php +++ b/test/Header/AcceptEncodingTest.php @@ -1,11 +1,5 @@ assertEquals('Accept-Encoding: compress;q=0.5, gzip', $acceptEncodingHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testCanParseCommaSeparatedValues() { $header = AcceptEncoding::fromString('Accept-Encoding: compress;q=0.5,gzip'); @@ -92,6 +89,7 @@ public function testWildcharEncoder() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -102,6 +100,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaSetters() diff --git a/test/Header/AcceptLanguageTest.php b/test/Header/AcceptLanguageTest.php index e8c8e4ee..42485d55 100644 --- a/test/Header/AcceptLanguageTest.php +++ b/test/Header/AcceptLanguageTest.php @@ -1,11 +1,5 @@ assertEquals('Accept-Language: da;q=0.8, en-gb', $acceptLanguageHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testCanParseCommaSeparatedValues() { $header = AcceptLanguage::fromString('Accept-Language: da;q=0.8, en-gb'); @@ -94,7 +91,7 @@ public function testWildcharLanguage() public function testWildcards() { $accept = AcceptLanguage::fromString('*, en-*, en-us'); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('en-us', $res[0]->getLanguage()); $this->assertEquals('en', $res[0]->getPrimaryTag()); @@ -108,6 +105,7 @@ public function testWildcards() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -118,6 +116,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaSetters() diff --git a/test/Header/AcceptRangesTest.php b/test/Header/AcceptRangesTest.php index ff75fa5f..9245287d 100644 --- a/test/Header/AcceptRangesTest.php +++ b/test/Header/AcceptRangesTest.php @@ -1,11 +1,5 @@ addMediaType('\\', 0.9); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testCanParseCommaSeparatedValues() { $header = Accept::fromString('Accept: text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c'); @@ -192,7 +190,7 @@ public function testMatchWildCard() public function testParsingAndAssemblingQuotedStrings() { - $acceptStr = 'Accept: application/vnd.foobar+html;q=1;version="2' + $acceptStr = 'Accept: application/vnd.foobar+html;q=1;version="2' . '\"";level="foo;, bar", text/json;level=1, text/xml;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); @@ -201,7 +199,7 @@ public function testParsingAndAssemblingQuotedStrings() public function testMatchReturnsMatchedAgainstObject() { - $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; + $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); $res = $acceptHeader->match('text/html; _randomValue=foobar'); @@ -211,7 +209,7 @@ public function testMatchReturnsMatchedAgainstObject() $res->getMatchedAgainst()->getParams()->_randomValue ); - $acceptStr = 'Accept: */*; '; + $acceptStr = 'Accept: */*; '; $acceptHeader = Accept::fromString($acceptStr); $res = $acceptHeader->match('text/html; _foo=bar'); @@ -225,7 +223,7 @@ public function testMatchReturnsMatchedAgainstObject() public function testVersioning() { - $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; + $acceptStr = 'Accept: text/html;q=1; version=23; level=5, text/json;level=1,text/xml;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); $expected = [ @@ -273,7 +271,7 @@ public function testWildcardWithDifferentParamsAndRanges() $this->assertFalse($acceptHeader->match('*/*; version=20-22')); $acceptHeader = Accept::fromString('Accept: */*; version=21'); - $res = $acceptHeader->match('*/*; version=20-22'); + $res = $acceptHeader->match('*/*; version=20-22'); $this->assertInstanceOf(AcceptFieldValuePart::class, $res); $this->assertEquals('21', $res->getParams()->version); } @@ -292,9 +290,7 @@ public function testParamRangesWithDecimals() * @group 3740 * @covers Laminas\Http\Header\AbstractAccept::matchAcceptParams() * @covers Laminas\Http\Header\AbstractAccept::getParametersFromFieldValuePart() - * * @dataProvider provideParamRanges - * * @param string $range * @param string $input * @param bool $success @@ -338,7 +334,7 @@ public function provideParamRanges() public function testVersioningAndPriorization() { - $acceptStr = 'Accept: text/html; version=23, text/json; version=15.3; q=0.9,text/html;level=2;q=0.4'; + $acceptStr = 'Accept: text/html; version=23, text/json; version=15.3; q=0.9,text/html;level=2;q=0.4'; $acceptHeader = Accept::fromString($acceptStr); $expected = [ @@ -407,27 +403,27 @@ public function testPrioritizing() public function testPrioritizing2() { $accept = Accept::fromString("Accept: application/text, \tapplication/*"); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('application/text', $res[0]->raw); $this->assertEquals('application/*', $res[1]->raw); $accept = Accept::fromString("Accept: \tapplication/*, application/text"); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('application/text', $res[0]->raw); $this->assertEquals('application/*', $res[1]->raw); $accept = Accept::fromString('Accept: text/xml, application/xml'); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('application/xml', $res[0]->raw); $this->assertEquals('text/xml', $res[1]->raw); $accept = Accept::fromString('Accept: application/xml, text/xml'); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('application/xml', $res[0]->raw); $this->assertEquals('text/xml', $res[1]->raw); $accept = Accept::fromString('Accept: application/vnd.foobar+xml; q=0.9, text/xml'); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals(1.0, $res[0]->getPriority()); $this->assertEquals(0.9, $res[1]->getPriority()); $this->assertEquals('application/vnd.foobar+xml', $res[1]->getTypeString()); @@ -436,7 +432,7 @@ public function testPrioritizing2() $this->assertEquals('xml', $res[1]->getFormat()); $accept = Accept::fromString('Accept: text/xml, application/vnd.foobar+xml; version="\'ัพ"'); - $res = $accept->getPrioritized(); + $res = $accept->getPrioritized(); $this->assertEquals('application/vnd.foobar+xml; version="\'ัพ"', $res[0]->getRaw()); } @@ -461,6 +457,7 @@ public function testWildcardDefaults() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() diff --git a/test/Header/AgeTest.php b/test/Header/AgeTest.php index 2acc184a..924fd3df 100644 --- a/test/Header/AgeTest.php +++ b/test/Header/AgeTest.php @@ -1,11 +1,5 @@ false, 'GET' => true, 'HEAD' => false, @@ -87,6 +81,7 @@ public function testAllowChecksAllowedMethod() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -97,20 +92,20 @@ public function testPreventsCRLFAttackViaFromString() Allow::fromString("Allow: GET\r\n\r\nevilContent"); } - public function injectionMethods() + /** @psalm-return array */ + public function injectionMethods(): array { return [ 'string' => ["\rG\r\nE\nT"], - 'array' => [["\rG\r\nE\nT"]], + 'array' => [["\rG\r\nE\nT"]], ]; } /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * @group ZF2015-04 * + * @group ZF2015-04 * @dataProvider injectionMethods - * * @param array|string $methods */ public function testPreventsCRLFAttackViaAllowMethods($methods) @@ -124,10 +119,9 @@ public function testPreventsCRLFAttackViaAllowMethods($methods) /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * @group ZF2015-04 * + * @group ZF2015-04 * @dataProvider injectionMethods - * * @param array|string $methods */ public function testPreventsCRLFAttackViaDisallowMethods($methods) diff --git a/test/Header/AuthenticationInfoTest.php b/test/Header/AuthenticationInfoTest.php index e9fb7194..9575b629 100644 --- a/test/Header/AuthenticationInfoTest.php +++ b/test/Header/AuthenticationInfoTest.php @@ -1,11 +1,5 @@ assertEmpty('Cache-Control: xxx', $cacheControlHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testCacheControlIsEmpty() { $cacheControlHeader = new CacheControl(); @@ -103,6 +98,7 @@ public function testCacheControlParse() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -113,6 +109,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testProtectsFromCRLFAttackViaSetters() diff --git a/test/Header/ConnectionTest.php b/test/Header/ConnectionTest.php index 27b0077c..24257a3b 100644 --- a/test/Header/ConnectionTest.php +++ b/test/Header/ConnectionTest.php @@ -1,11 +1,5 @@ assertEquals('Content-Location: http://www.example.com/path?query', $contentLocationHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testContentLocationCanSetAndAccessAbsoluteUri() { $contentLocationHeader = ContentLocation::fromString('Content-Location: http://www.example.com/path'); - $uri = $contentLocationHeader->uri(); + $uri = $contentLocationHeader->uri(); $this->assertInstanceOf(UriInterface::class, $uri); $this->assertTrue($uri->isAbsolute()); $this->assertEquals('http://www.example.com/path', $contentLocationHeader->getUri()); @@ -55,7 +50,7 @@ public function testContentLocationCanSetAndAccessAbsoluteUri() public function testContentLocationCanSetAndAccessRelativeUri() { $contentLocationHeader = ContentLocation::fromString('Content-Location: /path/to'); - $uri = $contentLocationHeader->uri(); + $uri = $contentLocationHeader->uri(); $this->assertInstanceOf(UriInterface::class, $uri); $this->assertFalse($uri->isAbsolute()); $this->assertEquals('/path/to', $contentLocationHeader->getUri()); @@ -63,6 +58,7 @@ public function testContentLocationCanSetAndAccessRelativeUri() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() diff --git a/test/Header/ContentMD5Test.php b/test/Header/ContentMD5Test.php index 1f8b60a0..02bd681f 100644 --- a/test/Header/ContentMD5Test.php +++ b/test/Header/ContentMD5Test.php @@ -1,10 +1,4 @@ - */ + public static function validDirectives(): array { return [ - ['child-src', ["'self'"],"Content-Security-Policy: child-src 'self';"], + ['child-src', ["'self'"], "Content-Security-Policy: child-src 'self';"], ['manifest-src', ["'self'"], "Content-Security-Policy: manifest-src 'self';"], ['worker-src', ["'self'"], "Content-Security-Policy: worker-src 'self';"], ['prefetch-src', ["'self'"], "Content-Security-Policy: prefetch-src 'self';"], @@ -205,12 +204,12 @@ public static function validDirectives() [ 'form-action', ['http://*.example.com', "'self'"], - "Content-Security-Policy: form-action http://*.example.com 'self';" + "Content-Security-Policy: form-action http://*.example.com 'self';", ], [ 'frame-ancestors', ['http://*.example.com', "'self'"], - "Content-Security-Policy: frame-ancestors http://*.example.com 'self';" + "Content-Security-Policy: frame-ancestors http://*.example.com 'self';", ], ['navigate-to', ['example.com'], 'Content-Security-Policy: navigate-to example.com;'], ['sandbox', ['allow-forms'], 'Content-Security-Policy: sandbox allow-forms;'], @@ -225,7 +224,6 @@ public static function validDirectives() /** * @dataProvider validDirectives - * * @param string $directive * @param string[] $values * @param string $expected @@ -243,7 +241,6 @@ public function testContentSecurityPolicySetDirectiveThrowsExceptionIfMissingDir /** * @dataProvider validDirectives - * * @param string $directive * @param string[] $values * @param string $header @@ -267,7 +264,6 @@ public function directivesWithoutValue() /** * @dataProvider directivesWithoutValue - * * @param string $directive */ public function testExceptionWhenProvideValueWithDirectiveWithoutValue($directive) diff --git a/test/Header/ContentTransferEncodingTest.php b/test/Header/ContentTransferEncodingTest.php index 5e5d45d6..8aa9f154 100644 --- a/test/Header/ContentTransferEncodingTest.php +++ b/test/Header/ContentTransferEncodingTest.php @@ -1,11 +1,5 @@ assertEquals('Content-Type: application/atom+xml; charset=ISO-8859-1', $header->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here - public function wildcardMatches() + /** @psalm-return array */ + public function wildcardMatches(): array { return [ - 'wildcard' => ['*/*'], - 'wildcard-format' => ['*/*+*'], - 'wildcard-type-subtype-fixed-format' => ['*/*+json'], + 'wildcard' => ['*/*'], + 'wildcard-format' => ['*/*+*'], + 'wildcard-type-subtype-fixed-format' => ['*/*+json'], 'wildcard-type-partial-wildcard-subtype-fixed-format' => ['*/vnd.*+json'], - 'wildcard-type-format-subtype' => ['*/json'], - 'fixed-type-wildcard-subtype' => ['application/*'], - 'fixed-type-wildcard-subtype-fixed-format' => ['application/*+json'], - 'fixed-type-format-subtype' => ['application/json'], - 'fixed-type-fixed-subtype-wildcard-format' => ['application/vnd.foobar+*'], - 'fixed-type-partial-wildcard-subtype-fixed-format' => ['application/vnd.*+json'], - 'fixed' => ['application/vnd.foobar+json'], - 'fixed-mixed-case' => ['APPLICATION/vnd.FooBar+json'], + 'wildcard-type-format-subtype' => ['*/json'], + 'fixed-type-wildcard-subtype' => ['application/*'], + 'fixed-type-wildcard-subtype-fixed-format' => ['application/*+json'], + 'fixed-type-format-subtype' => ['application/json'], + 'fixed-type-fixed-subtype-wildcard-format' => ['application/vnd.foobar+*'], + 'fixed-type-partial-wildcard-subtype-fixed-format' => ['application/vnd.*+json'], + 'fixed' => ['application/vnd.foobar+json'], + 'fixed-mixed-case' => ['APPLICATION/vnd.FooBar+json'], ]; } /** * @dataProvider wildcardMatches - * * @param string $matchAgainst */ public function testMatchWildCard($matchAgainst) @@ -75,22 +72,22 @@ public function testMatchWildCard($matchAgainst) $this->assertEquals(strtolower($matchAgainst), $result); } - public function invalidMatches() + /** @psalm-return array */ + public function invalidMatches(): array { return [ - 'format' => ['application/vnd.foobar+xml'], - 'wildcard-subtype' => ['application/vendor.*+json'], - 'subtype' => ['application/vendor.foobar+json'], - 'type' => ['text/vnd.foobar+json'], - 'wildcard-type-format' => ['*/vnd.foobar+xml'], + 'format' => ['application/vnd.foobar+xml'], + 'wildcard-subtype' => ['application/vendor.*+json'], + 'subtype' => ['application/vendor.foobar+json'], + 'type' => ['text/vnd.foobar+json'], + 'wildcard-type-format' => ['*/vnd.foobar+xml'], 'wildcard-type-wildcard-subtype' => ['*/vendor.*+json'], - 'wildcard-type-subtype' => ['*/vendor.foobar+json'], + 'wildcard-type-subtype' => ['*/vendor.foobar+json'], ]; } /** * @dataProvider invalidMatches - * * @param string $matchAgainst */ public function testFailedMatches($matchAgainst) @@ -100,7 +97,8 @@ public function testFailedMatches($matchAgainst) $this->assertFalse($result); } - public function multipleCriteria() + /** @psalm-return array */ + public function multipleCriteria(): array { $criteria = [ 'application/vnd.foobar+xml', @@ -109,14 +107,13 @@ public function multipleCriteria() '*/vnd.foobar+json', ]; return [ - 'array' => [$criteria], + 'array' => [$criteria], 'string' => [implode(',', $criteria)], ]; } /** * @dataProvider multipleCriteria - * * @param array|string $criteria */ public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate($criteria) @@ -126,19 +123,19 @@ public function testReturnsMatchingMediaTypeOfFirstCriteriaToValidate($criteria) $this->assertEquals('application/vnd.*+json', $result); } - public function contentTypeParameterExamples() + /** @psalm-return array */ + public function contentTypeParameterExamples(): array { return [ - 'no-quotes' => ['Content-Type: foo/bar; param=baz', 'baz'], - 'with-quotes' => ['Content-Type: foo/bar; param="baz"', 'baz'], - 'with-equals' => ['Content-Type: foo/bar; param=baz=bat', 'baz=bat'], + 'no-quotes' => ['Content-Type: foo/bar; param=baz', 'baz'], + 'with-quotes' => ['Content-Type: foo/bar; param="baz"', 'baz'], + 'with-equals' => ['Content-Type: foo/bar; param=baz=bat', 'baz=bat'], 'with-equals-and-quotes' => ['Content-Type: foo/bar; param="baz=bat"', 'baz=bat'], ]; } /** * @dataProvider contentTypeParameterExamples - * * @param string $headerString * @param string $expectedParameterValue */ @@ -154,6 +151,7 @@ public function testContentTypeParsesParametersCorrectly($headerString, $expecte /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -164,6 +162,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaConstructor() diff --git a/test/Header/CookieTest.php b/test/Header/CookieTest.php index b841cb38..f0d9c598 100644 --- a/test/Header/CookieTest.php +++ b/test/Header/CookieTest.php @@ -1,11 +1,5 @@ foo = 'bar'; $this->assertEquals('foo=bar', $cookieHeader->getFieldValue()); } @@ -72,6 +66,7 @@ public function testCookieToStringReturnsHeaderFormattedString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -82,10 +77,9 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * @group ZF2015-04 * + * @group ZF2015-04 * @dataProvider valuesProvider - * * @param mixed $value * @param string $serialized */ @@ -95,7 +89,8 @@ public function testSerialization($value, $serialized) $this->assertEquals('Cookie: ' . $serialized, $header->toString()); } - public function valuesProvider() + /** @psalm-return array */ + public function valuesProvider(): array { return [ // Description => [raw value, serialized] diff --git a/test/Header/DateTest.php b/test/Header/DateTest.php index 715de858..b4a42533 100644 --- a/test/Header/DateTest.php +++ b/test/Header/DateTest.php @@ -1,11 +1,5 @@ assertEquals('Date: Sun, 06 Nov 1994 08:49:37 GMT', $dateHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testDateReturnsDateTimeObject() { $dateHeader = new Date(); @@ -151,6 +150,7 @@ public function testDateCanOutputDatesInOldFormats() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() diff --git a/test/Header/EtagTest.php b/test/Header/EtagTest.php index 712fb10b..e0db99a3 100644 --- a/test/Header/EtagTest.php +++ b/test/Header/EtagTest.php @@ -1,11 +1,5 @@ assertInstanceOf(FeaturePolicy::class, $header); $directives = [ 'geolocation' => "'none'", - 'autoplay' => "'self'", - 'microphone' => "'self'", + 'autoplay' => "'self'", + 'microphone' => "'self'", ]; $this->assertEquals($directives, $header->getDirectives()); } @@ -95,6 +89,7 @@ public function testFeaturePolicyGetFieldValueReturnsProperValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -105,6 +100,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaDirective() diff --git a/test/Header/FromTest.php b/test/Header/FromTest.php index 0ec86f30..bd927f74 100644 --- a/test/Header/FromTest.php +++ b/test/Header/FromTest.php @@ -1,11 +1,5 @@ */ - public function getFilterValues() + public function getFilterValues(): array { return [ ["This is a\n test", 'This is a test'], @@ -36,9 +32,7 @@ public function getFilterValues() /** * @group ZF2015-04 - * * @dataProvider getFilterValues - * * @param string $value * @param string $expected */ @@ -47,7 +41,8 @@ public function testFiltersValuesPerRfc7230($value, $expected) $this->assertEquals($expected, HeaderValue::filter($value)); } - public function validateValues() + /** @psalm-return array */ + public function validateValues(): array { return [ ["This is a\n test", 'assertFalse'], @@ -66,9 +61,7 @@ public function validateValues() /** * @group ZF2015-04 - * * @dataProvider validateValues - * * @param string $value * @param string $assertion */ @@ -77,7 +70,8 @@ public function testValidatesValuesPerRfc7230($value, $assertion) $this->{$assertion}(HeaderValue::isValid($value)); } - public function assertValues() + /** @psalm-return array */ + public function assertValues(): array { return [ ["This is a\n test"], @@ -95,9 +89,7 @@ public function assertValues() /** * @group ZF2015-04 - * * @dataProvider assertValues - * * @param string $value */ public function testAssertValidRaisesExceptionForInvalidValue($value) diff --git a/test/Header/HostTest.php b/test/Header/HostTest.php index fa581ad9..1f66d2b4 100644 --- a/test/Header/HostTest.php +++ b/test/Header/HostTest.php @@ -1,11 +1,5 @@ assertInstanceOf(Location::class, $locationHeader); } - public function locationFromStringCreatesValidLocationHeaderProvider() + /** @psalm-return array */ + public function locationFromStringCreatesValidLocationHeaderProvider(): array { return [ ['http://www.example.com'], @@ -46,7 +40,6 @@ public function locationFromStringCreatesValidLocationHeaderProvider() * Test that we can set a redirect to different URI-Schemes * * @dataProvider locationCanSetDifferentSchemeUrisProvider - * * @param string $uri * @param string $expectedClass */ @@ -61,13 +54,12 @@ public function testLocationCanSetDifferentSchemeUris($uri, $expectedClass) * Test that we can set a redirect to different URI-schemes via a class * * @dataProvider locationCanSetDifferentSchemeUrisProvider - * * @param string $uri * @param string $expectedClass */ public function testLocationCanSetDifferentSchemeUriObjects($uri, $expectedClass) { - $uri = UriFactory::factory($uri); + $uri = UriFactory::factory($uri); $locationHeader = new Location(); $locationHeader->setUri($uri); $this->assertInstanceOf($expectedClass, $locationHeader->uri()); @@ -106,12 +98,13 @@ public function testLocationToStringReturnsHeaderFormattedString() $this->assertEquals('Location: http://www.example.com/path?query', $locationHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testLocationCanSetAndAccessAbsoluteUri() { $locationHeader = Location::fromString('Location: http://www.example.com/path'); - $uri = $locationHeader->uri(); + $uri = $locationHeader->uri(); $this->assertInstanceOf(Http::class, $uri); $this->assertTrue($uri->isAbsolute()); $this->assertEquals('http://www.example.com/path', $locationHeader->getUri()); @@ -120,7 +113,7 @@ public function testLocationCanSetAndAccessAbsoluteUri() public function testLocationCanSetAndAccessRelativeUri() { $locationHeader = Location::fromString('Location: /path/to'); - $uri = $locationHeader->uri(); + $uri = $locationHeader->uri(); $this->assertInstanceOf(Uri::class, $uri); $this->assertFalse($uri->isAbsolute()); $this->assertEquals('/path/to', $locationHeader->getUri()); @@ -128,6 +121,7 @@ public function testLocationCanSetAndAccessRelativeUri() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testCRLFAttack() diff --git a/test/Header/MaxForwardsTest.php b/test/Header/MaxForwardsTest.php index 09c0af4f..1113afea 100644 --- a/test/Header/MaxForwardsTest.php +++ b/test/Header/MaxForwardsTest.php @@ -1,11 +1,5 @@ assertEquals('Referer: http://www.example.com/path?query', $refererHeader->toString()); } - /** Implementation specific tests here */ + // Implementation specific tests here + // phpcs:ignore Squiz.Commenting.FunctionComment.WrongStyle public function testRefererCanSetAndAccessAbsoluteUri() { $refererHeader = Referer::fromString('Referer: http://www.example.com/path'); - $uri = $refererHeader->uri(); + $uri = $refererHeader->uri(); $this->assertInstanceOf(Http::class, $uri); $this->assertTrue($uri->isAbsolute()); $this->assertEquals('http://www.example.com/path', $refererHeader->getUri()); @@ -58,7 +53,7 @@ public function testRefererCanSetAndAccessAbsoluteUri() public function testRefererCanSetAndAccessRelativeUri() { $refererHeader = Referer::fromString('Referer: /path/to'); - $uri = $refererHeader->uri(); + $uri = $refererHeader->uri(); $this->assertInstanceOf(Uri::class, $uri); $this->assertFalse($uri->isAbsolute()); $this->assertEquals('/path/to', $refererHeader->getUri()); @@ -73,6 +68,7 @@ public function testRefererDoesNotHaveUriFragment() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testCRLFAttack() diff --git a/test/Header/RefreshTest.php b/test/Header/RefreshTest.php index f58d9bac..52856d0c 100644 --- a/test/Header/RefreshTest.php +++ b/test/Header/RefreshTest.php @@ -1,11 +1,5 @@ assertEquals('Wed, 13-Jan-2021 22:23:01 GMT', $setCookieHeader->getExpires()); $this->assertTrue($setCookieHeader->isSecure()); $this->assertTrue($setCookieHeader->isHttponly()); - $this->assertEquals(setCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); + $this->assertEquals(SetCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); $setCookieHeader = SetCookie::fromString( 'set-cookie: myname=myvalue; Domain=docs.foo.com; Path=/accounts;' @@ -227,7 +229,7 @@ public function testSetCookieFromStringCanCreateSingleHeader() $this->assertEquals('Wed, 13-Jan-2021 22:23:01 GMT', $setCookieHeader->getExpires()); $this->assertTrue($setCookieHeader->isSecure()); $this->assertTrue($setCookieHeader->isHttponly()); - $this->assertEquals(setCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); + $this->assertEquals(SetCookie::SAME_SITE_STRICT, $setCookieHeader->getSameSite()); } public function testFieldValueWithSameSiteCaseInsensitive() @@ -351,14 +353,14 @@ public function testSetCookieCanAppendOtherHeadersInWhenCreatingString() $setCookieHeader->setHttponly(true); $appendCookie = new SetCookie('othername', 'othervalue'); - $headerLine = $setCookieHeader->toStringMultipleHeaders([$appendCookie]); + $headerLine = $setCookieHeader->toStringMultipleHeaders([$appendCookie]); $target = 'Set-Cookie: myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT;' . ' Domain=docs.foo.com; Path=/accounts;' . ' Secure; HttpOnly, othername=othervalue'; $this->assertNotEquals($target, $headerLine); - $target = 'Set-Cookie: myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT;' + $target = 'Set-Cookie: myname=myvalue; Expires=Wed, 13-Jan-2021 22:23:01 GMT;' . ' Domain=docs.foo.com; Path=/accounts;' . ' Secure; HttpOnly'; $target .= "\n"; @@ -528,7 +530,6 @@ public function testGetFieldName() /** * @dataProvider validCookieWithInfoProvider - * * @param string $cStr * @param array $info * @param string $expected @@ -545,7 +546,6 @@ public function testGetFieldValue($cStr, array $info, $expected) /** * @dataProvider validCookieWithInfoProvider - * * @param string $cStr * @param array $info * @param string $expected @@ -561,10 +561,10 @@ public function testToString($cStr, array $info, $expected) public function testRfcCompatibility() { - $name = 'myname'; - $value = 'myvalue'; + $name = 'myname'; + $value = 'myvalue'; $formatUnquoted = '%s: %s=%s'; - $formatQuoted = '%s: %s="%s"'; + $formatQuoted = '%s: %s="%s"'; $cookie = new SetCookie($name, $value); @@ -583,7 +583,7 @@ public function testRfcCompatibility() public function testSetJsonValue() { $cookieName = 'fooCookie'; - $jsonData = json_encode(['foo' => 'bar']); + $jsonData = json_encode(['foo' => 'bar']); $cookie = new SetCookie($cookieName, $jsonData); @@ -591,7 +591,7 @@ public function testSetJsonValue() $this->assertMatchesRegularExpression($regExp, $cookie->getFieldValue()); $cookieName = 'fooCookie'; - $jsonData = json_encode(['foo' => 'bar']); + $jsonData = json_encode(['foo' => 'bar']); $cookie = new SetCookie($cookieName, $jsonData); $cookie->setDomain('example.org'); @@ -602,6 +602,7 @@ public function testSetJsonValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaFromString() @@ -612,6 +613,7 @@ public function testPreventsCRLFAttackViaFromString() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaConstructor() @@ -646,7 +648,8 @@ public function testSetCookieWithNoEncodeValue() $this->assertSame('test=a:b', $header->getFieldValue()); } - public function setterInjections() + /** @psalm-return array */ + public function setterInjections(): array { return [ 'name' => ['setName', "\r\nThis\rIs\nThe\r\nName"], @@ -657,10 +660,9 @@ public function setterInjections() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting - * @group ZF2015-04 * + * @group ZF2015-04 * @dataProvider setterInjections - * * @param string $method * @param string $value */ @@ -678,7 +680,7 @@ public function testPreventsCRLFAttackViaSetters($method, $value) */ public static function validCookieWithInfoProvider() { - $now = time(); + $now = time(); $yesterday = $now - (3600 * 24); return [ @@ -853,29 +855,29 @@ public static function validCookieWithInfoProvider() [ 'Set-Cookie: emptykey; Domain=docs.foo.com; Max-Age=foo;', [ - 'name' => 'myname', - 'value' => '', - 'domain' => 'docs.foo.com', + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', ], - 'emptykey=; Domain=docs.foo.com' + 'emptykey=; Domain=docs.foo.com', ], [ 'Set-Cookie: emptykey; Domain=docs.foo.com; Max-Age=-1480312904;', [ - 'name' => 'myname', - 'value' => '', - 'domain' => 'docs.foo.com', + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', ], - 'emptykey=; Max-Age=0; Domain=docs.foo.com' + 'emptykey=; Max-Age=0; Domain=docs.foo.com', ], [ 'Set-Cookie: emptykey; Domain=docs.foo.com; Max-Age=100;', [ - 'name' => 'myname', - 'value' => '', - 'domain' => 'docs.foo.com', + 'name' => 'myname', + 'value' => '', + 'domain' => 'docs.foo.com', ], - 'emptykey=; Max-Age=100; Domain=docs.foo.com' + 'emptykey=; Max-Age=100; Domain=docs.foo.com', ], ]; } diff --git a/test/Header/TETest.php b/test/Header/TETest.php index 5a7c3cad..f4b4c191 100644 --- a/test/Header/TETest.php +++ b/test/Header/TETest.php @@ -1,10 +1,4 @@ -expectException(InvalidArgumentException::class); - $header = WWWAuthenticate::fromString("WWW-Authenticate: xxx\r\n\r\nevilContent"); + WWWAuthenticate::fromString("WWW-Authenticate: xxx\r\n\r\nevilContent"); } /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackViaConstructor() { $this->expectException(InvalidArgumentException::class); - $header = new WWWAuthenticate("xxx\r\n\r\nevilContent"); + new WWWAuthenticate("xxx\r\n\r\nevilContent"); } } diff --git a/test/Header/WarningTest.php b/test/Header/WarningTest.php index 44e326f8..faaeb832 100644 --- a/test/Header/WarningTest.php +++ b/test/Header/WarningTest.php @@ -1,11 +1,5 @@ */ + public function header(): iterable { - // @codingStandardsIgnoreStart + // phpcs:disable Generic.Files.LineLength.TooLong yield Header\AcceptRanges::class => [Header\AcceptRanges::class, 'Accept-Ranges']; yield Header\AuthenticationInfo::class => [Header\AuthenticationInfo::class, 'Authentication-Info']; yield Header\Authorization::class => [Header\Authorization::class, 'Authorization']; @@ -53,12 +51,12 @@ public function header() yield Header\Via::class => [Header\Via::class, 'Via']; yield Header\Warning::class => [Header\Warning::class, 'Warning']; yield Header\WWWAuthenticate::class => [Header\WWWAuthenticate::class, 'WWW-Authenticate']; - // @codingStandardsIgnoreEnd + // phpcs:enable } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ @@ -70,8 +68,8 @@ public function testThrowsExceptionIfInvalidHeaderLine($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ @@ -85,8 +83,8 @@ public function testCaseInsensitiveHeaderName($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ @@ -100,8 +98,8 @@ public function testDefaultValues($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ @@ -114,8 +112,8 @@ public function testSetValueViaConstructor($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name * @@ -131,8 +129,8 @@ public function testSetIntValueViaConstructor($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ @@ -145,8 +143,8 @@ public function testSetZeroStringValueViaConstructor($class, $name) } /** + * phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.MismatchingCaseSensitivity * @dataProvider header - * * @param string $class * @param string $name */ diff --git a/test/HeadersTest.php b/test/HeadersTest.php index 7035bc29..eefe2b34 100644 --- a/test/HeadersTest.php +++ b/test/HeadersTest.php @@ -1,11 +1,5 @@ getPluginClassLoader(); + $pcl = $headers->getPluginClassLoader(); $pcl->registerPlugin('foo', GenericMultiHeader::class); $headers->addHeaderLine('foo: bar1,bar2,bar3'); $headers->forceLoading(); @@ -135,7 +131,7 @@ public function testHeadersGetReturnsLastAddedHeaderValue() public function testHeadersAggregatesHeaderObjects() { $fakeHeader = new Header\GenericHeader('Fake', 'bar'); - $headers = new Headers(); + $headers = new Headers(); $headers->addHeader($fakeHeader); $this->assertEquals(1, $headers->count()); $this->assertSame($fakeHeader, $headers->get('Fake')); @@ -276,7 +272,7 @@ public function testCastingToArrayReturnsMultiHeadersAsArrays() $cookie2 = new Header\SetCookie('bar', 'baz'); $headers->addHeader($cookie1); $headers->addHeader($cookie2); - $array = $headers->toArray(); + $array = $headers->toArray(); $expected = [ 'Set-Cookie' => [ $cookie1->getFieldValue(), @@ -293,7 +289,7 @@ public function testCastingToStringReturnsAllMultiHeaderValues() $cookie2 = new Header\SetCookie('bar', 'baz'); $headers->addHeader($cookie1); $headers->addHeader($cookie2); - $string = $headers->toString(); + $string = $headers->toString(); $expected = [ 'Set-Cookie: ' . $cookie1->getFieldValue(), 'Set-Cookie: ' . $cookie2->getFieldValue(), @@ -310,6 +306,7 @@ public function testZeroIsAValidHeaderValue() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testCRLFAttack() diff --git a/test/PhpEnvironment/RemoteAddressTest.php b/test/PhpEnvironment/RemoteAddressTest.php index b5682cba..fb6a3c5c 100644 --- a/test/PhpEnvironment/RemoteAddressTest.php +++ b/test/PhpEnvironment/RemoteAddressTest.php @@ -1,11 +1,5 @@ assertEquals('8.8.8.8', $this->remoteAddress->getIpAddress()); } @@ -108,7 +100,7 @@ public function testGetIpAddressFromProxyRemoteAddressNotTrusted() '10.0.0.1', ]); // the REMOTE_ADDR is not in the trusted IPs, possible attack here - $_SERVER['REMOTE_ADDR'] = '1.1.1.1'; + $_SERVER['REMOTE_ADDR'] = '1.1.1.1'; $_SERVER['HTTP_X_FORWARDED_FOR'] = '8.8.8.8, 10.0.0.1'; $this->assertEquals('1.1.1.1', $this->remoteAddress->getIpAddress()); } diff --git a/test/PhpEnvironment/RequestTest.php b/test/PhpEnvironment/RequestTest.php index 95e1e39a..a48d688c 100644 --- a/test/PhpEnvironment/RequestTest.php +++ b/test/PhpEnvironment/RequestTest.php @@ -1,11 +1,5 @@ , + * 1: string, + * 2: string + * }> */ - public static function baseUrlAndPathProvider() + public static function baseUrlAndPathProvider(): array { return [ [ @@ -156,10 +159,10 @@ public static function baseUrlAndPathProvider() ], [ [ - 'SCRIPT_NAME' => '/~username/public/index.php', - 'REQUEST_URI' => '/~username/public/', - 'PHP_SELF' => '/~username/public/index.php', - 'SCRIPT_FILENAME' => '/Users/username/Sites/public/index.php', + 'SCRIPT_NAME' => '/~username/public/index.php', + 'REQUEST_URI' => '/~username/public/', + 'PHP_SELF' => '/~username/public/index.php', + 'SCRIPT_FILENAME' => '/Users/username/Sites/public/index.php', 'ORIG_SCRIPT_NAME' => null, ], '/~username/public', @@ -168,10 +171,10 @@ public static function baseUrlAndPathProvider() // Laminas-206 [ [ - 'SCRIPT_NAME' => '/laminastut/index.php', - 'REQUEST_URI' => '/laminastut/', - 'PHP_SELF' => '/laminastut/index.php', - 'SCRIPT_FILENAME' => 'c:/LaminasTutorial/public/index.php', + 'SCRIPT_NAME' => '/laminastut/index.php', + 'REQUEST_URI' => '/laminastut/', + 'PHP_SELF' => '/laminastut/index.php', + 'SCRIPT_FILENAME' => 'c:/LaminasTutorial/public/index.php', 'ORIG_SCRIPT_NAME' => null, ], '/laminastut', @@ -198,8 +201,8 @@ public static function baseUrlAndPathProvider() // Test when url quert contains a full http url [ [ - 'REQUEST_URI' => '/html/index.php?url=http://test.example.com/path/&foo=bar', - 'PHP_SELF' => '/html/index.php', + 'REQUEST_URI' => '/html/index.php?url=http://test.example.com/path/&foo=bar', + 'PHP_SELF' => '/html/index.php', 'SCRIPT_FILENAME' => '/var/web/html/index.php', ], '/html/index.php', @@ -210,7 +213,6 @@ public static function baseUrlAndPathProvider() /** * @dataProvider baseUrlAndPathProvider - * * @param array $server * @param string $baseUrl * @param string $basePath @@ -226,8 +228,14 @@ public function testBasePathDetection(array $server, $baseUrl, $basePath) /** * Data provider for testing server provided headers. + * + * @psalm-return array, + * 1: string, + * 2: string|int + * }> */ - public static function serverHeaderProvider() + public static function serverHeaderProvider(): array { return [ [ @@ -284,7 +292,6 @@ public static function serverHeaderProvider() /** * @dataProvider serverHeaderProvider - * * @param array $server * @param string $name * @param string $value @@ -302,7 +309,6 @@ public function testHeadersWithMinus(array $server, $name, $value) /** * @dataProvider serverHeaderProvider - * * @param array $server * @param string $name */ @@ -316,8 +322,15 @@ public function testRequestStringHasCorrectHeaderName(array $server, $name) /** * Data provider for testing server hostname. + * + * @psalm-return array, + * 1: string, + * 2: string, + * 3: string + * }> */ - public static function serverHostnameProvider() + public static function serverHostnameProvider(): array { return [ [ @@ -331,7 +344,7 @@ public static function serverHostnameProvider() ], [ [ - 'HTTP_HOST' => 'test.example.com', + 'HTTP_HOST' => 'test.example.com', 'REQUEST_URI' => 'http://test.example.com/news', ], 'test.example.com', @@ -341,7 +354,7 @@ public static function serverHostnameProvider() [ [ 'SERVER_NAME' => 'test.example.com', - 'HTTP_HOST' => 'requested.example.com', + 'HTTP_HOST' => 'requested.example.com', 'REQUEST_URI' => 'http://test.example.com/news', ], 'requested.example.com', @@ -351,7 +364,7 @@ public static function serverHostnameProvider() [ [ 'SERVER_NAME' => 'test.example.com', - 'HTTP_HOST' => '', + 'HTTP_HOST' => '', 'REQUEST_URI' => 'http://test.example.com/news', ], 'test.example.com', @@ -405,10 +418,10 @@ public static function serverHostnameProvider() // Test for HTTPS requests which are forwarded over a reverse proxy/load balancer [ [ - 'SERVER_NAME' => 'test.example.com', - 'SERVER_PORT' => '443', + 'SERVER_NAME' => 'test.example.com', + 'SERVER_PORT' => '443', 'HTTP_X_FORWARDED_PROTO' => 'https', - 'REQUEST_URI' => 'https://test.example.com/news', + 'REQUEST_URI' => 'https://test.example.com/news', ], 'test.example.com', '443', @@ -429,7 +442,6 @@ public static function serverHostnameProvider() /** * @dataProvider serverHostnameProvider - * * @param array $server * @param string $expectedHost * @param string $expectedPort @@ -468,20 +480,20 @@ public static function filesProvider() [ [ 'file' => [ - 'name' => 'test1.txt', - 'type' => 'text/plain', + 'name' => 'test1.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], [ 'file' => [ - 'name' => 'test1.txt', - 'type' => 'text/plain', + 'name' => 'test1.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], ], @@ -490,11 +502,11 @@ public static function filesProvider() [ [ 'file' => [ - 'name' => [ + 'name' => [ 0 => 'test1.txt', 1 => 'test2.txt', ], - 'type' => [ + 'type' => [ 0 => 'text/plain', 1 => 'text/plain', ], @@ -502,11 +514,11 @@ public static function filesProvider() 0 => '/tmp/phpXXX', 1 => '/tmp/phpXXX', ], - 'error' => [ + 'error' => [ 0 => 0, 1 => 0, ], - 'size' => [ + 'size' => [ 0 => 1, 1 => 1, ], @@ -515,18 +527,18 @@ public static function filesProvider() [ 'file' => [ 0 => [ - 'name' => 'test1.txt', - 'type' => 'text/plain', + 'name' => 'test1.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], 1 => [ - 'name' => 'test2.txt', - 'type' => 'text/plain', + 'name' => 'test2.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], ], @@ -536,11 +548,11 @@ public static function filesProvider() [ [ 'file' => [ - 'name' => [ + 'name' => [ 'one' => 'test1.txt', 'two' => 'test2.txt', ], - 'type' => [ + 'type' => [ 'one' => 'text/plain', 'two' => 'text/plain', ], @@ -548,31 +560,31 @@ public static function filesProvider() 'one' => '/tmp/phpXXX', 'two' => '/tmp/phpXXX', ], - 'error' => [ + 'error' => [ 'one' => 0, 'two' => 0, ], - 'size' => [ + 'size' => [ 'one' => 1, 'two' => 1, ], - ], + ], ], [ 'file' => [ 'one' => [ - 'name' => 'test1.txt', - 'type' => 'text/plain', + 'name' => 'test1.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], 'two' => [ - 'name' => 'test2.txt', - 'type' => 'text/plain', + 'name' => 'test2.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], ], @@ -582,7 +594,7 @@ public static function filesProvider() [ [ 'file' => [ - 'name' => [ + 'name' => [ 0 => 'test_0.txt', 1 => [ 0 => 'test_10.txt', @@ -593,7 +605,7 @@ public static function filesProvider() ], ], ], - 'type' => [ + 'type' => [ 0 => 'text/plain', 1 => [ 0 => 'text/plain', @@ -615,7 +627,7 @@ public static function filesProvider() ], ], ], - 'error' => [ + 'error' => [ 0 => 0, 1 => [ 0 => 0, @@ -626,7 +638,7 @@ public static function filesProvider() ], ], ], - 'size' => [ + 'size' => [ 0 => 1, 1 => [ 0 => 1, @@ -642,29 +654,29 @@ public static function filesProvider() [ 'file' => [ 0 => [ - 'name' => 'test_0.txt', - 'type' => 'text/plain', + 'name' => 'test_0.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], 1 => [ 0 => [ - 'name' => 'test_10.txt', - 'type' => 'text/plain', + 'name' => 'test_10.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], 2 => [ 0 => [ 0 => [ - 'name' => 'test_200.txt', - 'type' => 'text/plain', + 'name' => 'test_200.txt', + 'type' => 'text/plain', 'tmp_name' => '/tmp/phpXXX', - 'error' => 0, - 'size' => 1, + 'error' => 0, + 'size' => 1, ], ], ], @@ -676,13 +688,12 @@ public static function filesProvider() /** * @dataProvider filesProvider - * * @param array $files * @param array $expectedFiles */ public function testRequestMapsPhpFies(array $files, array $expectedFiles) { - $_FILES = $files; + $_FILES = $files; $request = new Request(); $this->assertEquals($expectedFiles, $request->getFiles()->toArray()); } @@ -690,7 +701,7 @@ public function testRequestMapsPhpFies(array $files, array $expectedFiles) public function testParameterRetrievalDefaultValue() { $request = new Request(); - $p = new Parameters([ + $p = new Parameters([ 'foo' => 'bar', ]); $request->setQuery($p); @@ -712,7 +723,7 @@ public function testParameterRetrievalDefaultValue() public function testRetrievingASingleValueForParameters() { $request = new Request(); - $p = new Parameters([ + $p = new Parameters([ 'foo' => 'bar', ]); $request->setQuery($p); @@ -728,7 +739,7 @@ public function testRetrievingASingleValueForParameters() $this->assertSame('bar', $request->getEnv('foo')); $headers = new Headers(); - $h = new GenericHeader('foo', 'bar'); + $h = new GenericHeader('foo', 'bar'); $headers->addHeader($h); $request->setHeaders($headers); diff --git a/test/PhpEnvironment/ResponseTest.php b/test/PhpEnvironment/ResponseTest.php index 3bf04584..163b79d7 100644 --- a/test/PhpEnvironment/ResponseTest.php +++ b/test/PhpEnvironment/ResponseTest.php @@ -1,11 +1,5 @@ assertSame(Response::VERSION_10, $response->getVersion()); } @@ -69,7 +63,7 @@ public function testReturnsOneOneVersionWhenDetectedInServerSuperglobal() { // HTTP/1.1 $_SERVER['SERVER_PROTOCOL'] = 'HTTP/1.1'; - $response = new Response(); + $response = new Response(); $this->assertSame(Response::VERSION_11, $response->getVersion()); } @@ -77,7 +71,7 @@ public function testFallsBackToVersionOneOhWhenServerSuperglobalVersionIsNotReco { // unknown protocol or version -> fallback to HTTP/1.0 $_SERVER['SERVER_PROTOCOL'] = 'laminas/2.0'; - $response = new Response(); + $response = new Response(); $this->assertSame(Response::VERSION_10, $response->getVersion()); } diff --git a/test/RequestTest.php b/test/RequestTest.php index c9706c19..36c42cfd 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -1,11 +1,5 @@ assertEquals(Request::METHOD_GET, $request->getMethod()); @@ -44,7 +41,7 @@ public function testRequestUsesParametersContainerByDefault() public function testRequestAllowsSettingOfParameterContainer() { $request = new Request(); - $p = new Parameters(); + $p = new Parameters(); $request->setQuery($p); $request->setPost($p); $request->setFiles($p); @@ -61,7 +58,7 @@ public function testRequestAllowsSettingOfParameterContainer() public function testRetrievingASingleValueForParameters() { $request = new Request(); - $p = new Parameters([ + $p = new Parameters([ 'foo' => 'bar', ]); $request->setQuery($p); @@ -73,7 +70,7 @@ public function testRetrievingASingleValueForParameters() $this->assertSame('bar', $request->getFiles('foo')); $headers = new Headers(); - $h = new GenericHeader('foo', 'bar'); + $h = new GenericHeader('foo', 'bar'); $headers->addHeader($h); $request->setHeaders($headers); @@ -85,7 +82,7 @@ public function testRetrievingASingleValueForParameters() public function testParameterRetrievalDefaultValue() { $request = new Request(); - $p = new Parameters([ + $p = new Parameters([ 'foo' => 'bar', ]); $request->setQuery($p); @@ -139,7 +136,6 @@ public function testRequestCanAlwaysForcesUppecaseMethodName() /** * @dataProvider uriDataProvider - * * @param string $uri */ public function testRequestCanSetAndRetrieveUri($uri) @@ -152,7 +148,8 @@ public function testRequestCanSetAndRetrieveUri($uri) $this->assertEquals($uri, $request->getUriString()); } - public function uriDataProvider() + /** @psalm-return array */ + public function uriDataProvider(): array { return [ ['/foo'], @@ -189,7 +186,6 @@ public function testRequestSetVersionWillThrowExceptionOnInvalidArgument() /** * @dataProvider getMethods - * * @param string $methodName */ public function testRequestMethodCheckWorksForAllMethods($methodName) @@ -245,7 +241,7 @@ public function testRequestIsFlashRequest() public function testRequestsWithoutHttpVersionAreOK() { $requestString = 'GET http://www.domain.com/index.php'; - $request = Request::fromString($requestString); + $request = Request::fromString($requestString); $this->assertEquals($request::METHOD_GET, $request->getMethod()); } @@ -257,13 +253,13 @@ public function testRequestsWithoutHttpVersionAreOK() public function getMethods($providerContext, $trueMethod = null) { $refClass = new ReflectionClass(Request::class); - $return = []; + $return = []; foreach ($refClass->getConstants() as $cName => $cValue) { - if (substr($cName, 0, 6) == 'METHOD') { + if (substr($cName, 0, 6) === 'METHOD') { if ($providerContext) { $return[] = [$cValue]; } else { - $return[strtolower($cValue)] = $trueMethod == $cValue; + $return[strtolower($cValue)] = $trueMethod === $cValue; } } } @@ -326,6 +322,7 @@ public function testFromStringFactoryCreatesSingleObjectWithHeaderFolding() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testCRLFAttack() diff --git a/test/Response/ResponseStreamTest.php b/test/Response/ResponseStreamTest.php index ebb2d72e..90e168e7 100644 --- a/test/Response/ResponseStreamTest.php +++ b/test/Response/ResponseStreamTest.php @@ -1,16 +1,23 @@ tempFile = tempnam(sys_get_temp_dir(), 'lhrs'); - $streamObject = new class($this->tempFile) { + $streamObject = new class ($this->tempFile) { + /** @var string */ private $tempFile; public function __construct(string $tempFile) @@ -107,7 +114,7 @@ public function __construct(string $tempFile) $this->tempFile = $tempFile; } - public function __toString() + public function __toString(): string { return $this->tempFile; } @@ -136,14 +143,14 @@ protected function readResponse($response) $data = ''; while (false !== ($newLine = fgets($stream))) { $data .= $newLine; - if ($newLine == "\n" || $newLine == "\r\n") { + if ($newLine === "\n" || $newLine === "\r\n") { break; } } $data .= fread($stream, 100); // Should accept also part of body as text - $return = []; + $return = []; $return['stream'] = $stream; $return['data'] = $data; diff --git a/test/ResponseTest.php b/test/ResponseTest.php index 4ed4e3dd..35dc4ef1 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -1,11 +1,5 @@ */ + public function validHttpVersions(): iterable { yield 'http/1.0' => ['1.0']; yield 'http/1.1' => ['1.1']; yield 'http/2' => ['2']; } - public function validResponseHttpVersionProvider() + /** + * @psalm-return iterable + */ + public function validResponseHttpVersionProvider(): iterable { $responseTemplate = "HTTP/%s 200 OK\r\n\r\nFoo Bar"; foreach ($this->validHttpVersions() as $testCase => $data) { @@ -88,8 +106,8 @@ public function testInvalidHTTP2VersionString() { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('A valid response status line was not found in the provided string'); - $string = 'HTTP/2.0 200 OK' . "\r\n\r\n" . 'Foo Bar'; - $response = \Laminas\Http\Response::fromString($string); + $string = 'HTTP/2.0 200 OK' . "\r\n\r\n" . 'Foo Bar'; + $response = Response::fromString($string); } public function testResponseUsesHeadersContainerByDefault() @@ -101,14 +119,15 @@ public function testResponseUsesHeadersContainerByDefault() public function testRequestCanSetHeaders() { $response = new Response(); - $headers = new Headers(); + $headers = new Headers(); $ret = $response->setHeaders($headers); $this->assertInstanceOf(Response::class, $ret); $this->assertSame($headers, $response->getHeaders()); } - public function validStatusCode() + /** @psalm-return iterable */ + public function validStatusCode(): iterable { for ($i = 100; $i <= 599; ++$i) { yield $i => [$i]; @@ -117,7 +136,6 @@ public function validStatusCode() /** * @dataProvider validStatusCode - * * @param int $statusCode */ public function testResponseCanSetStatusCode($statusCode) @@ -162,7 +180,7 @@ public function testResponseSetCustomStatusCodeThrowsExceptionOnInvalidCode() public function testResponseEndsAtStatusCode() { - $string = 'HTTP/1.0 200' . "\r\n\r\n" . 'Foo Bar'; + $string = 'HTTP/1.0 200' . "\r\n\r\n" . 'Foo Bar'; $response = Response::fromString($string); $this->assertEquals(200, $response->getStatusCode()); $this->assertEquals('Foo Bar', $response->getContent()); @@ -302,7 +320,6 @@ private function makeChunk($chunksize) } /** - * @param Response $response * @return float the time that calling the getBody function took on the response */ private function getTimeForGetBody(Response $response) @@ -356,10 +373,10 @@ public function testChunkedResponsePerformance() public function testLineBreaksCompatibility() { $responseTestLf = $this->readResponse('response_lfonly'); - $resLf = Response::fromString($responseTestLf); + $resLf = Response::fromString($responseTestLf); $responseTestCrlf = $this->readResponse('response_crlf'); - $resCrlf = Response::fromString($responseTestCrlf); + $resCrlf = Response::fromString($responseTestCrlf); $this->assertEquals( $resLf->getHeaders()->toString(), @@ -374,7 +391,7 @@ public function testLineBreaksCompatibility() public function test404IsClientErrorAndNotFound() { $responseTest = $this->readResponse('response_404'); - $response = Response::fromString($responseTest); + $response = Response::fromString($responseTest); $this->assertEquals(404, $response->getStatusCode(), 'Response code is expected to be 404, but it\'s not.'); $this->assertTrue($response->isClientError(), 'Response is an error, but isClientError() returned false'); @@ -391,7 +408,7 @@ public function test404IsClientErrorAndNotFound() public function test410IsGone() { $responseTest = $this->readResponse('response_410'); - $response = Response::fromString($responseTest); + $response = Response::fromString($responseTest); $this->assertEquals(410, $response->getStatusCode(), 'Response code is expected to be 410, but it\'s not.'); $this->assertTrue($response->isClientError(), 'Response is an error, but isClientError() returned false'); @@ -408,7 +425,7 @@ public function test410IsGone() public function test500isError() { $responseTest = $this->readResponse('response_500'); - $response = Response::fromString($responseTest); + $response = Response::fromString($responseTest); $this->assertEquals(500, $response->getStatusCode(), 'Response code is expected to be 500, but it\'s not.'); $this->assertFalse($response->isClientError(), 'Response is an error, but isClientError() returned true'); @@ -499,7 +516,7 @@ public function testAutoMessageSet() public function testToString() { $responseStr = $this->readResponse('response_404'); - $response = Response::fromString($responseStr); + $response = Response::fromString($responseStr); $this->assertEquals( strtolower(str_replace("\n", "\r\n", $responseStr)), @@ -516,7 +533,7 @@ public function testToString() public function testToStringGzip() { $responseStr = $this->readResponse('response_gzip'); - $response = Response::fromString($responseStr); + $response = Response::fromString($responseStr); $this->assertEquals( strtolower($responseStr), @@ -533,7 +550,7 @@ public function testToStringGzip() public function testGetHeaders() { $response = Response::fromString($this->readResponse('response_deflate')); - $headers = $response->getHeaders(); + $headers = $response->getHeaders(); $this->assertEquals(8, count($headers), 'Header count is not as expected'); $this->assertEquals('Apache', $headers->get('Server')->getFieldValue(), 'Server header is not as expected'); @@ -553,7 +570,7 @@ public function testGetVersion() public function testUnknownCode() { $responseStr = $this->readResponse('response_unknown'); - $response = Response::fromString($responseStr); + $response = Response::fromString($responseStr); $this->assertEquals(550, $response->getStatusCode()); } @@ -613,6 +630,7 @@ public function testromStringFactoryCreatesSingleObjectWithHeaderFolding() /** * @see http://en.wikipedia.org/wiki/HTTP_response_splitting + * * @group ZF2015-04 */ public function testPreventsCRLFAttackWhenDeserializing() @@ -626,7 +644,7 @@ public function testPreventsCRLFAttackWhenDeserializing() public function test100ContinueFromString() { $fixture = 'TOKEN=EC%XXXXXXXXXXXXX&TIMESTAMP=2017%2d10%2d10T09%3a02%3a55Z' - ."&CORRELATIONID=XXXXXXXXXX&ACK=Success&VERSION=65%2e1&BUILD=XXXXXXXXXX\r\n"; + . "&CORRELATIONID=XXXXXXXXXX&ACK=Success&VERSION=65%2e1&BUILD=XXXXXXXXXX\r\n"; $request = Response::fromString($this->readResponse('response_100_continue')); $this->assertEquals(Response::STATUS_CODE_200, $request->getStatusCode()); diff --git a/test/TestAsset/ExtendedClient.php b/test/TestAsset/ExtendedClient.php index 0f1a14af..b6bd82fa 100644 --- a/test/TestAsset/ExtendedClient.php +++ b/test/TestAsset/ExtendedClient.php @@ -1,16 +1,10 @@ Date: Thu, 9 Sep 2021 12:49:57 -0500 Subject: [PATCH 3/9] fix: add ReturnTypeWillChange attribute to Headers methods implementing internal interfaces Signed-off-by: Matthew Weier O'Phinney --- src/Headers.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Headers.php b/src/Headers.php index 84e1915b..8ae9ad88 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -9,6 +9,8 @@ use Laminas\Http\Header\GenericHeader; use Laminas\Http\Header\MultipleHeaderInterface; use Laminas\Loader\PluginClassLocator; +// phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse +use ReturnTypeWillChange; use Traversable; use function array_keys; @@ -338,6 +340,7 @@ public function has($name) * * @return void */ + #[ReturnTypeWillChange] public function next() { next($this->headers); @@ -348,6 +351,7 @@ public function next() * * @return mixed */ + #[ReturnTypeWillChange] public function key() { return key($this->headers); @@ -358,6 +362,7 @@ public function key() * * @return bool */ + #[ReturnTypeWillChange] public function valid() { return current($this->headers) !== false; @@ -368,6 +373,7 @@ public function valid() * * @return void */ + #[ReturnTypeWillChange] public function rewind() { reset($this->headers); @@ -378,6 +384,7 @@ public function rewind() * * @return array|Header\HeaderInterface */ + #[ReturnTypeWillChange] public function current() { $current = current($this->headers); @@ -393,6 +400,7 @@ public function current() * * @return int count of currently known headers */ + #[ReturnTypeWillChange] public function count() { return count($this->headers); From d4e4bc308eb7604fb56c7867ba5d4c29e5cb6a12 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 13:24:45 -0500 Subject: [PATCH 4/9] fix: provide functionality to work with PHP 8.1 Primarily, these are around ensuring that the appropriate type of argument is passed to internal methods/functions. Generally the solutions are achieved via null coalesce to the appropriate empty version of a type (e.g., `?? ''` or `?? []`). Signed-off-by: Matthew Weier O'Phinney --- src/Client.php | 6 +- src/Client/Adapter/Socket.php | 7 +- src/Cookies.php | 2 +- src/Header/AbstractAccept.php | 2 +- src/Header/AbstractDate.php | 2 +- src/Header/SetCookie.php | 6 +- src/PhpEnvironment/Request.php | 4 +- test/Client/StaticTest.php | 148 ++++++++++++++++----------------- test/Header/AcceptTest.php | 12 +-- test/Header/DateTest.php | 4 +- 10 files changed, 96 insertions(+), 97 deletions(-) diff --git a/src/Client.php b/src/Client.php index 2e675aaf..2d144102 100644 --- a/src/Client.php +++ b/src/Client.php @@ -343,7 +343,7 @@ public function setUri($uri) // reasons, see #4215 for a discussion - currently authentication is also // cleared for peer subdomains due to technical limits $nextHost = $this->getRequest()->getUri()->getHost(); - if (! preg_match('/' . preg_quote($lastHost, '/') . '$/i', $nextHost)) { + if (! empty($lastHost) && ! preg_match('/' . preg_quote($lastHost, '/') . '$/i', $nextHost)) { $this->clearAuth(); } @@ -914,7 +914,7 @@ public function send(?Request $request = null) if (! empty($queryArray)) { $newUri = $uri->toString(); - $queryString = http_build_query($queryArray, null, $this->getArgSeparator()); + $queryString = http_build_query($queryArray, '', $this->getArgSeparator()); if ($this->config['rfc3986strict']) { $queryString = str_replace('+', '%20', $queryString); @@ -1323,7 +1323,7 @@ protected function prepareBody() $body .= '--' . $boundary . '--' . "\r\n"; } elseif (stripos($this->getEncType(), self::ENC_URLENCODED) === 0) { // Encode body as application/x-www-form-urlencoded - $body = http_build_query($this->getRequest()->getPost()->toArray(), null, '&'); + $body = http_build_query($this->getRequest()->getPost()->toArray(), '', '&'); } else { throw new RuntimeException(sprintf( 'Cannot handle content type \'%s\' automatically', diff --git a/src/Client/Adapter/Socket.php b/src/Client/Adapter/Socket.php index a5542bb6..d54ee401 100644 --- a/src/Client/Adapter/Socket.php +++ b/src/Client/Adapter/Socket.php @@ -228,9 +228,10 @@ public function getStreamContext() public function connect($host, $port = 80, $secure = false) { // If we are connected to the wrong host, disconnect first - $connectedHost = strpos($this->connectedTo[0], '://') - ? substr($this->connectedTo[0], strpos($this->connectedTo[0], '://') + 3, strlen($this->connectedTo[0])) - : $this->connectedTo[0]; + $connectedTo = $this->connectedTo[0] ?? ''; + $connectedHost = strpos($connectedTo, '://') + ? substr($connectedTo, strpos($connectedTo, '://') + 3, strlen($this->connectedTo)) + : $connectedTo; if ($connectedHost !== $host || $this->connectedTo[1] !== $port) { if (is_resource($this->socket)) { diff --git a/src/Cookies.php b/src/Cookies.php index 2265cfcf..1d03b2b1 100644 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -210,7 +210,7 @@ public function getCookie($uri, $cookieName, $retAs = self::COOKIE_OBJECT) } // Get correct cookie path - $path = $uri->getPath(); + $path = $uri->getPath() ?? ''; $lastSlashPos = strrpos($path, '/') ?: 0; $path = substr($path, 0, $lastSlashPos); if (! $path) { diff --git a/src/Header/AbstractAccept.php b/src/Header/AbstractAccept.php index d1ff0409..279f97ef 100644 --- a/src/Header/AbstractAccept.php +++ b/src/Header/AbstractAccept.php @@ -194,7 +194,7 @@ protected function getParametersFromFieldValuePart($fieldValuePart) $value = substr(substr($value, 1), 0, -1); } - $params[trim($explode[0])] = stripslashes($value); + $params[trim($explode[0])] = stripslashes($value ?? ''); } } diff --git a/src/Header/AbstractDate.php b/src/Header/AbstractDate.php index 9ff0fe0c..f75bc701 100644 --- a/src/Header/AbstractDate.php +++ b/src/Header/AbstractDate.php @@ -200,7 +200,7 @@ public function getDate() public function date() { if ($this->date === null) { - $this->date = new DateTime(null, new DateTimeZone('GMT')); + $this->date = new DateTime('now', new DateTimeZone('GMT')); } return $this->date; } diff --git a/src/Header/SetCookie.php b/src/Header/SetCookie.php index 0341a109..19096243 100644 --- a/src/Header/SetCookie.php +++ b/src/Header/SetCookie.php @@ -169,10 +169,10 @@ public static function fromString($headerLine, $bypassHeaderFieldName = false) // First K=V pair is always the cookie name and value if ($header->getName() === null) { $header->setName($headerKey); - $header->setValue(urldecode($headerValue)); + $header->setValue(urldecode($headerValue ?? '')); // set no encode value if raw and encoded values are the same - if (urldecode($headerValue) === $headerValue) { + if (urldecode($headerValue ?? '') === $headerValue) { $header->setEncodeValue(false); } continue; @@ -313,7 +313,7 @@ public function getFieldValue() return ''; } - $value = $this->encodeValue ? urlencode($this->getValue()) : $this->getValue(); + $value = $this->encodeValue ? urlencode($this->getValue() ?? '') : $this->getValue(); if ($this->hasQuoteFieldValue()) { $value = '"' . $value . '"'; } diff --git a/src/PhpEnvironment/Request.php b/src/PhpEnvironment/Request.php index 80c20342..87407ca1 100644 --- a/src/PhpEnvironment/Request.php +++ b/src/PhpEnvironment/Request.php @@ -234,7 +234,7 @@ public function setServer(ParametersInterface $server) $headers = []; foreach ($server as $key => $value) { - if ($value || (! is_array($value) && strlen($value))) { + if ($value || (! is_array($value) && strlen($value ?? ''))) { if (strpos($key, 'HTTP_') === 0) { if (strpos($key, 'HTTP_COOKIE') === 0) { // Cookies are handled using the $_COOKIE superglobal @@ -518,7 +518,7 @@ protected function detectBaseUrl() } $baseUrl = '/'; - $basename = basename($filename); + $basename = basename($filename ?? ''); if ($basename) { $path = $phpSelf ? trim($phpSelf, '/') : ''; $basePos = strpos($path, $basename) ?: 0; diff --git a/test/Client/StaticTest.php b/test/Client/StaticTest.php index 3804bd72..775316f9 100644 --- a/test/Client/StaticTest.php +++ b/test/Client/StaticTest.php @@ -49,21 +49,19 @@ */ class StaticTest extends TestCase { - // @codingStandardsIgnoreStart /** * Common HTTP client * * @var HTTPClient */ - protected $_client; - // @codingStandardsIgnoreEnd + protected $client; /** * Set up the test suite before each test */ public function setUp(): void { - $this->_client = new MockClient('http://www.example.com'); + $this->client = new MockClient('http://www.example.com'); } /** @@ -71,7 +69,7 @@ public function setUp(): void */ public function tearDown(): void { - $this->_client = null; + $this->client = null; } /** @@ -85,13 +83,13 @@ public function testSetGetUriString() { $uristr = 'https://www.zend.com:80/'; - $this->_client->setUri($uristr); + $this->client->setUri($uristr); - $uri = $this->_client->getUri(); + $uri = $this->client->getUri(); $this->assertInstanceOf(UriHttp::class, $uri, 'Returned value is not a Uri object as expected'); $this->assertEquals($uri->__toString(), $uristr, 'Returned Uri object does not hold the expected URI'); - $uri = $this->_client->getUri()->toString(); + $uri = $this->client->getUri()->toString(); $this->assertIsString( $uri, 'Returned value expected to be a string, ' . gettype($uri) . ' returned' @@ -106,9 +104,9 @@ public function testSetGetUriObject() { $uriobj = new UriHttp('https://www.zend.com:80/'); - $this->_client->setUri($uriobj); + $this->client->setUri($uriobj); - $uri = $this->_client->getUri(); + $uri = $this->client->getUri(); $this->assertInstanceOf(UriHttp::class, $uri, 'Returned value is not a Uri object as expected'); $this->assertEquals($uri, $uriobj, 'Returned object is not the excepted Uri object'); } @@ -121,14 +119,14 @@ public function testDoubleGetParameter() { $qstr = 'foo=bar&foo=baz'; - $this->_client->setUri('http://example.com/test/?' . $qstr); - $this->_client->setAdapter(Test::class); - $this->_client->setMethod('GET'); - $this->_client->send(); + $this->client->setUri('http://example.com/test/?' . $qstr); + $this->client->setAdapter(Test::class); + $this->client->setMethod('GET'); + $this->client->send(); $this->assertStringContainsString( $qstr, - $this->_client->getLastRawRequest(), + $this->client->getLastRawRequest(), 'Request is expected to contain the entire query string' ); } @@ -142,18 +140,18 @@ public function testDoubleGetParameter() */ public function testGetHeader() { - $this->_client->setHeaders([ + $this->client->setHeaders([ 'Accept-encoding' => 'gzip,deflate', 'Accept-language' => 'en,de,*', ]); $this->assertEquals( - $this->_client->getHeader('Accept-encoding'), + $this->client->getHeader('Accept-encoding'), 'gzip, deflate', 'Returned value of header is not as expected' ); $this->assertEquals( - $this->_client->getHeader('X-Fake-Header'), + $this->client->getHeader('X-Fake-Header'), null, 'Non-existing header should not return a value' ); @@ -172,7 +170,7 @@ public function testExceptUnsupportedAuthDynamic() $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid or not supported authentication type: \'SuperStrongAlgo\''); - $this->_client->setAuth('shahar', '1234', 'SuperStrongAlgo'); + $this->client->setAuth('shahar', '1234', 'SuperStrongAlgo'); } /** @@ -184,9 +182,9 @@ public function testExceptUnsupportedAuthDynamic() */ public function testSetNewCookies() { - $this->_client->addCookie('cookie', 'value'); - $this->_client->addCookie('chocolate', 'chips'); - $cookies = $this->_client->getCookies(); + $this->client->addCookie('cookie', 'value'); + $this->client->addCookie('chocolate', 'chips'); + $cookies = $this->client->getCookies(); // Check we got the right cookiejar $this->assertIsArray($cookies); @@ -200,13 +198,13 @@ public function testSetNewCookies() public function testUnsetCookies() { // Set the cookie jar just like in testSetNewCookieJar - $this->_client->addCookie('cookie', 'value'); - $this->_client->addCookie('chocolate', 'chips'); - $cookies = $this->_client->getCookies(); + $this->client->addCookie('cookie', 'value'); + $this->client->addCookie('chocolate', 'chips'); + $cookies = $this->client->getCookies(); // Try unsetting the cookies - $this->_client->clearCookies(); - $cookies = $this->_client->getCookies(); + $this->client->clearCookies(); + $cookies = $this->client->getCookies(); $this->assertEquals([], $cookies, 'Cookies are expected to be an empty array but it is not'); } @@ -219,7 +217,7 @@ public function testSetInvalidCookies() $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid parameter type passed as Cookie'); - $this->_client->addCookie('cookie'); + $this->client->addCookie('cookie'); } /** @@ -236,9 +234,9 @@ public function testConfigSetAsArray() 'someoption' => 'hasvalue', ]; - $this->_client->setOptions($config); + $this->client->setOptions($config); - $hasConfig = $this->_client->config; + $hasConfig = $this->client->config; foreach ($config as $k => $v) { $this->assertEquals($v, $hasConfig[$k]); @@ -259,9 +257,9 @@ public function testConfigSetAsTraversable() ], ]); - $this->_client->setOptions($config); + $this->client->setOptions($config); - $hasConfig = $this->_client->config; + $hasConfig = $this->client->config; $this->assertEquals($config['timeout'], $hasConfig['timeout']); $this->assertEquals($config['nested']['item'], $hasConfig['nested']['item']); } @@ -277,7 +275,7 @@ public function testConfigSetInvalid($config) $this->expectException(ClientException\InvalidArgumentException::class); $this->expectExceptionMessage('Config parameter is not valid'); - $this->_client->setOptions($config); + $this->client->setOptions($config); } /** @@ -291,13 +289,13 @@ public function testConfigPassToAdapterLaminas4557() $adapter = new MockAdapter(); // test that config passes when we set the adapter - $this->_client->setOptions(['param' => 'value1']); - $this->_client->setAdapter($adapter); + $this->client->setOptions(['param' => 'value1']); + $this->client->setAdapter($adapter); $adapterCfg = $adapter->config; $this->assertEquals('value1', $adapterCfg['param']); // test that adapter config value changes when we set client config - $this->_client->setOptions(['param' => 'value2']); + $this->client->setOptions(['param' => 'value2']); $adapterCfg = $adapter->config; $this->assertEquals('value2', $adapterCfg['param']); } @@ -314,18 +312,18 @@ public function testGetLastRawResponse() // First, make sure we get null before the request $this->assertEquals( null, - $this->_client->getLastRawResponse(), + $this->client->getLastRawResponse(), 'getLastRawResponse() is still expected to return null' ); // Now, test we get a proper response after the request - $this->_client->setUri('http://example.com/foo/bar'); - $this->_client->setAdapter(Test::class); + $this->client->setUri('http://example.com/foo/bar'); + $this->client->setAdapter(Test::class); - $response = $this->_client->send(); + $response = $this->client->send(); $this->assertSame( $response, - $this->_client->getResponse(), + $this->client->getResponse(), 'Response is expected to be identical to the result of getResponse()' ); } @@ -336,14 +334,14 @@ public function testGetLastRawResponse() public function testGetLastRawResponseWhenNotStoring() { // Now, test we get a proper response after the request - $this->_client->setUri('http://example.com/foo/bar'); - $this->_client->setAdapter(Test::class); - $this->_client->setOptions(['storeresponse' => false]); + $this->client->setUri('http://example.com/foo/bar'); + $this->client->setAdapter(Test::class); + $this->client->setOptions(['storeresponse' => false]); - $this->_client->send(); + $this->client->send(); $this->assertNull( - $this->_client->getLastRawResponse(), + $this->client->getLastRawResponse(), 'getLastRawResponse is expected to be null when not storing' ); } @@ -363,11 +361,11 @@ public function testInvalidPostContentType() $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Cannot handle content type \'x-foo/something-fake\' automatically'); - $this->_client->setEncType('x-foo/something-fake'); - $this->_client->setParameterPost(['parameter' => 'value']); - $this->_client->setMethod('POST'); + $this->client->setEncType('x-foo/something-fake'); + $this->client->setParameterPost(['parameter' => 'value']); + $this->client->setMethod('POST'); // This should throw an exception - $this->_client->send(); + $this->client->send(); } /** @@ -385,13 +383,13 @@ public function testSocketErrorException() $this->expectExceptionMessage('Unable to connect to 255.255.255.255:80'); // Try to connect to an invalid host - $this->_client->setUri('http://255.255.255.255'); + $this->client->setUri('http://255.255.255.255'); // Reduce timeout to 3 seconds to avoid waiting - $this->_client->setOptions(['timeout' => 3]); + $this->client->setOptions(['timeout' => 3]); // This call should cause an exception - $this->_client->send(); + $this->client->send(); } /** @@ -406,7 +404,7 @@ public function testSettingInvalidMethodThrowsException($method) $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid HTTP method passed'); - $this->_client->setMethod($method); + $this->client->setMethod($method); } /** @@ -421,11 +419,11 @@ public function testFormDataEncodingWithMultiArrayLaminas7038() HTTPClient::class )); } - $this->_client->setAdapter(Test::class); - $this->_client->setUri('http://example.com'); - $this->_client->setEncType(HTTPClient::ENC_FORMDATA); + $this->client->setAdapter(Test::class); + $this->client->setUri('http://example.com'); + $this->client->setEncType(HTTPClient::ENC_FORMDATA); - $this->_client->setParameterPost([ + $this->client->setParameterPost([ 'test' => [ 'v0.1', 'v0.2', @@ -437,12 +435,12 @@ public function testFormDataEncodingWithMultiArrayLaminas7038() ], ]); - $this->_client->setMethod('POST'); - $this->_client->send(); + $this->client->setMethod('POST'); + $this->client->send(); $expectedLines = file(__DIR__ . '/_files/Laminas7038-multipartarrayrequest.txt'); - $gotLines = explode("\n", $this->_client->getLastRawRequest()); + $gotLines = explode("\n", $this->client->getLastRawRequest()); $this->assertEquals(count($expectedLines), count($gotLines)); @@ -473,16 +471,16 @@ public function testMultibyteRawPostDataLaminas2098() HTTPClient::class )); } - $this->_client->setAdapter(Test::class); - $this->_client->setUri('http://example.com'); + $this->client->setAdapter(Test::class); + $this->client->setUri('http://example.com'); $bodyFile = __DIR__ . '/_files/Laminas2098-multibytepostdata.txt'; - $this->_client->setRawBody(file_get_contents($bodyFile)); - $this->_client->setEncType('text/plain'); - $this->_client->setMethod('POST'); - $this->_client->send(); - $request = $this->_client->getLastRawRequest(); + $this->client->setRawBody(file_get_contents($bodyFile)); + $this->client->setEncType('text/plain'); + $this->client->setMethod('POST'); + $this->client->send(); + $request = $this->client->getLastRawRequest(); if (! preg_match('/^content-length:\s+(\d+)/mi', $request, $match)) { $this->fail('Unable to find content-length header in request'); @@ -585,12 +583,12 @@ public function testEncodedCookiesInRequestHeaders() HTTPClient::class )); } - $this->_client->addCookie('foo', 'bar=baz'); - $this->_client->send(); + $this->client->addCookie('foo', 'bar=baz'); + $this->client->send(); $cookieValue = 'Cookie: foo=' . urlencode('bar=baz'); $this->assertStringContainsString( $cookieValue, - $this->_client->getLastRawRequest(), + $this->client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=encoded_value"' ); } @@ -608,13 +606,13 @@ public function testRawCookiesInRequestHeaders() HTTPClient::class )); } - $this->_client->setOptions(['encodecookies' => false]); - $this->_client->addCookie('foo', 'bar=baz'); - $this->_client->send(); + $this->client->setOptions(['encodecookies' => false]); + $this->client->addCookie('foo', 'bar=baz'); + $this->client->send(); $cookieValue = 'Cookie: foo=bar=baz'; $this->assertStringContainsString( $cookieValue, - $this->_client->getLastRawRequest(), + $this->client->getLastRawRequest(), 'Request is expected to contain the entire cookie "keyname=raw_value"' ); } diff --git a/test/Header/AcceptTest.php b/test/Header/AcceptTest.php index 6ebe1ba4..e183e227 100644 --- a/test/Header/AcceptTest.php +++ b/test/Header/AcceptTest.php @@ -130,12 +130,12 @@ public function testPrios() { $values = [ 'invalidPrio' => false, - -0.0001 => false, - 1.0001 => false, - 1.000 => true, - 0.999 => true, - 0.000 => true, - 0.001 => true, + '-0.0001' => false, + '1.0001' => false, + '1.000' => true, + '0.999' => true, + '0.000' => true, + '0.001' => true, 1 => true, 0 => true, ]; diff --git a/test/Header/DateTest.php b/test/Header/DateTest.php index b4a42533..4f87a934 100644 --- a/test/Header/DateTest.php +++ b/test/Header/DateTest.php @@ -35,7 +35,7 @@ public function testDateFromTimeStringCreatesValidDateHeader() $this->assertInstanceOf(HeaderInterface::class, $dateHeader); $this->assertInstanceOf(Date::class, $dateHeader); - $date = new DateTime(null, new DateTimeZone('GMT')); + $date = new DateTime('now', new DateTimeZone('GMT')); $interval = $dateHeader->date()->diff($date, 1); if (PHP_VERSION_ID >= 70200) { @@ -54,7 +54,7 @@ public function testDateFromTimestampCreatesValidDateHeader() $this->assertInstanceOf(HeaderInterface::class, $dateHeader); $this->assertInstanceOf(Date::class, $dateHeader); - $date = new DateTime(null, new DateTimeZone('GMT')); + $date = new DateTime('now', new DateTimeZone('GMT')); $interval = $dateHeader->date()->diff($date, 1); if (PHP_VERSION_ID >= 70200) { From 1f3ba9d461d3c3a7ba8a8648c8049829de2222d6 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 13:39:32 -0500 Subject: [PATCH 5/9] fix: pull in laminas-uri 2.9.1 to pickup fix detected when testing laminas-http Signed-off-by: Matthew Weier O'Phinney --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 4284db42..642144a1 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": "^7.3 || ~8.0.0 || ~8.1.0", "laminas/laminas-loader": "^2.8", "laminas/laminas-stdlib": "^3.6", - "laminas/laminas-uri": "^2.9", + "laminas/laminas-uri": "^2.9.1", "laminas/laminas-validator": "^2.15" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 6c554eab..c4c0dbe7 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": "6156759afffef21f7325de36a76338df", + "content-hash": "3bfcee73d78e113600374665bbe4e8a0", "packages": [ { "name": "container-interop/container-interop", @@ -221,16 +221,16 @@ }, { "name": "laminas/laminas-uri", - "version": "2.9.0", + "version": "2.9.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-uri.git", - "reference": "34c9386b7058bd52b3ea3b150bb34e0c97812c55" + "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/34c9386b7058bd52b3ea3b150bb34e0c97812c55", - "reference": "34c9386b7058bd52b3ea3b150bb34e0c97812c55", + "url": "https://api.github.com/repos/laminas/laminas-uri/zipball/7e837dc15c8fd3949df7d1213246fd7c8640032b", + "reference": "7e837dc15c8fd3949df7d1213246fd7c8640032b", "shasum": "" }, "require": { @@ -275,7 +275,7 @@ "type": "community_bridge" } ], - "time": "2021-09-09T13:57:23+00:00" + "time": "2021-09-09T18:37:15+00:00" }, { "name": "laminas/laminas-validator", From 72380a8f2aadc096637ca148116ff4cdcf227208 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 14:37:26 -0500 Subject: [PATCH 6/9] qa: fix how we attempt to install apache2 There's a bug in the apache2 package whereby one hook writes to the /etc/apache2/sites-available/000-default.conf file, and then a later one attempts to do so as well, thus creating a conflict situation. Providing the `-o Dpkg::Options::="--force-confnew"` option ensures the new version from the later hook is installed. In the end, it doesn't matter which one is installed, because we write over it, but without this, the installation fails. Signed-off-by: Matthew Weier O'Phinney --- .laminas-ci/pre-run.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.laminas-ci/pre-run.sh b/.laminas-ci/pre-run.sh index 3e09684c..442caa39 100755 --- a/.laminas-ci/pre-run.sh +++ b/.laminas-ci/pre-run.sh @@ -19,17 +19,19 @@ cp .laminas-ci/phpunit.xml phpunit.xml # Install dependendies apt update -qq -apt install -y apache2 php${PHP_VERSION}-fpm +# Hack because apache2 package attempts to write to 000-default.conf twice +apt-get install -o Dpkg::Options::="--force-confnew" -y apache2 +apt install -y "php${PHP_VERSION}-fpm" # Enable required modules a2enmod rewrite actions proxy_fcgi setenvif alias -a2enconf php${PHP_VERSION}-fpm +a2enconf "php${PHP_VERSION}-fpm" # Setup and start php-fpm -echo "cgi.fix_pathinfo = 1" >> /etc/php/${PHP_VERSION}/fpm/php.ini -sed -i -e "s,www-data,${TEST_USER},g" /etc/php/${PHP_VERSION}/fpm/pool.d/www.conf +echo "cgi.fix_pathinfo = 1" >> "/etc/php/${PHP_VERSION}/fpm/php.ini" +sed -i -e "s,www-data,${TEST_USER},g" "/etc/php/${PHP_VERSION}/fpm/pool.d/www.conf" sed -i -e "s,www-data,${TEST_USER},g" /etc/apache2/envvars -service php${PHP_VERSION}-fpm start +service "php${PHP_VERSION}-fpm" start # configure apache virtual hosts echo "ServerName 127.0.0.1" >> /etc/apache2/apache2.conf From 2360099a850c85820381f8c4303aeddca1463f9e Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 14:47:52 -0500 Subject: [PATCH 7/9] fix: Fix errors flagged during CI testing Signed-off-by: Matthew Weier O'Phinney --- src/Client/Adapter/Socket.php | 2 +- test/Client/CurlTest.php | 8 ++++---- test/Client/SocketTest.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Client/Adapter/Socket.php b/src/Client/Adapter/Socket.php index d54ee401..44dfcb5c 100644 --- a/src/Client/Adapter/Socket.php +++ b/src/Client/Adapter/Socket.php @@ -230,7 +230,7 @@ public function connect($host, $port = 80, $secure = false) // If we are connected to the wrong host, disconnect first $connectedTo = $this->connectedTo[0] ?? ''; $connectedHost = strpos($connectedTo, '://') - ? substr($connectedTo, strpos($connectedTo, '://') + 3, strlen($this->connectedTo)) + ? substr($connectedTo, strpos($connectedTo, '://') + 3, strlen($connectedTo)) : $connectedTo; if ($connectedHost !== $host || $this->connectedTo[1] !== $port) { diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 7cea064d..bd4673e3 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -111,13 +111,13 @@ public function testConfigSetAsTraversable() 'nested' => [ 'item' => 'value', ], - ], ArrayObject::ARRAY_AS_PROPS); + ]); $this->adapter->setOptions($config); $hasConfig = $this->adapter->getConfig(); - $this->assertEquals($config->timeout, $hasConfig['timeout']); - $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); + $this->assertEquals($config['timeout'], $hasConfig['timeout']); + $this->assertEquals($config['nested']['item'], $hasConfig['nested']['item']); } /** @psalm-return array */ @@ -584,6 +584,6 @@ public function testMustRemoveProxyConnectionEstablishedLine() $response = $this->client->getResponse(); $this->assertSame(200, $response->getStatusCode()); - $this->assertSame('HTTP/1.1 200 OK', trim(strstr($response, "\n", true))); + $this->assertMatchesRegularExpression('#^HTTP/1.(0|1) 200 OK$#', trim(strstr($response, "\n", true))); } } diff --git a/test/Client/SocketTest.php b/test/Client/SocketTest.php index d7884181..d495271b 100644 --- a/test/Client/SocketTest.php +++ b/test/Client/SocketTest.php @@ -150,13 +150,13 @@ public function testConfigSetAsTraversable() 'nested' => [ 'item' => 'value', ], - ], ArrayObject::ARRAY_AS_PROPS); + ]); $this->adapter->setOptions($config); $hasConfig = $this->adapter->getConfig(); - $this->assertEquals($config->timeout, $hasConfig['timeout']); - $this->assertEquals($config->nested->item, $hasConfig['nested']['item']); + $this->assertEquals($config['timeout'], $hasConfig['timeout']); + $this->assertEquals($config['nested']['item'], $hasConfig['nested']['item']); } /** From 952b1160fc57703c677f635806bdf170b34cff55 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 14:56:06 -0500 Subject: [PATCH 8/9] qa: on PHP 8.1, use php-builder specific tools for enabling fpm SAPI with apache Signed-off-by: Matthew Weier O'Phinney --- .laminas-ci/pre-run.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.laminas-ci/pre-run.sh b/.laminas-ci/pre-run.sh index 442caa39..fed82a59 100755 --- a/.laminas-ci/pre-run.sh +++ b/.laminas-ci/pre-run.sh @@ -21,7 +21,11 @@ cp .laminas-ci/phpunit.xml phpunit.xml apt update -qq # Hack because apache2 package attempts to write to 000-default.conf twice apt-get install -o Dpkg::Options::="--force-confnew" -y apache2 -apt install -y "php${PHP_VERSION}-fpm" +if [[ "${PHP_VERSION}" == "8.1" ]];then + switch_sapi -v 8.1 -s fpm:apache +else + apt install -y "php${PHP_VERSION}-fpm" +fi # Enable required modules a2enmod rewrite actions proxy_fcgi setenvif alias From 3fded87e0f88c716ca4147f9b3be064d74bdb654 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 9 Sep 2021 15:01:26 -0500 Subject: [PATCH 9/9] qa: disable fpm enablement on PHP 8.1 Testing if this is necessary, or in fact causing issues Signed-off-by: Matthew Weier O'Phinney --- .laminas-ci/pre-run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.laminas-ci/pre-run.sh b/.laminas-ci/pre-run.sh index fed82a59..066311cb 100755 --- a/.laminas-ci/pre-run.sh +++ b/.laminas-ci/pre-run.sh @@ -22,7 +22,9 @@ apt update -qq # Hack because apache2 package attempts to write to 000-default.conf twice apt-get install -o Dpkg::Options::="--force-confnew" -y apache2 if [[ "${PHP_VERSION}" == "8.1" ]];then - switch_sapi -v 8.1 -s fpm:apache + # This might not be necessary + # switch_sapi -v 8.1 -s fpm:apache + echo "Skipping FPM installation on PHP 8.1" else apt install -y "php${PHP_VERSION}-fpm" fi