diff --git a/.gitignore b/.gitignore index 36b6252..48048b3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ vendor/ state/*-* build/* phpunit.xml -.php_cs.cache -.php_cs.result.cache +/.phpunit.result.cache +/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..52e11a5 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,31 @@ +in(__DIR__ . '/src') + ->in(__DIR__ . '/tests'); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@Symfony' => true, + 'array_syntax' => ['syntax' => 'short'], + 'combine_consecutive_unsets' => true, + 'concat_space' => ['spacing' => 'one'], + 'return_type_declaration' => ['space_before' => 'one'], + 'no_unreachable_default_argument_value' => false, + 'yoda_style' => false, + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'increment_style' => ['style' => 'post'], + 'phpdoc_align' => ['align' => 'left'], + 'phpdoc_no_alias_tag' => false, + 'ordered_class_elements' => [ + 'order' => [ + 'use_trait', 'constant_public', 'constant_protected', 'constant_private', 'property_public', + 'property_private', 'property_protected', 'construct', 'destruct', 'magic', 'phpunit', + 'method_public_abstract', 'method_protected_abstract', 'method_public_abstract_static', + 'method_protected_abstract_static', 'method_public', 'method_protected', 'method_private', + 'method_public_static', 'method_protected_static', + ], + ], + 'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true], + ]) + ->setFinder($finder); diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index f07918d..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,19 +0,0 @@ -in(__DIR__ . '/src') - ->in(__DIR__ . '/tests'); - -return PhpCsFixer\Config::create() - ->setRules([ - '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], - 'combine_consecutive_unsets' => true, - 'concat_space' => ['spacing' => 'one'], - 'return_type_declaration' => ['space_before' => 'one'], - 'no_unreachable_default_argument_value' => false, - 'yoda_style' => false, - 'ordered_imports' => ['sortAlgorithm' => 'alpha'], - 'pre_increment' => false, - ]) - ->setFinder($finder); diff --git a/composer.json b/composer.json index fccef8d..7e568d7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "lstrojny/hmmmath": ">=0.5.0", "guzzlehttp/guzzle": "^6.5", "slim/slim": "^3.12", - "friendsofphp/php-cs-fixer": "^2.16", + "friendsofphp/php-cs-fixer": "^3.16", "sensiolabs/security-checker": "^6.0" }, "require-dev": { @@ -52,7 +52,7 @@ "@auto-scripts" ], "lint": [ - "php-cs-fixer fix --ansi --verbose --show-progress=estimating" + "php-cs-fixer fix --ansi --verbose --show-progress=dots" ], "lint:check": [ "@lint --dry-run" diff --git a/composer.lock b/composer.lock index 8a0bd9b..5f2c6e3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,34 +4,34 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7417ed59a0cf3b04e0f847f861095de9", + "content-hash": "34303a832b2bb5559b17379ecadcd749", "packages": [ { "name": "composer/pcre", - "version": "1.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560" + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/67a32d7d6f9f560b726ab25a061b38ff3a80c560", - "reference": "67a32d7d6f9f560b726ab25a061b38ff3a80c560", + "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", "shasum": "" }, "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" + "php": "^7.4 || ^8.0" }, "require-dev": { "phpstan/phpstan": "^1.3", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^4.2 || ^5" + "symfony/phpunit-bridge": "^5" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.x-dev" + "dev-main": "3.x-dev" } }, "autoload": { @@ -59,7 +59,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/1.0.1" + "source": "https://github.com/composer/pcre/tree/3.1.0" }, "funding": [ { @@ -75,7 +75,7 @@ "type": "tidelift" } ], - "time": "2022-01-21T20:24:37+00:00" + "time": "2022-11-17T09:50:14+00:00" }, { "name": "composer/semver", @@ -160,27 +160,27 @@ }, { "name": "composer/xdebug-handler", - "version": "2.0.5", + "version": "3.0.3", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a" + "reference": "ced299686f41dce890debac69273b47ffe98a40c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/9e36aeed4616366d2b690bdce11f71e9178c579a", - "reference": "9e36aeed4616366d2b690bdce11f71e9178c579a", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/ced299686f41dce890debac69273b47ffe98a40c", + "reference": "ced299686f41dce890debac69273b47ffe98a40c", "shasum": "" }, "require": { - "composer/pcre": "^1", - "php": "^5.3.2 || ^7.0 || ^8.0", + "composer/pcre": "^1 || ^2 || ^3", + "php": "^7.2.5 || ^8.0", "psr/log": "^1 || ^2 || ^3" }, "require-dev": { "phpstan/phpstan": "^1.0", "phpstan/phpstan-strict-rules": "^1.1", - "symfony/phpunit-bridge": "^4.2 || ^5.0 || ^6.0" + "symfony/phpunit-bridge": "^6.0" }, "type": "library", "autoload": { @@ -206,7 +206,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.5" + "source": "https://github.com/composer/xdebug-handler/tree/3.0.3" }, "funding": [ { @@ -222,290 +222,69 @@ "type": "tidelift" } ], - "time": "2022-02-24T20:20:32+00:00" - }, - { - "name": "doctrine/annotations", - "version": "1.14.3", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af", - "reference": "fb0d71a7393298a7b232cbf4c8b1f73f3ec3d5af", - "shasum": "" - }, - "require": { - "doctrine/lexer": "^1 || ^2", - "ext-tokenizer": "*", - "php": "^7.1 || ^8.0", - "psr/cache": "^1 || ^2 || ^3" - }, - "require-dev": { - "doctrine/cache": "^1.11 || ^2.0", - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "~1.4.10 || ^1.8.0", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "symfony/cache": "^4.4 || ^5.4 || ^6", - "vimeo/psalm": "^4.10" - }, - "suggest": { - "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "https://www.doctrine-project.org/projects/annotations.html", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "support": { - "issues": "https://github.com/doctrine/annotations/issues", - "source": "https://github.com/doctrine/annotations/tree/1.14.3" - }, - "time": "2023-02-01T09:20:38+00:00" - }, - { - "name": "doctrine/deprecations", - "version": "v1.1.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9", - "phpstan/phpstan": "1.4.10 || 1.10.15", - "phpstan/phpstan-phpunit": "^1.0", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "0.18.4", - "psr/log": "^1 || ^2 || ^3", - "vimeo/psalm": "4.30.0 || 5.12.0" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" - }, - "time": "2023-06-03T09:27:29+00:00" - }, - { - "name": "doctrine/lexer", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/lexer.git", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^10", - "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psalm/plugin-phpunit": "^0.18.3", - "vimeo/psalm": "^4.11 || ^5.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Lexer\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "https://www.doctrine-project.org/projects/lexer.html", - "keywords": [ - "annotations", - "docblock", - "lexer", - "parser", - "php" - ], - "support": { - "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/2.1.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%2Flexer", - "type": "tidelift" - } - ], - "time": "2022-12-14T08:49:07+00:00" + "time": "2022-02-25T21:32:43+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.19.3", + "version": "v3.25.1", "source": { "type": "git", - "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8" + "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", + "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/75ac86f33fab4714ea5a39a396784d83ae3b5ed8", - "reference": "75ac86f33fab4714ea5a39a396784d83ae3b5ed8", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", + "reference": "8e21d69801de6b5ecb0dbe0bcdf967b335b1260b", "shasum": "" }, "require": { - "composer/semver": "^1.4 || ^2.0 || ^3.0", - "composer/xdebug-handler": "^1.2 || ^2.0", - "doctrine/annotations": "^1.2", + "composer/semver": "^3.3", + "composer/xdebug-handler": "^3.0.3", "ext-json": "*", "ext-tokenizer": "*", - "php": "^5.6 || ^7.0 || ^8.0", - "php-cs-fixer/diff": "^1.3", - "symfony/console": "^3.4.43 || ^4.1.6 || ^5.0", - "symfony/event-dispatcher": "^3.0 || ^4.0 || ^5.0", - "symfony/filesystem": "^3.0 || ^4.0 || ^5.0", - "symfony/finder": "^3.0 || ^4.0 || ^5.0", - "symfony/options-resolver": "^3.0 || ^4.0 || ^5.0", - "symfony/polyfill-php70": "^1.0", - "symfony/polyfill-php72": "^1.4", - "symfony/process": "^3.0 || ^4.0 || ^5.0", - "symfony/stopwatch": "^3.0 || ^4.0 || ^5.0" + "php": "^7.4 || ^8.0", + "sebastian/diff": "^4.0 || ^5.0", + "symfony/console": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/filesystem": "^5.4 || ^6.0", + "symfony/finder": "^5.4 || ^6.0", + "symfony/options-resolver": "^5.4 || ^6.0", + "symfony/polyfill-mbstring": "^1.27", + "symfony/polyfill-php80": "^1.27", + "symfony/polyfill-php81": "^1.27", + "symfony/process": "^5.4 || ^6.0", + "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { - "justinrainbow/json-schema": "^5.0", - "keradus/cli-executor": "^1.4", - "mikey179/vfsstream": "^1.6", - "php-coveralls/php-coveralls": "^2.4.2", - "php-cs-fixer/accessible-object": "^1.0", + "facile-it/paraunit": "^1.3 || ^2.0", + "justinrainbow/json-schema": "^5.2", + "keradus/cli-executor": "^2.0", + "mikey179/vfsstream": "^1.6.11", + "php-coveralls/php-coveralls": "^2.5.3", + "php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1", - "phpspec/prophecy-phpunit": "^1.1 || ^2.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5", - "phpunitgoodpractices/polyfill": "^1.5", - "phpunitgoodpractices/traits": "^1.9.1", - "sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", - "symfony/phpunit-bridge": "^5.2.1", - "symfony/yaml": "^3.0 || ^4.0 || ^5.0" + "phpspec/prophecy": "^1.16", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "phpunitgoodpractices/polyfill": "^1.6", + "phpunitgoodpractices/traits": "^1.9.2", + "symfony/phpunit-bridge": "^6.2.3", + "symfony/yaml": "^5.4 || ^6.0" }, "suggest": { "ext-dom": "For handling output formats in XML", - "ext-mbstring": "For handling non-UTF8 characters.", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.", - "symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible." + "ext-mbstring": "For handling non-UTF8 characters." }, "bin": [ "php-cs-fixer" ], "type": "application", - "extra": { - "branch-alias": { - "dev-master": "2.19-dev" - } - }, "autoload": { "psr-4": { "PhpCsFixer\\": "src/" - }, - "classmap": [ - "tests/Test/AbstractFixerTestCase.php", - "tests/Test/AbstractIntegrationCaseFactory.php", - "tests/Test/AbstractIntegrationTestCase.php", - "tests/Test/Assert/AssertTokensTrait.php", - "tests/Test/IntegrationCase.php", - "tests/Test/IntegrationCaseFactory.php", - "tests/Test/IntegrationCaseFactoryInterface.php", - "tests/Test/InternalIntegrationCaseFactory.php", - "tests/Test/IsIdenticalConstraint.php", - "tests/Test/TokensWithObservedTransformers.php", - "tests/TestCase.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -522,9 +301,15 @@ } ], "description": "A tool to automatically fix PHP code style", + "keywords": [ + "Static code analysis", + "fixer", + "standards", + "static analysis" + ], "support": { - "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.19.3" + "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.25.1" }, "funding": [ { @@ -532,7 +317,7 @@ "type": "github" } ], - "time": "2021-11-15T17:17:55+00:00" + "time": "2023-09-04T01:22:52+00:00" }, { "name": "guzzlehttp/guzzle", @@ -1045,62 +830,6 @@ }, "time": "2023-08-13T19:53:39+00:00" }, - { - "name": "php-cs-fixer/diff", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/PHP-CS-Fixer/diff.git", - "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/dbd31aeb251639ac0b9e7e29405c1441907f5759", - "reference": "dbd31aeb251639ac0b9e7e29405c1441907f5759", - "shasum": "" - }, - "require": { - "php": "^5.6 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.7.23 || ^6.4.3 || ^7.0", - "symfony/process": "^3.3" - }, - "type": "library", - "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" - }, - { - "name": "SpacePossum" - } - ], - "description": "sebastian/diff v2 backport support for PHP5.6", - "homepage": "https://github.com/PHP-CS-Fixer", - "keywords": [ - "diff" - ], - "support": { - "issues": "https://github.com/PHP-CS-Fixer/diff/issues", - "source": "https://github.com/PHP-CS-Fixer/diff/tree/v1.3.1" - }, - "abandoned": true, - "time": "2020-10-14T08:39:05+00:00" - }, { "name": "pimple/pimple", "version": "v3.5.0", @@ -1154,55 +883,6 @@ }, "time": "2021-10-28T11:13:42+00:00" }, - { - "name": "psr/cache", - "version": "3.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/cache.git", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Cache\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for caching libraries", - "keywords": [ - "cache", - "psr", - "psr-6" - ], - "support": { - "source": "https://github.com/php-fig/cache/tree/3.0.0" - }, - "time": "2021-02-03T23:26:27+00:00" - }, { "name": "psr/container", "version": "1.1.2", @@ -1448,6 +1128,72 @@ }, "time": "2019-03-08T08:55:37+00:00" }, + { + "name": "sebastian/diff", + "version": "4.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", + "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.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-05-07T05:35:17+00:00" + }, { "name": "sensiolabs/security-checker", "version": "v6.0.3", @@ -1756,44 +1502,39 @@ }, { "name": "symfony/event-dispatcher", - "version": "v5.4.26", + "version": "v6.3.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac" + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/5dcc00e03413f05c1e7900090927bb7247cb0aac", - "reference": "5dcc00e03413f05c1e7900090927bb7247cb0aac", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/adb01fe097a4ee930db9258a3cc906b5beb5cf2e", + "reference": "adb01fe097a4ee930db9258a3cc906b5beb5cf2e", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/event-dispatcher-contracts": "^2|^3", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1", + "symfony/event-dispatcher-contracts": "^2.5|^3" }, "conflict": { - "symfony/dependency-injection": "<4.4" + "symfony/dependency-injection": "<5.4", + "symfony/service-contracts": "<2.5" }, "provide": { "psr/event-dispatcher-implementation": "1.0", - "symfony/event-dispatcher-implementation": "2.0" + "symfony/event-dispatcher-implementation": "2.0|3.0" }, "require-dev": { "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/error-handler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/http-foundation": "^4.4|^5.0|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/stopwatch": "^4.4|^5.0|^6.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" + "symfony/config": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/error-handler": "^5.4|^6.0", + "symfony/expression-language": "^5.4|^6.0", + "symfony/http-foundation": "^5.4|^6.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/stopwatch": "^5.4|^6.0" }, "type": "library", "autoload": { @@ -1821,7 +1562,7 @@ "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.26" + "source": "https://github.com/symfony/event-dispatcher/tree/v6.3.2" }, "funding": [ { @@ -1837,7 +1578,7 @@ "type": "tidelift" } ], - "time": "2023-07-06T06:34:20+00:00" + "time": "2023-07-06T06:56:43+00:00" }, { "name": "symfony/event-dispatcher-contracts", @@ -1917,23 +1658,22 @@ }, { "name": "symfony/filesystem", - "version": "v5.4.25", + "version": "v6.3.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364" + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", + "reference": "edd36776956f2a6fcf577edb5b05eb0e3bdc52ae", "shasum": "" }, "require": { - "php": ">=7.2.5", + "php": ">=8.1", "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-mbstring": "~1.8" }, "type": "library", "autoload": { @@ -1961,7 +1701,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.25" + "source": "https://github.com/symfony/filesystem/tree/v6.3.1" }, "funding": [ { @@ -1977,26 +1717,27 @@ "type": "tidelift" } ], - "time": "2023-05-31T13:04:02+00:00" + "time": "2023-06-01T08:30:39+00:00" }, { "name": "symfony/finder", - "version": "v5.4.27", + "version": "v6.3.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d" + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/ff4bce3c33451e7ec778070e45bd23f74214cd5d", - "reference": "ff4bce3c33451e7ec778070e45bd23f74214cd5d", + "url": "https://api.github.com/repos/symfony/finder/zipball/9915db259f67d21eefee768c1abcf1cc61b1fc9e", + "reference": "9915db259f67d21eefee768c1abcf1cc61b1fc9e", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1" + }, + "require-dev": { + "symfony/filesystem": "^6.0" }, "type": "library", "autoload": { @@ -2024,7 +1765,7 @@ "description": "Finds files and directories via an intuitive fluent interface", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/finder/tree/v5.4.27" + "source": "https://github.com/symfony/finder/tree/v6.3.3" }, "funding": [ { @@ -2040,7 +1781,7 @@ "type": "tidelift" } ], - "time": "2023-07-31T08:02:31+00:00" + "time": "2023-07-31T08:31:44+00:00" }, { "name": "symfony/http-client", @@ -2297,23 +2038,21 @@ }, { "name": "symfony/options-resolver", - "version": "v5.4.21", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9" + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", - "reference": "4fe5cf6ede71096839f0e4b4444d65dd3a7c1eb9", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a10f19f5198d589d5c33333cffe98dc9820332dd", + "reference": "a10f19f5198d589d5c33333cffe98dc9820332dd", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-php73": "~1.0", - "symfony/polyfill-php80": "^1.16" + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3" }, "type": "library", "autoload": { @@ -2346,7 +2085,7 @@ "options" ], "support": { - "source": "https://github.com/symfony/options-resolver/tree/v5.4.21" + "source": "https://github.com/symfony/options-resolver/tree/v6.3.0" }, "funding": [ { @@ -2362,7 +2101,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2023-05-12T14:21:09+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2850,32 +2589,40 @@ "time": "2020-10-23T14:02:19+00:00" }, { - "name": "symfony/polyfill-php70", - "version": "v1.20.0", + "name": "symfony/polyfill-php72", + "version": "v1.28.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644" + "url": "https://github.com/symfony/polyfill-php72.git", + "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/5f03a781d984aae42cebd18e7912fa80f02ee644", - "reference": "5f03a781d984aae42cebd18e7912fa80f02ee644", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", + "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", "shasum": "" }, "require": { "php": ">=7.1" }, - "type": "metapackage", + "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" } }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php72\\": "" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" @@ -2890,7 +2637,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -2899,7 +2646,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php70/tree/v1.20.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" }, "funding": [ { @@ -2915,20 +2662,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { - "name": "symfony/polyfill-php72", + "name": "symfony/polyfill-php73", "version": "v1.28.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", "shasum": "" }, "require": { @@ -2949,8 +2696,11 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - } + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2966,7 +2716,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -2975,7 +2725,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" }, "funding": [ { @@ -2994,17 +2744,17 @@ "time": "2023-01-26T09:26:14+00:00" }, { - "name": "symfony/polyfill-php73", + "name": "symfony/polyfill-php80", "version": "v1.28.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fe2f306d1d9d346a7fee353d0d5012e401e984b5", - "reference": "fe2f306d1d9d346a7fee353d0d5012e401e984b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -3025,7 +2775,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, "classmap": [ "Resources/stubs" @@ -3036,6 +2786,10 @@ "MIT" ], "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -3045,7 +2799,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -3054,7 +2808,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" }, "funding": [ { @@ -3073,17 +2827,17 @@ "time": "2023-01-26T09:26:14+00:00" }, { - "name": "symfony/polyfill-php80", + "name": "symfony/polyfill-php81", "version": "v1.28.0", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/7581cd600fa9fd681b797d00b02f068e2f13263b", + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", "shasum": "" }, "require": { @@ -3104,7 +2858,7 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" + "Symfony\\Polyfill\\Php81\\": "" }, "classmap": [ "Resources/stubs" @@ -3115,10 +2869,6 @@ "MIT" ], "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, { "name": "Nicolas Grekas", "email": "p@tchwork.com" @@ -3128,7 +2878,7 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", @@ -3137,7 +2887,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.28.0" }, "funding": [ { @@ -3302,21 +3052,21 @@ }, { "name": "symfony/stopwatch", - "version": "v5.4.21", + "version": "v6.3.0", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee" + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/f83692cd869a6f2391691d40a01e8acb89e76fee", - "reference": "f83692cd869a6f2391691d40a01e8acb89e76fee", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", + "reference": "fc47f1015ec80927ff64ba9094dfe8b9d48fe9f2", "shasum": "" }, "require": { - "php": ">=7.2.5", - "symfony/service-contracts": "^1|^2|^3" + "php": ">=8.1", + "symfony/service-contracts": "^2.5|^3" }, "type": "library", "autoload": { @@ -3344,7 +3094,7 @@ "description": "Provides a way to profile code", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/stopwatch/tree/v5.4.21" + "source": "https://github.com/symfony/stopwatch/tree/v6.3.0" }, "funding": [ { @@ -3360,7 +3110,7 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:03:56+00:00" + "time": "2023-02-16T10:14:28+00:00" }, { "name": "symfony/string", @@ -4482,72 +4232,6 @@ ], "time": "2020-10-26T15:52:27+00:00" }, - { - "name": "sebastian/diff", - "version": "4.0.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "reference": "74be17022044ebaaecfdf0c5cd504fc9cd5a7131", - "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.5" - }, - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2023-05-07T05:35:17+00:00" - }, { "name": "sebastian/environment", "version": "5.1.5", diff --git a/src/Matcher/AbstractMatcher.php b/src/Matcher/AbstractMatcher.php index dbbc577..f341919 100644 --- a/src/Matcher/AbstractMatcher.php +++ b/src/Matcher/AbstractMatcher.php @@ -10,24 +10,13 @@ abstract class AbstractMatcher implements MatcherInterface { protected $extractor; + abstract protected function createMatcher(); + public function setExtractor(Closure $extractor) { $this->extractor = $extractor; } - protected function createExtractor() - { - if (!$this->extractor) { - return static function (Request $request) { - return $request; - }; - } - - return $this->extractor; - } - - abstract protected function createMatcher(); - public function getMatcher() { $matcher = new SerializableClosure($this->createMatcher()); @@ -39,4 +28,15 @@ static function (Request $request) use ($matcher, $extractor) { } ); } + + protected function createExtractor() + { + if (!$this->extractor) { + return static function (Request $request) { + return $request; + }; + } + + return $this->extractor; + } } diff --git a/src/PHPUnit/HttpMockFacade.php b/src/PHPUnit/HttpMockFacade.php index 818a809..c7c9afd 100644 --- a/src/PHPUnit/HttpMockFacade.php +++ b/src/PHPUnit/HttpMockFacade.php @@ -11,11 +11,11 @@ use RuntimeException; /** - * @property Server $server The HTTP mock server that is currently running - * @property MatcherFactory $matches An instance of the matcher factory - * @property MockBuilder $mock An instance of the mock builder + * @property Server $server The HTTP mock server that is currently running + * @property MatcherFactory $matches An instance of the matcher factory + * @property MockBuilder $mock An instance of the mock builder * @property RequestCollectionFacade $requests Convenient access to recorded requests - * @property Client $client A pre configured HTTP for client for the currently running server + * @property Client $client A pre configured HTTP for client for the currently running server */ class HttpMockFacade { @@ -32,9 +32,18 @@ public function __construct($port, $host, $basePath) $this->basePath = $basePath; } - public static function getProperties() + public function __get($property) { - return ['server', 'matches', 'mock', 'requests', 'client']; + if (isset($this->services[$property])) { + return $this->services[$property]; + } + + return $this->services[$property] = $this->createService($property); + } + + public function __clone() + { + $this->server->clean(); } public function setUp() @@ -42,13 +51,9 @@ public function setUp() $this->server->setUp($this->mock->flushExpectations()); } - public function __get($property) + public function each(callable $callback) { - if (isset($this->services[$property])) { - return $this->services[$property]; - } - - return $this->services[$property] = $this->createService($property); + $callback($this); } private function createService($property) @@ -76,13 +81,8 @@ private function createService($property) } } - public function __clone() - { - $this->server->clean(); - } - - public function each(callable $callback) + public static function getProperties() { - $callback($this); + return ['server', 'matches', 'mock', 'requests', 'client']; } } diff --git a/src/PHPUnit/HttpMockFacadeMap.php b/src/PHPUnit/HttpMockFacadeMap.php index 10d07a6..1bb8c15 100644 --- a/src/PHPUnit/HttpMockFacadeMap.php +++ b/src/PHPUnit/HttpMockFacadeMap.php @@ -17,6 +17,25 @@ public function __construct(array $facadeMap) $this->facadeMap = $facadeMap; } + public function __clone() + { + $this->facadeMap = array_map( + static function (HttpMockFacade $facade) { + return clone $facade; + }, + $this->facadeMap + ); + } + + public function __get($property) + { + if (in_array($property, HttpMockFacade::getProperties(), true)) { + throw new OutOfBoundsException(sprintf('Tried to access facade property "%1$s" on facade map. First select one of the facades from the map. Defined facades: "%2$s", try $this->http[\'%s\']->%1$s->…', $property, implode('", "', array_keys($this->facadeMap)), current(array_keys($this->facadeMap)))); + } + + throw new OutOfBoundsException(sprintf('Tried to access property "%1$s". This is a map of facades, try $this->http[\'%1$s\'] instead.', $property)); + } + public function offsetGet($offset) { if (!$this->offsetExists($offset)) { @@ -41,30 +60,11 @@ public function offsetUnset($offset) throw new BadMethodCallException(__METHOD__); } - public function __clone() - { - $this->facadeMap = array_map( - static function (HttpMockFacade $facade) { - return clone $facade; - }, - $this->facadeMap - ); - } - public function each(callable $callback) { array_map($callback, $this->facadeMap); } - public function __get($property) - { - if (in_array($property, HttpMockFacade::getProperties(), true)) { - throw new OutOfBoundsException(sprintf('Tried to access facade property "%1$s" on facade map. First select one of the facades from ' . 'the map. Defined facades: "%2$s", try $this->http[\'%s\']->%1$s->…', $property, implode('", "', array_keys($this->facadeMap)), current(array_keys($this->facadeMap)))); - } - - throw new OutOfBoundsException(sprintf('Tried to access property "%1$s". This is a map of facades, try $this->http[\'%1$s\'] instead.', $property)); - } - public function all() { return $this->facadeMap; diff --git a/src/PHPUnit/HttpMockTrait.php b/src/PHPUnit/HttpMockTrait.php index f976a08..cb2687a 100644 --- a/src/PHPUnit/HttpMockTrait.php +++ b/src/PHPUnit/HttpMockTrait.php @@ -4,6 +4,38 @@ trait HttpMockTrait { + /** @var HttpMockFacade|HttpMockFacadeMap */ + protected static $staticHttp; + + /** @var HttpMockFacade|HttpMockFacadeMap */ + protected $http; + + protected function setUpHttpMock() + { + static::assertHttpMockSetup(); + + $this->http = clone static::$staticHttp; + } + + protected function tearDownHttpMock() + { + if (!$this->http) { + return; + } + + $http = $this->http; + $this->http = null; + $http->each( + function (HttpMockFacade $facade) { + $this->assertSame( + '', + (string) $facade->server->getIncrementalErrorOutput(), + 'HTTP mock server standard error output should be empty' + ); + } + ); + } + public static function getHttpMockDefaultPort() { return 28080; @@ -14,12 +46,6 @@ public static function getHttpMockDefaultHost() return 'localhost'; } - /** @var HttpMockFacade|HttpMockFacadeMap */ - protected static $staticHttp; - - /** @var HttpMockFacade|HttpMockFacadeMap */ - protected $http; - protected static function setUpHttpMockBeforeClass($port = null, $host = null, $basePath = null, $name = null) { $port = $port ?: static::getHttpMockDefaultPort(); @@ -38,13 +64,6 @@ protected static function setUpHttpMockBeforeClass($port = null, $host = null, $ ServerManager::getInstance()->add($facade->server); } - protected function setUpHttpMock() - { - static::assertHttpMockSetup(); - - $this->http = clone static::$staticHttp; - } - protected static function assertHttpMockSetup() { if (!static::$staticHttp) { @@ -58,25 +77,6 @@ protected static function assertHttpMockSetup() } } - protected function tearDownHttpMock() - { - if (!$this->http) { - return; - } - - $http = $this->http; - $this->http = null; - $http->each( - function (HttpMockFacade $facade) { - $this->assertSame( - '', - (string) $facade->server->getIncrementalErrorOutput(), - 'HTTP mock server standard error output should be empty' - ); - } - ); - } - protected static function tearDownHttpMockAfterClass() { static::$staticHttp->each( diff --git a/src/PHPUnit/ServerManager.php b/src/PHPUnit/ServerManager.php index e8b14ad..cb16288 100644 --- a/src/PHPUnit/ServerManager.php +++ b/src/PHPUnit/ServerManager.php @@ -14,16 +14,14 @@ final class ServerManager private static $instance; - /** - * @return self - */ - public static function getInstance() + private function __construct() { - if (!static::$instance) { - static::$instance = new static(); - } + $this->servers = new SplObjectStorage(); + register_shutdown_function([$this, 'cleanup']); + } - return static::$instance; + private function __clone() + { } public function add(Server $server) @@ -43,13 +41,15 @@ public function cleanup() } } - private function __construct() + /** + * @return self + */ + public static function getInstance() { - $this->servers = new SplObjectStorage(); - register_shutdown_function([$this, 'cleanup']); - } + if (!static::$instance) { + static::$instance = new static(); + } - private function __clone() - { + return static::$instance; } } diff --git a/src/RequestCollectionFacade.php b/src/RequestCollectionFacade.php index 33f78c9..3daee48 100644 --- a/src/RequestCollectionFacade.php +++ b/src/RequestCollectionFacade.php @@ -4,7 +4,9 @@ use Countable; use GuzzleHttp\Client; + use function GuzzleHttp\Psr7\parse_request; + use GuzzleHttp\Psr7\Request; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; diff --git a/src/RequestStorage.php b/src/RequestStorage.php index 0191d7d..394dc47 100644 --- a/src/RequestStorage.php +++ b/src/RequestStorage.php @@ -48,11 +48,6 @@ public function prepend(Request $request, $name, $data) $this->store($request, $name, $list); } - private function getFileName(Request $request, $name) - { - return $this->directory . $this->pid . '-' . $name . '-' . $request->getUri()->getPort(); - } - public function clear(Request $request, $name) { $fileName = $this->getFileName($request, $name); @@ -61,4 +56,9 @@ public function clear(Request $request, $name) unlink($fileName); } } + + private function getFileName(Request $request, $name) + { + return $this->directory . $this->pid . '-' . $name . '-' . $request->getUri()->getPort(); + } } diff --git a/src/ResponseBuilder.php b/src/ResponseBuilder.php index 8d8d108..70728f8 100644 --- a/src/ResponseBuilder.php +++ b/src/ResponseBuilder.php @@ -4,7 +4,9 @@ use Closure; use GuzzleHttp\Psr7\Response; + use function GuzzleHttp\Psr7\stream_for; + use Psr\Http\Message\ResponseInterface; use SuperClosure\SerializableClosure; use SuperClosure\SerializerInterface; diff --git a/src/Server.php b/src/Server.php index 47743d0..1b79352 100644 --- a/src/Server.php +++ b/src/Server.php @@ -2,6 +2,7 @@ namespace InterNations\Component\HttpMock; +use Exception; use GuzzleHttp\Client; use hmmmath\Fibonacci\FibonacciFactory; use RuntimeException; @@ -36,6 +37,31 @@ public function __construct($port, $host) $this->setTimeout(null); } + /** + * @param Expectation[] $expectations + * + * @throws RuntimeException + */ + public function setUp(array $expectations) + { + /** @var Expectation $expectation */ + foreach ($expectations as $expectation) { + $response = $this->getClient()->post( + '/_expectation', + ['json' => [ + 'matcher' => serialize($expectation->getMatcherClosures()), + 'limiter' => serialize($expectation->getLimiter()), + 'response' => Util::serializePsrMessage($expectation->getResponse()), + 'responseCallback' => serialize($expectation->getResponseCallback()), + ]] + ); + + if ($response->getStatusCode() !== 201) { + throw new RuntimeException('Could not set up expectations: ' . $response->getBody()->getContents()); + } + } + } + public function start(callable $callback = null, array $env = []) { parent::start($callback, $env); @@ -53,11 +79,6 @@ public function getClient() return $this->client ?: $this->client = $this->createClient(); } - private function createClient() - { - return new Client(['base_uri' => $this->getBaseUrl(), 'http_errors' => false]); - } - public function getBaseUrl() { return sprintf('http://%s', $this->getConnectionString()); @@ -68,31 +89,6 @@ public function getConnectionString() return sprintf('%s:%d', $this->host, $this->port); } - /** - * @param Expectation[] $expectations - * - * @throws RuntimeException - */ - public function setUp(array $expectations) - { - /** @var Expectation $expectation */ - foreach ($expectations as $expectation) { - $response = $this->getClient()->post( - '/_expectation', - ['json' => [ - 'matcher' => serialize($expectation->getMatcherClosures()), - 'limiter' => serialize($expectation->getLimiter()), - 'response' => Util::serializePsrMessage($expectation->getResponse()), - 'responseCallback' => serialize($expectation->getResponseCallback()), - ]] - ); - - if ($response->getStatusCode() !== 201) { - throw new RuntimeException('Could not set up expectations: ' . $response->getBody()->getContents()); - } - } - } - public function clean() { if (!$this->isRunning()) { @@ -102,6 +98,21 @@ public function clean() $this->getClient()->delete('/_all'); } + public function getIncrementalErrorOutput() + { + return self::cleanErrorOutput(parent::getIncrementalErrorOutput()); + } + + public function getErrorOutput() + { + return self::cleanErrorOutput(parent::getErrorOutput()); + } + + private function createClient() + { + return new Client(['base_uri' => $this->getBaseUrl(), 'http_errors' => false]); + } + private function pollWait() { foreach (FibonacciFactory::sequence(50000, 10000) as $sleepTime) { @@ -109,22 +120,12 @@ private function pollWait() usleep($sleepTime); $this->getClient()->head('/_me'); break; - } catch (\Exception $e) { + } catch (Exception $e) { continue; } } } - public function getIncrementalErrorOutput() - { - return self::cleanErrorOutput(parent::getIncrementalErrorOutput()); - } - - public function getErrorOutput() - { - return self::cleanErrorOutput(parent::getErrorOutput()); - } - private static function cleanErrorOutput($output) { if (!trim($output)) { @@ -149,7 +150,7 @@ private static function cleanErrorOutput($output) private static function stringEndsWithAny($haystack, array $needles) { foreach ($needles as $needle) { - if (substr($haystack, (-1 * strlen($needle))) === $needle) { + if (substr($haystack, -1 * strlen($needle)) === $needle) { return true; } } diff --git a/src/Util.php b/src/Util.php index b0283f9..9571dd4 100644 --- a/src/Util.php +++ b/src/Util.php @@ -4,6 +4,7 @@ use function GuzzleHttp\Psr7\parse_response; use function GuzzleHttp\Psr7\str; + use UnexpectedValueException; final class Util diff --git a/src/app.php b/src/app.php index f5e4684..0c6075a 100644 --- a/src/app.php +++ b/src/app.php @@ -127,7 +127,7 @@ function (Request $request, Response $response) use ($container) { ); $container['phpErrorHandler'] = function ($container) { - return function (Request $request, Response $response, Error $e) use ($container) { + return function (Request $request, Response $response, Error $e) { return $response->withStatus(500) ->withHeader('Content-Type', 'text/plain') ->write($e->getMessage() . "\n" . $e->getTraceAsString() . "\n"); @@ -166,7 +166,7 @@ function (Request $request, Response $response) use ($container) { continue; } - ++$expectations[$pos]['runs']; + $expectations[$pos]['runs']++; $container['storage']->store($request, 'expectations', $expectations); $r = Util::responseDeserialize($expectation['response']); @@ -188,7 +188,7 @@ function (Request $request, Response $response) use ($container) { }; $container['errorHandler'] = function ($container) { - return function (Request $request, Response $response, Exception $e) use ($container) { + return function (Request $request, Response $response, Exception $e) { return $response->withStatus(StatusCode::HTTP_INTERNAL_SERVER_ERROR)->write( 'Server error: ' . $e->getMessage()); }; diff --git a/tests/AppIntegrationTest.php b/tests/AppIntegrationTest.php index a63e6a4..d8630e6 100644 --- a/tests/AppIntegrationTest.php +++ b/tests/AppIntegrationTest.php @@ -12,6 +12,7 @@ /** * @large + * * @group integration */ class AppIntegrationTest extends AbstractTestCase @@ -38,7 +39,7 @@ public static function tearDownAfterClass() static::assertSame('', $out, $out); $out = (string) static::$server1->getErrorOutput(); - //static::assertSame('', $out, $out); + // static::assertSame('', $out, $out); echo $out . "\n"; static::$server1->stop(); diff --git a/tests/MockBuilderIntegrationTest.php b/tests/MockBuilderIntegrationTest.php index f38b28b..75eee29 100644 --- a/tests/MockBuilderIntegrationTest.php +++ b/tests/MockBuilderIntegrationTest.php @@ -13,6 +13,7 @@ /** * @large + * * @group integration */ class MockBuilderIntegrationTest extends TestCase @@ -75,7 +76,7 @@ public function testCreateExpectation() $unserializedClosure = unserialize(serialize($closure)); $this->assertTrue($unserializedClosure($request)); - ++$run; + $run++; } ini_set('error_log', $oldValue); $this->assertSame(3, $run); diff --git a/tests/PHPUnit/HttpMockMultiPHPUnitIntegrationTest.php b/tests/PHPUnit/HttpMockMultiPHPUnitIntegrationTest.php index 639f88b..8fb9008 100644 --- a/tests/PHPUnit/HttpMockMultiPHPUnitIntegrationTest.php +++ b/tests/PHPUnit/HttpMockMultiPHPUnitIntegrationTest.php @@ -2,6 +2,7 @@ namespace InterNations\Component\HttpMock\Tests\PHPUnit; +use Exception; use InterNations\Component\HttpMock\PHPUnit\HttpMockTrait; use InterNations\Component\Testing\AbstractTestCase; use PHPUnit\Framework\TestCase; @@ -33,16 +34,6 @@ public function tearDown() $this->tearDownHttpMock(); } - public static function getPaths() - { - return [ - [ - '/foo', - '/bar', - ], - ]; - } - /** @dataProvider getPaths */ public function testSimpleRequest($path) { @@ -103,7 +94,7 @@ public function testErrorLogOutput() try { $this->tearDown(); $this->fail('Exception expected'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertContains('HTTP mock server standard error output should be empty', $e->getMessage()); } } @@ -268,4 +259,14 @@ public function testFatalError() $this->expectExceptionMessage('Cannot instantiate abstract class'); new TestCase(); } + + public static function getPaths() + { + return [ + [ + '/foo', + '/bar', + ], + ]; + } } diff --git a/tests/PHPUnit/HttpMockPHPUnitIntegrationBasePathTest.php b/tests/PHPUnit/HttpMockPHPUnitIntegrationBasePathTest.php index 4718c37..9221ec6 100644 --- a/tests/PHPUnit/HttpMockPHPUnitIntegrationBasePathTest.php +++ b/tests/PHPUnit/HttpMockPHPUnitIntegrationBasePathTest.php @@ -36,7 +36,7 @@ public function testSimpleRequest() ->when() ->pathIs('/foo') ->then() - ->body('/foo' . ' body') + ->body('/foo body') ->end(); $this->http->setUp(); diff --git a/tests/PHPUnit/HttpMockPHPUnitIntegrationTest.php b/tests/PHPUnit/HttpMockPHPUnitIntegrationTest.php index 50a8bd5..f5277dd 100644 --- a/tests/PHPUnit/HttpMockPHPUnitIntegrationTest.php +++ b/tests/PHPUnit/HttpMockPHPUnitIntegrationTest.php @@ -2,6 +2,7 @@ namespace InterNations\Component\HttpMock\Tests\PHPUnit; +use Exception; use InterNations\Component\HttpMock\PHPUnit\HttpMockTrait; use InterNations\Component\Testing\AbstractTestCase; use PHPUnit\Framework\TestCase; @@ -34,16 +35,6 @@ public function tearDown() $this->tearDownHttpMock(); } - public static function getPaths() - { - return [ - [ - '/foo', - '/bar', - ], - ]; - } - /** @dataProvider getPaths */ public function testSimpleRequest($path) { @@ -104,7 +95,7 @@ public function testErrorLogOutput() try { $this->tearDown(); $this->fail('Exception expected'); - } catch (\Exception $e) { + } catch (Exception $e) { $this->assertContains('HTTP mock server standard error output should be empty', $e->getMessage()); } } @@ -355,4 +346,14 @@ public function testFatalError() $this->expectExceptionMessage('Cannot instantiate abstract class'); new TestCase(); } + + public static function getPaths() + { + return [ + [ + '/foo', + '/bar', + ], + ]; + } } diff --git a/tests/RequestCollectionFacadeTest.php b/tests/RequestCollectionFacadeTest.php index 32615c6..c010691 100644 --- a/tests/RequestCollectionFacadeTest.php +++ b/tests/RequestCollectionFacadeTest.php @@ -29,18 +29,6 @@ public function setUp() $this->request = new Request('GET', '/_request/last'); } - public static function provideMethodAndUrls() - { - return [ - ['latest', '/_request/last'], - ['first', '/_request/first'], - ['last', '/_request/last'], - ['at', '/_request/0', [0]], - ['shift', '/_request/first', [], 'delete'], - ['pop', '/_request/last', [], 'delete'], - ]; - } - /** @dataProvider provideMethodAndUrls */ public function testRequestingLatestRequest($method, $path, array $args = [], $httpMethod = 'get') { @@ -65,11 +53,11 @@ public function testRequestLatestResponseWithHttpAuth($method, $path, array $arg $this->assertSame('RECORDED=1', (string) $request->getBody()); $this->assertSame('localhost', $request->getUri()->getHost()); $this->assertSame(1234, $request->getUri()->getPort()); - $this->assertSame('CUSTOM UA', $request->getHeaderLine(('User-Agent'))); + $this->assertSame('CUSTOM UA', $request->getHeaderLine('User-Agent')); } /** @dataProvider provideMethodAndUrls */ - public function testRequestResponse_InvalidStatusCode($method, $path, array $args = [], $httpMethod = 'get') + public function testRequestResponseInvalidStatusCode($method, $path, array $args = [], $httpMethod = 'get') { $this->mockClient($path, $this->createResponseWithInvalidStatusCode(), $httpMethod); @@ -80,7 +68,7 @@ public function testRequestResponse_InvalidStatusCode($method, $path, array $arg } /** @dataProvider provideMethodAndUrls */ - public function testRequestResponse_EmptyContentType($method, $path, array $args = [], $httpMethod = 'get') + public function testRequestResponseEmptyContentType($method, $path, array $args = [], $httpMethod = 'get') { $this->mockClient($path, $this->createResponseWithEmptyContentType(), $httpMethod); @@ -91,7 +79,7 @@ public function testRequestResponse_EmptyContentType($method, $path, array $args } /** @dataProvider provideMethodAndUrls */ - public function testRequestResponse_InvalidContentType($method, $path, array $args = [], $httpMethod = 'get') + public function testRequestResponseInvalidContentType($method, $path, array $args = [], $httpMethod = 'get') { $this->mockClient($path, $this->createResponseWithInvalidContentType(), $httpMethod); @@ -102,7 +90,7 @@ public function testRequestResponse_InvalidContentType($method, $path, array $ar } /** @dataProvider provideMethodAndUrls */ - public function testRequestResponse_DeserializationError($method, $path, array $args = [], $httpMethod = 'get') + public function testRequestResponseDeserializationError($method, $path, array $args = [], $httpMethod = 'get') { $this->mockClient($path, $this->createResponseThatCannotBeDeserialized(), $httpMethod); @@ -185,4 +173,16 @@ private function createResponseThatCannotBeDeserialized() { return new Response(200, ['Content-Type' => 'text/plain'], 'invalid response'); } + + public static function provideMethodAndUrls() + { + return [ + ['latest', '/_request/last'], + ['first', '/_request/first'], + ['last', '/_request/last'], + ['at', '/_request/0', [0]], + ['shift', '/_request/first', [], 'delete'], + ['pop', '/_request/last', [], 'delete'], + ]; + } }