From 0bdb4d78509d5ef66d1817ebdb92d33cc400431d Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 5 May 2024 15:07:52 +0100 Subject: [PATCH] Chained promise returning (#71) * test: pass existing tests for #70 functionality * build: php 8.1 compatibility * ci: use latest phpunit * ci: use latest phpunit * ci: debug phpunit * ci: debug phpunit * ci: debug phpunit * test: ensure "finally" can return its own promise * test: ensure "finally" can return its own promise * test: fix static analysis * build: ignore complexity error --- .github/workflows/ci.yml | 2 +- composer.lock | 490 ++++++++++++++------------ phpcs.xml | 1 - src/Chain/ChainFunctionTypeError.php | 6 + src/Chain/Chainable.php | 105 +++++- src/Chain/ThenChain.php | 3 +- src/Promise.php | 47 ++- test/phpunit/PromiseTest.php | 264 ++++++++++---- test/phpunit/TestPromiseContainer.php | 1 - 9 files changed, 591 insertions(+), 328 deletions(-) create mode 100644 src/Chain/ChainFunctionTypeError.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21a7d93..cb7f4b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: run: tar -xvf /tmp/github-actions/build.tar ./ - name: PHP Unit tests - uses: php-actions/phpunit@v3 + uses: php-actions/phpunit@master env: XDEBUG_MODE: cover with: diff --git a/composer.lock b/composer.lock index d145e85..d145daf 100644 --- a/composer.lock +++ b/composer.lock @@ -9,16 +9,16 @@ "packages-dev": [ { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/pcre/zipball/4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://api.github.com/repos/composer/pcre/zipball/00104306927c7a0919b4ced2aaa6782c1e61a3c9", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -60,7 +60,7 @@ ], "support": { "issues": "https://github.com/composer/pcre/issues", - "source": "https://github.com/composer/pcre/tree/3.1.0" + "source": "https://github.com/composer/pcre/tree/3.1.1" }, "funding": [ { @@ -76,7 +76,7 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/xdebug-handler", @@ -205,25 +205,27 @@ }, { "name": "nikic/php-parser", - "version": "v4.15.4", + "version": "v5.0.2", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290" + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6bb5176bc4af8bcb7d926f88718db9b96a2d4290", - "reference": "6bb5176bc4af8bcb7d926f88718db9b96a2d4290", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", "shasum": "" }, "require": { + "ext-ctype": "*", + "ext-json": "*", "ext-tokenizer": "*", - "php": ">=7.0" + "php": ">=7.4" }, "require-dev": { "ircmaxell/php-yacc": "^0.0.7", - "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "bin": [ "bin/php-parse" @@ -231,7 +233,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.9-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -255,34 +257,34 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.4" + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" }, - "time": "2023-03-05T19:49:14+00:00" + "time": "2024-03-05T20:51:40+00:00" }, { "name": "pdepend/pdepend", - "version": "2.13.0", + "version": "2.16.2", "source": { "type": "git", "url": "https://github.com/pdepend/pdepend.git", - "reference": "31be7cd4f305f3f7b52af99c1cb13fc938d1cfad" + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pdepend/pdepend/zipball/31be7cd4f305f3f7b52af99c1cb13fc938d1cfad", - "reference": "31be7cd4f305f3f7b52af99c1cb13fc938d1cfad", + "url": "https://api.github.com/repos/pdepend/pdepend/zipball/f942b208dc2a0868454d01b29f0c75bbcfc6ed58", + "reference": "f942b208dc2a0868454d01b29f0c75bbcfc6ed58", "shasum": "" }, "require": { "php": ">=5.3.7", - "symfony/config": "^2.3.0|^3|^4|^5|^6.0", - "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0", - "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0" + "symfony/config": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/dependency-injection": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/filesystem": "^2.3.0|^3|^4|^5|^6.0|^7.0", + "symfony/polyfill-mbstring": "^1.19" }, "require-dev": { "easy-doc/easy-doc": "0.0.0|^1.2.3", "gregwar/rst": "^1.0", - "phpunit/phpunit": "^4.8.36|^5.7.27", "squizlabs/php_codesniffer": "^2.0.0" }, "bin": [ @@ -304,9 +306,15 @@ "BSD-3-Clause" ], "description": "Official version of pdepend to be handled with Composer", + "keywords": [ + "PHP Depend", + "PHP_Depend", + "dev", + "pdepend" + ], "support": { "issues": "https://github.com/pdepend/pdepend/issues", - "source": "https://github.com/pdepend/pdepend/tree/2.13.0" + "source": "https://github.com/pdepend/pdepend/tree/2.16.2" }, "funding": [ { @@ -314,24 +322,25 @@ "type": "tidelift" } ], - "time": "2023-02-28T20:56:15+00:00" + "time": "2023-12-17T18:09:59+00:00" }, { "name": "phar-io/manifest", - "version": "2.0.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53" + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", - "reference": "97803eca37d319dfa7826cc2437fc020857acb53", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-phar": "*", "ext-xmlwriter": "*", "phar-io/version": "^3.0.1", @@ -372,9 +381,15 @@ "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" + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "time": "2021-07-20T11:28:43+00:00" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" }, { "name": "phar-io/version", @@ -429,22 +444,22 @@ }, { "name": "phpmd/phpmd", - "version": "2.13.0", + "version": "2.15.0", "source": { "type": "git", "url": "https://github.com/phpmd/phpmd.git", - "reference": "dad0228156856b3ad959992f9748514fa943f3e3" + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpmd/phpmd/zipball/dad0228156856b3ad959992f9748514fa943f3e3", - "reference": "dad0228156856b3ad959992f9748514fa943f3e3", + "url": "https://api.github.com/repos/phpmd/phpmd/zipball/74a1f56e33afad4128b886e334093e98e1b5e7c0", + "reference": "74a1f56e33afad4128b886e334093e98e1b5e7c0", "shasum": "" }, "require": { "composer/xdebug-handler": "^1.0 || ^2.0 || ^3.0", "ext-xml": "*", - "pdepend/pdepend": "^2.12.1", + "pdepend/pdepend": "^2.16.1", "php": ">=5.3.9" }, "require-dev": { @@ -453,8 +468,7 @@ "ext-simplexml": "*", "gregwar/rst": "^1.0", "mikey179/vfsstream": "^1.6.8", - "phpunit/phpunit": "^4.8.36 || ^5.7.27", - "squizlabs/php_codesniffer": "^2.0" + "squizlabs/php_codesniffer": "^2.9.2 || ^3.7.2" }, "bin": [ "src/bin/phpmd" @@ -491,6 +505,7 @@ "description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.", "homepage": "https://phpmd.org/", "keywords": [ + "dev", "mess detection", "mess detector", "pdepend", @@ -500,7 +515,7 @@ "support": { "irc": "irc://irc.freenode.org/phpmd", "issues": "https://github.com/phpmd/phpmd/issues", - "source": "https://github.com/phpmd/phpmd/tree/2.13.0" + "source": "https://github.com/phpmd/phpmd/tree/2.15.0" }, "funding": [ { @@ -508,20 +523,20 @@ "type": "tidelift" } ], - "time": "2022-09-10T08:44:15+00:00" + "time": "2023-12-11T08:22:20+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.14", + "version": "1.10.60", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c" + "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d232901b09e67538e5c86a724be841bea5768a7c", - "reference": "d232901b09e67538e5c86a724be841bea5768a7c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/95dcea7d6c628a3f2f56d091d8a0219485a86bbe", + "reference": "95dcea7d6c628a3f2f56d091d8a0219485a86bbe", "shasum": "" }, "require": { @@ -570,27 +585,27 @@ "type": "tidelift" } ], - "time": "2023-04-19T13:47:27+00:00" + "time": "2024-03-07T13:30:19+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "10.1.1", + "version": "10.1.12", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "884a0da7f9f46f28b2cb69134217fd810b793974" + "reference": "842f72662d6b9edda84c4b6f13885fd9cd53dc63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/884a0da7f9f46f28b2cb69134217fd810b793974", - "reference": "884a0da7f9f46f28b2cb69134217fd810b793974", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/842f72662d6b9edda84c4b6f13885fd9cd53dc63", + "reference": "842f72662d6b9edda84c4b6f13885fd9cd53dc63", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.15", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1", "phpunit/php-file-iterator": "^4.0", "phpunit/php-text-template": "^3.0", @@ -640,7 +655,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.1" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.12" }, "funding": [ { @@ -648,20 +663,20 @@ "type": "github" } ], - "time": "2023-04-17T12:15:40+00:00" + "time": "2024-03-02T07:22:05+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "4.0.1", + "version": "4.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "fd9329ab3368f59fe1fe808a189c51086bd4b6bd" + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/fd9329ab3368f59fe1fe808a189c51086bd4b6bd", - "reference": "fd9329ab3368f59fe1fe808a189c51086bd4b6bd", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", "shasum": "" }, "require": { @@ -700,7 +715,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", - "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.0.1" + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" }, "funding": [ { @@ -708,7 +724,7 @@ "type": "github" } ], - "time": "2023-02-10T16:53:14+00:00" + "time": "2023-08-31T06:24:48+00:00" }, { "name": "phpunit/php-invoker", @@ -775,16 +791,16 @@ }, { "name": "phpunit/php-text-template", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d" + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/9f3d3709577a527025f55bcf0f7ab8052c8bb37d", - "reference": "9f3d3709577a527025f55bcf0f7ab8052c8bb37d", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", "shasum": "" }, "require": { @@ -822,7 +838,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-text-template/issues", - "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" }, "funding": [ { @@ -830,7 +847,7 @@ "type": "github" } ], - "time": "2023-02-03T06:56:46+00:00" + "time": "2023-08-31T14:07:24+00:00" }, { "name": "phpunit/php-timer", @@ -893,16 +910,16 @@ }, { "name": "phpunit/phpunit", - "version": "10.1.2", + "version": "10.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b" + "reference": "0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6f0cd95be71add539f8fd2be25b2a4a29789000b", - "reference": "6f0cd95be71add539f8fd2be25b2a4a29789000b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4", + "reference": "0d968f6323deb3dbfeba5bfd4929b9415eb7a9a4", "shasum": "" }, "require": { @@ -916,7 +933,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=8.1", - "phpunit/php-code-coverage": "^10.1.1", + "phpunit/php-code-coverage": "^10.1.5", "phpunit/php-file-iterator": "^4.0", "phpunit/php-invoker": "^4.0", "phpunit/php-text-template": "^3.0", @@ -926,8 +943,8 @@ "sebastian/comparator": "^5.0", "sebastian/diff": "^5.0", "sebastian/environment": "^6.0", - "sebastian/exporter": "^5.0", - "sebastian/global-state": "^6.0", + "sebastian/exporter": "^5.1", + "sebastian/global-state": "^6.0.1", "sebastian/object-enumerator": "^5.0", "sebastian/recursion-context": "^5.0", "sebastian/type": "^4.0", @@ -942,7 +959,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "10.1-dev" + "dev-main": "10.5-dev" } }, "autoload": { @@ -974,7 +991,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/10.1.2" + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.11" }, "funding": [ { @@ -990,7 +1007,7 @@ "type": "tidelift" } ], - "time": "2023-04-22T07:38:19+00:00" + "time": "2024-02-25T14:05:00+00:00" }, { "name": "psr/container", @@ -1097,16 +1114,16 @@ }, { "name": "sebastian/cli-parser", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae" + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/efdc130dbbbb8ef0b545a994fd811725c5282cae", - "reference": "efdc130dbbbb8ef0b545a994fd811725c5282cae", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", "shasum": "" }, "require": { @@ -1141,7 +1158,8 @@ "homepage": "https://github.com/sebastianbergmann/cli-parser", "support": { "issues": "https://github.com/sebastianbergmann/cli-parser/issues", - "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.0" + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" }, "funding": [ { @@ -1149,7 +1167,7 @@ "type": "github" } ], - "time": "2023-02-03T06:58:15+00:00" + "time": "2024-03-02T07:12:49+00:00" }, { "name": "sebastian/code-unit", @@ -1264,16 +1282,16 @@ }, { "name": "sebastian/comparator", - "version": "5.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c" + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/72f01e6586e0caf6af81297897bd112eb7e9627c", - "reference": "72f01e6586e0caf6af81297897bd112eb7e9627c", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", "shasum": "" }, "require": { @@ -1284,7 +1302,7 @@ "sebastian/exporter": "^5.0" }, "require-dev": { - "phpunit/phpunit": "^10.0" + "phpunit/phpunit": "^10.3" }, "type": "library", "extra": { @@ -1328,7 +1346,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" }, "funding": [ { @@ -1336,24 +1355,24 @@ "type": "github" } ], - "time": "2023-02-03T07:07:16+00:00" + "time": "2023-08-14T13:18:12+00:00" }, { "name": "sebastian/complexity", - "version": "3.0.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/complexity.git", - "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6" + "reference": "68ff824baeae169ec9f2137158ee529584553799" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/e67d240970c9dc7ea7b2123a6d520e334dd61dc6", - "reference": "e67d240970c9dc7ea7b2123a6d520e334dd61dc6", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -1362,7 +1381,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.0-dev" + "dev-main": "3.2-dev" } }, "autoload": { @@ -1385,7 +1404,8 @@ "homepage": "https://github.com/sebastianbergmann/complexity", "support": { "issues": "https://github.com/sebastianbergmann/complexity/issues", - "source": "https://github.com/sebastianbergmann/complexity/tree/3.0.0" + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" }, "funding": [ { @@ -1393,20 +1413,20 @@ "type": "github" } ], - "time": "2023-02-03T06:59:47+00:00" + "time": "2023-12-21T08:37:17+00:00" }, { "name": "sebastian/diff", - "version": "5.0.1", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02" + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/aae9a0a43bff37bd5d8d0311426c87bf36153f02", - "reference": "aae9a0a43bff37bd5d8d0311426c87bf36153f02", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", "shasum": "" }, "require": { @@ -1414,12 +1434,12 @@ }, "require-dev": { "phpunit/phpunit": "^10.0", - "symfony/process": "^4.2 || ^5" + "symfony/process": "^6.4" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -1452,7 +1472,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/diff/issues", "security": "https://github.com/sebastianbergmann/diff/security/policy", - "source": "https://github.com/sebastianbergmann/diff/tree/5.0.1" + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" }, "funding": [ { @@ -1460,7 +1480,7 @@ "type": "github" } ], - "time": "2023-03-23T05:12:41+00:00" + "time": "2024-03-02T07:15:17+00:00" }, { "name": "sebastian/environment", @@ -1528,16 +1548,16 @@ }, { "name": "sebastian/exporter", - "version": "5.0.0", + "version": "5.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0" + "reference": "955288482d97c19a372d3f31006ab3f37da47adf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0", - "reference": "f3ec4bf931c0b31e5b413f5b4fc970a7d03338c0", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", + "reference": "955288482d97c19a372d3f31006ab3f37da47adf", "shasum": "" }, "require": { @@ -1551,7 +1571,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "5.0-dev" + "dev-main": "5.1-dev" } }, "autoload": { @@ -1593,7 +1613,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/5.0.0" + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" }, "funding": [ { @@ -1601,20 +1622,20 @@ "type": "github" } ], - "time": "2023-02-03T07:06:49+00:00" + "time": "2024-03-02T07:17:12+00:00" }, { "name": "sebastian/global-state", - "version": "6.0.0", + "version": "6.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "aab257c712de87b90194febd52e4d184551c2d44" + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/aab257c712de87b90194febd52e4d184551c2d44", - "reference": "aab257c712de87b90194febd52e4d184551c2d44", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", "shasum": "" }, "require": { @@ -1648,13 +1669,14 @@ } ], "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", + "homepage": "https://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/6.0.0" + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" }, "funding": [ { @@ -1662,24 +1684,24 @@ "type": "github" } ], - "time": "2023-02-03T07:07:38+00:00" + "time": "2024-03-02T07:19:19+00:00" }, { "name": "sebastian/lines-of-code", - "version": "2.0.0", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/lines-of-code.git", - "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130" + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/17c4d940ecafb3d15d2cf916f4108f664e28b130", - "reference": "17c4d940ecafb3d15d2cf916f4108f664e28b130", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", "shasum": "" }, "require": { - "nikic/php-parser": "^4.10", + "nikic/php-parser": "^4.18 || ^5.0", "php": ">=8.1" }, "require-dev": { @@ -1711,7 +1733,8 @@ "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/2.0.0" + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" }, "funding": [ { @@ -1719,7 +1742,7 @@ "type": "github" } ], - "time": "2023-02-03T07:08:02+00:00" + "time": "2023-12-21T08:38:20+00:00" }, { "name": "sebastian/object-enumerator", @@ -2007,16 +2030,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.9.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -2026,11 +2049,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -2045,55 +2068,76 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "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", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-02-16T15:06:51+00:00" }, { "name": "symfony/config", - "version": "v6.2.7", + "version": "v6.4.4", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "249271da6f545d6579e0663374f8249a80be2893" + "reference": "6ea4affc27f2086c9d16b92ab5429ce1e3c38047" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/249271da6f545d6579e0663374f8249a80be2893", - "reference": "249271da6f545d6579e0663374f8249a80be2893", + "url": "https://api.github.com/repos/symfony/config/zipball/6ea4affc27f2086c9d16b92ab5429ce1e3c38047", + "reference": "6ea4affc27f2086c9d16b92ab5429ce1e3c38047", "shasum": "" }, "require": { "php": ">=8.1", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/filesystem": "^5.4|^6.0", + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/filesystem": "^5.4|^6.0|^7.0", "symfony/polyfill-ctype": "~1.8" }, "conflict": { - "symfony/finder": "<5.4" + "symfony/finder": "<5.4", + "symfony/service-contracts": "<2.5" }, "require-dev": { - "symfony/event-dispatcher": "^5.4|^6.0", - "symfony/finder": "^5.4|^6.0", - "symfony/messenger": "^5.4|^6.0", - "symfony/service-contracts": "^1.1|^2|^3", - "symfony/yaml": "^5.4|^6.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" + "symfony/event-dispatcher": "^5.4|^6.0|^7.0", + "symfony/finder": "^5.4|^6.0|^7.0", + "symfony/messenger": "^5.4|^6.0|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -2121,7 +2165,7 @@ "description": "Helps you find, load, combine, autofill and validate configuration values of any kind", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/config/tree/v6.2.7" + "source": "https://github.com/symfony/config/tree/v6.4.4" }, "funding": [ { @@ -2137,34 +2181,34 @@ "type": "tidelift" } ], - "time": "2023-02-14T08:44:56+00:00" + "time": "2024-02-26T07:52:26+00:00" }, { "name": "symfony/dependency-injection", - "version": "v6.2.10", + "version": "v6.4.4", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "d732a66a2672669232c0b4536c8c96724a679780" + "reference": "6236e5e843cb763e9d0f74245678b994afea5363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/d732a66a2672669232c0b4536c8c96724a679780", - "reference": "d732a66a2672669232c0b4536c8c96724a679780", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/6236e5e843cb763e9d0f74245678b994afea5363", + "reference": "6236e5e843cb763e9d0f74245678b994afea5363", "shasum": "" }, "require": { "php": ">=8.1", "psr/container": "^1.1|^2.0", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/service-contracts": "^1.1.6|^2.0|^3.0", - "symfony/var-exporter": "^6.2.7" + "symfony/deprecation-contracts": "^2.5|^3", + "symfony/service-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.2.10|^7.0" }, "conflict": { "ext-psr": "<1.1|>=2", "symfony/config": "<6.1", "symfony/finder": "<5.4", - "symfony/proxy-manager-bridge": "<6.2", + "symfony/proxy-manager-bridge": "<6.3", "symfony/yaml": "<5.4" }, "provide": { @@ -2172,15 +2216,9 @@ "symfony/service-implementation": "1.1|2.0|3.0" }, "require-dev": { - "symfony/config": "^6.1", - "symfony/expression-language": "^5.4|^6.0", - "symfony/yaml": "^5.4|^6.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/yaml": "" + "symfony/config": "^6.1|^7.0", + "symfony/expression-language": "^5.4|^6.0|^7.0", + "symfony/yaml": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -2208,7 +2246,7 @@ "description": "Allows you to standardize and centralize the way objects are constructed in your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/dependency-injection/tree/v6.2.10" + "source": "https://github.com/symfony/dependency-injection/tree/v6.4.4" }, "funding": [ { @@ -2224,20 +2262,20 @@ "type": "tidelift" } ], - "time": "2023-04-21T15:42:15+00:00" + "time": "2024-02-22T20:27:10+00:00" }, { "name": "symfony/deprecation-contracts", - "version": "v3.2.1", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e" + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", - "reference": "e2d1534420bd723d0ef5aec58a22c5fe60ce6f5e", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", + "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", "shasum": "" }, "require": { @@ -2246,7 +2284,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -2275,7 +2313,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.2.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" }, "funding": [ { @@ -2291,20 +2329,20 @@ "type": "tidelift" } ], - "time": "2023-03-01T10:25:55+00:00" + "time": "2023-05-23T14:45:45+00:00" }, { "name": "symfony/filesystem", - "version": "v6.2.10", + "version": "v6.4.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894" + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/fd588debf7d1bc16a2c84b4b3b71145d9946b894", - "reference": "fd588debf7d1bc16a2c84b4b3b71145d9946b894", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", + "reference": "7f3b1755eb49297a0827a7575d5d2b2fd11cc9fb", "shasum": "" }, "require": { @@ -2338,7 +2376,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.2.10" + "source": "https://github.com/symfony/filesystem/tree/v6.4.3" }, "funding": [ { @@ -2354,20 +2392,20 @@ "type": "tidelift" } ], - "time": "2023-04-18T13:46:08+00:00" + "time": "2024-01-23T14:51:35+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -2381,9 +2419,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2420,7 +2455,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -2436,20 +2471,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -2463,9 +2498,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2503,7 +2535,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -2519,36 +2551,33 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/service-contracts", - "version": "v3.2.1", + "version": "v3.4.1", "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "a8c9cedf55f314f3a186041d19537303766df09a" + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/a8c9cedf55f314f3a186041d19537303766df09a", - "reference": "a8c9cedf55f314f3a186041d19537303766df09a", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/fe07cbc8d837f60caf7018068e350cc5163681a0", + "reference": "fe07cbc8d837f60caf7018068e350cc5163681a0", "shasum": "" }, "require": { "php": ">=8.1", - "psr/container": "^2.0" + "psr/container": "^1.1|^2.0" }, "conflict": { "ext-psr": "<1.1|>=2" }, - "suggest": { - "symfony/service-implementation": "" - }, "type": "library", "extra": { "branch-alias": { - "dev-main": "3.3-dev" + "dev-main": "3.4-dev" }, "thanks": { "name": "symfony/contracts", @@ -2588,7 +2617,7 @@ "standards" ], "support": { - "source": "https://github.com/symfony/service-contracts/tree/v3.2.1" + "source": "https://github.com/symfony/service-contracts/tree/v3.4.1" }, "funding": [ { @@ -2604,27 +2633,28 @@ "type": "tidelift" } ], - "time": "2023-03-01T10:32:47+00:00" + "time": "2023-12-26T14:02:43+00:00" }, { "name": "symfony/var-exporter", - "version": "v6.2.10", + "version": "v6.4.4", "source": { "type": "git", "url": "https://github.com/symfony/var-exporter.git", - "reference": "9a07920c2058bafee921ce4d90aeef2193837d63" + "reference": "0bd342e24aef49fc82a21bd4eedd3e665d177e5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-exporter/zipball/9a07920c2058bafee921ce4d90aeef2193837d63", - "reference": "9a07920c2058bafee921ce4d90aeef2193837d63", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/0bd342e24aef49fc82a21bd4eedd3e665d177e5b", + "reference": "0bd342e24aef49fc82a21bd4eedd3e665d177e5b", "shasum": "" }, "require": { - "php": ">=8.1" + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.5|^3" }, "require-dev": { - "symfony/var-dumper": "^5.4|^6.0" + "symfony/var-dumper": "^5.4|^6.0|^7.0" }, "type": "library", "autoload": { @@ -2662,7 +2692,7 @@ "serialize" ], "support": { - "source": "https://github.com/symfony/var-exporter/tree/v6.2.10" + "source": "https://github.com/symfony/var-exporter/tree/v6.4.4" }, "funding": [ { @@ -2678,20 +2708,20 @@ "type": "tidelift" } ], - "time": "2023-04-21T08:33:05+00:00" + "time": "2024-02-26T08:37:45+00:00" }, { "name": "theseer/tokenizer", - "version": "1.2.1", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", - "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", "shasum": "" }, "require": { @@ -2720,7 +2750,7 @@ "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" + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" }, "funding": [ { @@ -2728,7 +2758,7 @@ "type": "github" } ], - "time": "2021-07-28T10:34:58+00:00" + "time": "2024-03-03T12:36:25+00:00" } ], "aliases": [], diff --git a/phpcs.xml b/phpcs.xml index b771656..a80be70 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -19,7 +19,6 @@ - diff --git a/src/Chain/ChainFunctionTypeError.php b/src/Chain/ChainFunctionTypeError.php new file mode 100644 index 0000000..cae2369 --- /dev/null +++ b/src/Chain/ChainFunctionTypeError.php @@ -0,0 +1,6 @@ +onRejected, $reason); -// try { -// } -// catch(TypeError $error) { -// $reflection = new ReflectionFunction($this->onRejected); -// $param = $reflection->getParameters()[0] ?? null; -// if($param) { -// $paramType = (string)$param->getType(); -// -// if(!str_contains($error->getMessage(), "must be of type $paramType")) { -// throw $error; -// } -// } -// -// return $reason; -// } + } + + public function checkResolutionCallbackType(mixed $resolvedValue):void { + if(isset($this->onResolved)) { + $this->checkType($resolvedValue, $this->onResolved); + } + } + + public function checkRejectionCallbackType(Throwable $rejection):void { + if(isset($this->onRejected)) { + $this->checkType($rejection, $this->onRejected); + } + } + + /** + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) + */ + // phpcs:ignore + private function checkType(mixed $value, callable $callable):void { + if(!$callable instanceof Closure) { + return; + } + + $refFunction = new ReflectionFunction($callable); + $refParameterList = $refFunction->getParameters(); + if(!isset($refParameterList[0])) { + return; + } + $refParameter = $refParameterList[0]; + $nullable = $refParameter->allowsNull(); + + if(is_null($value)) { + if(!$nullable) { + throw new ChainFunctionTypeError("Then function's parameter is not nullable"); + } + } + + $allowedTypes = []; + $refType = $refParameter->getType(); + + if($refType instanceof ReflectionUnionType || $refType instanceof ReflectionIntersectionType) { + /** @var ReflectionNamedType $refSubType */ + foreach($refType->getTypes() as $refSubType) { + array_push($allowedTypes, $refSubType->getName()); + } + } + else { + /** @var ?ReflectionNamedType $refType */ + array_push($allowedTypes, $refType?->getName()); + } + + $valueType = is_object($value) + ? get_class($value) + : gettype($value); + foreach($allowedTypes as $allowedType) { + $allowedType = match($allowedType) { + "int" => "integer", + "float" => "double", + default => $allowedType, + }; + if(is_null($allowedType) || $allowedType === "mixed") { +// A typeless property is defined - allow anything! + return; + } + if($allowedType === $valueType) { + return; + } + + if(is_a($valueType, $allowedType, true)) { + return; + } + + if($allowedType === "string") { + if($valueType === "double" || $valueType === "integer") { + return; + } + } + if($allowedType === "double") { + if(is_numeric($value)) { + return; + } + } + } + + throw new ChainFunctionTypeError("Value $value is not compatible with chainable parameter"); } } diff --git a/src/Chain/ThenChain.php b/src/Chain/ThenChain.php index 6953868..7ea761a 100644 --- a/src/Chain/ThenChain.php +++ b/src/Chain/ThenChain.php @@ -1,4 +1,5 @@ rejectedReason)) { return PromiseState::REJECTED; } - elseif(isset($this->resolvedValue)) { + elseif($this->resolvedValueSet) { return PromiseState::RESOLVED; } @@ -87,7 +94,12 @@ private function callExecutor():void { call_user_func( $this->executor, function(mixed $value = null) { - $this->resolve($value); + try { + $this->resolve($value); + } + catch(PromiseException $exception) { + $this->reject($exception); + } }, function(Throwable $reason) { $this->reject($reason); @@ -107,6 +119,7 @@ private function resolve(mixed $value):void { } $this->resolvedValue = $value; + $this->resolvedValueSet = true; } private function reject(Throwable $reason):void { @@ -133,6 +146,7 @@ private function tryComplete():void { } } + // phpcs:ignore private function complete():void { usort( $this->chain, @@ -155,11 +169,28 @@ function(Chainable $a, Chainable $b) { } if($chainItem instanceof ThenChain) { + try { + if($this->resolvedValueSet && isset($this->resolvedValue)) { + $chainItem->checkResolutionCallbackType($this->resolvedValue); + } + } + catch(ChainFunctionTypeError) { + continue; + } + $this->handleThen($chainItem); } elseif($chainItem instanceof CatchChain) { - if($handled = $this->handleCatch($chainItem)) { - array_push($this->handledRejections, $handled); + try { + if(isset($this->rejectedReason)) { + $chainItem->checkRejectionCallbackType($this->rejectedReason); + } + if($handled = $this->handleCatch($chainItem)) { + array_push($this->handledRejections, $handled); + } + } + catch(ChainFunctionTypeError) { + continue; } } elseif($chainItem instanceof FinallyChain) { @@ -180,8 +211,10 @@ private function handleThen(ThenChain $then):void { } try { - $result = $then->callOnResolved($this->resolvedValue) - ?? $this->resolvedValue ?? null; + $result = null; + if(isset($this->resolvedValue)) { + $result = $then->callOnResolved($this->resolvedValue); + } if($result instanceof PromiseInterface) { $this->chainPromise($result); @@ -197,8 +230,6 @@ private function handleThen(ThenChain $then):void { private function handleCatch(CatchChain $catch):?Throwable { if($this->getState() !== PromiseState::REJECTED) { -// TODO: This is where #52 can be implemented -// see: (https://github.com/PhpGt/Promise/issues/52) array_push($this->uncalledCatchChain, $catch); return null; } diff --git a/test/phpunit/PromiseTest.php b/test/phpunit/PromiseTest.php index eea2a81..9ca003c 100644 --- a/test/phpunit/PromiseTest.php +++ b/test/phpunit/PromiseTest.php @@ -1,6 +1,7 @@ getTestPromiseContainer(); $sut = $promiseContainer->getPromise(); - $sut->then(function() {})->then( + $sut->then(function(string $message) { + return $message; + })->then( self::mockCallable(1, $value) ); @@ -48,12 +52,12 @@ public function testPromiseRejectsIfResolvedWithItself() { $promiseContainer = $this->getTestPromiseContainer(); $sut = $promiseContainer->getPromise(); $onResolvedCallCount = 0; - $sut->then(function($value) use(&$onResolvedCallCount) { + $sut->then(function($value) use (&$onResolvedCallCount) { $onResolvedCallCount++; }) - ->catch(function(PromiseException $reason) use(&$actualMessage) { - $actualMessage = $reason->getMessage(); - }); + ->catch(function(PromiseException $reason) use (&$actualMessage) { + $actualMessage = $reason->getMessage(); + }); $promiseContainer->resolve($sut); self::assertEquals(0, $onResolvedCallCount); @@ -67,9 +71,9 @@ public function testRejectWithException() { $fulfilledCallCount = 0; - $sut->then(function() use(&$fulfilledCallCount) { - $fulfilledCallCount++; - }) + $sut->then(function() use (&$fulfilledCallCount) { + $fulfilledCallCount++; + }) ->catch(self::mockCallable(1, $exception)); $promiseContainer->reject($exception); @@ -92,7 +96,7 @@ public function testRejectIfFulfillerThrowsException() { $sut = $promiseContainer->getPromise(); $sut->then( - function() use($exception) { + function() use ($exception) { throw $exception; }, self::mockCallable(0), @@ -111,11 +115,11 @@ public function testRejectIfRejecterThrowsException() { $sut = $promiseContainer->getPromise(); $sut->then(self::mockCallable(0)) - ->catch(function(Throwable $reason) use($exception) { + ->catch(function(Throwable $reason) use ($exception) { throw $exception; }) ->then(self::mockCallable(0)) - ->catch(function(Throwable $reason) use(&$caughtExceptions) { + ->catch(function(Throwable $reason) use (&$caughtExceptions) { array_push($caughtExceptions, $reason); }); @@ -156,14 +160,25 @@ public function testThenResultForwardedWhenOnFulfilledIsNull() { $promiseContainer = $this->getTestPromiseContainer(); - $onFulfilled = self::mockCallable(2, $message); - $onRejected = self::mockCallable(0); + $caughtResolutions = []; + $caughtReasons = []; $sut = $promiseContainer->getPromise(); - $sut->then($onFulfilled)->catch($onRejected) - ->then($onFulfilled)->catch($onRejected); + $sut->then(function(string $resolved) use (&$caughtResolutions) { + array_push($caughtResolutions, $resolved); + return $resolved; + })->catch(function(Throwable $reason) use (&$caughtReasons) { + array_push($caughtReasons, $reason); + })->then(function(string $resolved) use (&$caughtResolutions) { + array_push($caughtResolutions, $resolved); + return $resolved; + })->catch(function(Throwable $reason) use (&$caughtReasons) { + array_push($caughtReasons, $reason); + }); $promiseContainer->resolve($message); + self::assertCount(2, $caughtResolutions); + self::assertEmpty($caughtReasons); } public function testThenCallbackResultForwarded() { @@ -180,18 +195,56 @@ public function testThenCallbackResultForwarded() { ); $onRejected = self::mockCallable(0); - $sut->then(function(string $message) use($messageConcat) { + $sut->then(function(string $message) use ($messageConcat) { return "$message, $messageConcat"; }) ->then(function(string $message) { - return "$message!!!"; - }) + return "$message!!!"; + }) ->then($onFulfilled) ->catch($onRejected); $promiseContainer->resolve($message); } + public function testThenCallbackResultStoppedWhenNullReturn() { + $concatMessages1 = ""; + $promiseContainer = $this->getTestPromiseContainer(); + $sut = $promiseContainer->getPromise(); + $sut->then(function(string $message) use (&$concatMessages1) { + $concatMessages1 .= $message; + + if($message === "STOP") { + return null; + } + + return "MORE"; + })->then(function(string $message) use (&$concatMessages1) { + $concatMessages1 .= $message; + }); + + $promiseContainer->resolve("HELLO"); + self::assertEquals("HELLOMORE", $concatMessages1); + + $concatMessages2 = ""; + $promiseContainer = $this->getTestPromiseContainer(); + $sut = $promiseContainer->getPromise(); + $sut->then(function(string $message) use (&$concatMessages2) { + $concatMessages2 .= $message; + + if($message === "STOP") { + return null; + } + + return "MORE"; + })->then(function(string $message) use (&$concatMessages2) { + $concatMessages2 .= $message; + }); + + $promiseContainer->resolve("STOP"); + self::assertEquals("STOP", $concatMessages2); + } + /** * A rejected promise should forward its rejection to the end of the * promise chain. @@ -204,16 +257,16 @@ public function testThenRejectionCallbackResultForwarded() { $fulfilledCallCount = 0; $sut = $promiseContainer->getPromise(); - $sut->then(function($value) use(&$fulfilledCallCount) { - $fulfilledCallCount++; - }) - ->then(function($value) use(&$fulfilledCallCount) { + $sut->then(function($value) use (&$fulfilledCallCount) { $fulfilledCallCount++; }) - ->then(function($value) use(&$fulfilledCallCount) { + ->then(function($value) use (&$fulfilledCallCount) { + $fulfilledCallCount++; + }) + ->then(function($value) use (&$fulfilledCallCount) { $fulfilledCallCount++; }) - ->catch(self::mockCallable(1, $expectedException)); + ->catch(self::mockCallable(1, $expectedException)); $promiseContainer->reject($expectedException); self::assertEquals(0, $fulfilledCallCount); @@ -259,7 +312,7 @@ public function testCatchRejectionReasonIdenticalToRejectionException() { $onRejected = self::mockCallable(1, $exception); $sut = $promiseContainer->getPromise(); - $sut->catch(function($reason) use($onRejected) { + $sut->catch(function($reason) use ($onRejected) { call_user_func($onRejected, $reason); }); $promiseContainer->reject($exception); @@ -272,7 +325,7 @@ public function testCatchRejectionHandlerIsCalledByTypeHintedOnRejectedCallback( $onRejected = self::mockCallable(1, $exception); - $sut->catch(function(PromiseException $reason) use($onRejected) { + $sut->catch(function(PromiseException $reason) use ($onRejected) { call_user_func($onRejected, $reason); }); @@ -288,10 +341,10 @@ public function testCatchRejectionWhenExceptionIsThrownInResolutionFunction() { $expectedReason = new RuntimeException("This is expected"); $caughtReasons = []; - $sut->then(function($value)use ($expectedReason, &$caughtResolutions) { + $sut->then(function($value) use ($expectedReason, &$caughtResolutions) { array_push($caughtResolutions, $value); throw $expectedReason; - })->catch(function(Throwable $reason)use(&$caughtReasons) { + })->catch(function(Throwable $reason) use (&$caughtReasons) { array_push($caughtReasons, $reason); }); @@ -315,15 +368,15 @@ public function testCatchRejectionWhenExceptionIsThrownInResolutionFunctionUsing $expectedReason = new RuntimeException("This is expected"); $caughtReasons = []; - $sut->then(function($value)use ($expectedReason) { + $sut->then(function($value) use ($expectedReason) { throw $expectedReason; - })->catch(function(Throwable $reason)use($newDeferred) { + })->catch(function(Throwable $reason) use ($newDeferred) { $newDeferred->reject($reason); }); - $newPromise->then(function($value)use ($expectedReason, &$caughtResolutions) { + $newPromise->then(function($value) use ($expectedReason, &$caughtResolutions) { array_push($caughtResolutions, $value); - })->catch(function(Throwable $reason)use (&$caughtReasons) { + })->catch(function(Throwable $reason) use (&$caughtReasons) { array_push($caughtReasons, $reason); }); @@ -347,7 +400,7 @@ public function testFinallyDoesNotBlockOnFulfilled() { $sut = $promiseContainer->getPromise(); $sut->finally(fn() => "example123") - ->then(self::mockCallable(1, $expectedValue)); + ->then(self::mockCallable(1, $expectedValue)); $promiseContainer->resolve($expectedValue); } @@ -357,7 +410,7 @@ public function testFinallyDoesNotBlockOnRejected() { $promiseContainer = $this->getTestPromiseContainer(); $sut = $promiseContainer->getPromise(); $sut->finally(function() {}) - ->catch(self::mockCallable(1, $exception)); + ->catch(self::mockCallable(1, $exception)); $promiseContainer->reject($exception); } @@ -380,15 +433,35 @@ public function testFinallyPassesThrownException() { self::expectException(Exception::class); self::expectExceptionMessage("Second"); $sut = $promiseContainer->getPromise(); - $sut->finally(function(mixed $resolvedValueOrRejectedReason) use($exception1) { + $sut->finally(function(mixed $resolvedValueOrRejectedReason) use ($exception1) { self::assertSame($resolvedValueOrRejectedReason, $exception1); throw new Exception("Second"); }) - ->then(self::mockCallable(0)) - ->catch(self::mockCallable(1, $exception1)); + ->then(self::mockCallable(0)) + ->catch(self::mockCallable(1, $exception1)); $promiseContainer->reject($exception1); } + public function testFinallyCanReturnPromise() { + $finallyLog = []; + + $otherPromiseContainer = $this->getTestPromiseContainer(); + $otherPromise = $otherPromiseContainer->getPromise(); + + $promiseContainer = $this->getTestPromiseContainer(); + $sut = $promiseContainer->getPromise(); + $sut->finally(function(mixed $resolvedValueOrRejectedReason) use($otherPromise, &$finallyLog) { + array_push($finallyLog, $resolvedValueOrRejectedReason); + return $otherPromise; + })->finally(function(mixed $resolvedValueOrRejectedReason) use($otherPromise, &$finallyLog) { + array_push($finallyLog, $resolvedValueOrRejectedReason); + }); + $promiseContainer->resolve("test"); + self::assertCount(2, $finallyLog); + self::assertSame("test", $finallyLog[0]); + self::assertNull($finallyLog[1]); + } + public function testOnRejectedCalledWhenFinallyThrows() { $exception = new PromiseException("Oh dear, oh dear"); $promiseContainer = $this->getTestPromiseContainer(); @@ -396,7 +469,7 @@ public function testOnRejectedCalledWhenFinallyThrows() { self::expectException(PromiseException::class); self::expectExceptionMessage("Oh dear, oh dear"); $sut = $promiseContainer->getPromise(); - $sut->finally(function() use($exception) { + $sut->finally(function() use ($exception) { throw $exception; })->then( self::mockCallable(1, "Example resolution"), @@ -428,7 +501,7 @@ public function testGetStateFulfilled() { public function testGetStateRejected() { $promiseContainer = $this->getTestPromiseContainer(); $sut = $promiseContainer->getPromise(); - $sut->catch(function(Throwable $throwable){}); + $sut->catch(function(Throwable $throwable) {}); $promiseContainer->reject(new Exception("Example rejection")); @@ -452,12 +525,12 @@ public function testCatchMethodNotBubblesThrowables() { $exception = null; try { - $sut->then(function() use($expectedException) { + $sut->then(function() use ($expectedException) { throw $expectedException; }) - ->catch($onRejected); + ->catch($onRejected); + } catch(Throwable $exception) { } - catch(Throwable $exception) {} $promiseContainer->resolve("test"); self::assertNull($exception); @@ -472,15 +545,15 @@ public function testNoCatchMethodBubblesThrowables() { $expectedException = new Exception("Test exception"); $promiseContainer = $this->getTestPromiseContainer(); $sut = $promiseContainer->getPromise(); - $sut->then(function() use($expectedException) { + $sut->then(function() use ($expectedException) { throw $expectedException; }); $exception = null; try { $promiseContainer->resolve("test"); + } catch(Throwable $exception) { } - catch(Throwable $exception) {} self::assertSame($expectedException, $exception); } @@ -492,20 +565,43 @@ public function testNoCatchMethodBubblesThrowables_internalRejection() { $exception = null; try { - $sut->then(function(string $message) use($sut, $promiseContainer, $expectedException) { - $sut->then(function($resolvedValue) use($promiseContainer, $expectedException) { + $sut->then(function(string $message) use ($sut, $promiseContainer, $expectedException) { + $sut->then(function($resolvedValue) use ($promiseContainer, $expectedException) { $promiseContainer->reject($expectedException); }); return $sut; }); $promiseContainer->resolve("test"); + } catch(Throwable $exception) { } - catch(Throwable $exception) {} self::assertSame($expectedException, $exception); } + public function testCatchCanReturnPromise() { + $catchLog = []; + $finallyLog = []; + + $otherPromiseContainer = $this->getTestPromiseContainer(); + $otherPromise = $otherPromiseContainer->getPromise(); + $otherPromiseContainer->resolve("test"); + + $promiseContainer = $this->getTestPromiseContainer(); + $sut = $promiseContainer->getPromise(); + $sut->catch(function(Throwable $rejectedReason) use($otherPromise, &$catchLog) { + array_push($catchLog, $rejectedReason); + return $otherPromise; + })->finally(function(mixed $received) use(&$finallyLog) { + array_push($finallyLog, $received); + }); + $promiseContainer->resolve($sut); + self::assertCount(1, $catchLog); + self::assertCount(1, $finallyLog); + self::assertInstanceOf(PromiseResolvedWithAnotherPromiseException::class, $catchLog[0]); + self::assertSame("test", $finallyLog[0]); + } + public function testFulfilledReturnsNewPromiseThatIsResolved() { $numberPromiseContainer = $this->getTestPromiseContainer(); $numberPromise = $numberPromiseContainer->getPromise(); @@ -514,18 +610,24 @@ public function testFulfilledReturnsNewPromiseThatIsResolved() { $messagePromise = $messagePromiseContainer->getPromise(); $numberToResolveWith = null; + $actualMessageReceived = null; // The first onFulfilled takes the number to process, and returns a new promise // which should resolve to a message containing the number. $numberPromise - ->then(function(int $number) use($messagePromiseContainer, $messagePromise, &$numberToResolveWith) { - $numberToResolveWith = $number; - return $messagePromise; - }) - ->then(self::mockCallable(1, "Your number is 105")); + ->then(function(int $number) use ($messagePromiseContainer, $messagePromise, &$numberToResolveWith) { + $numberToResolveWith = $number; + return $messagePromise; + }) + ->then( + function(string $message) use(&$actualMessageReceived) { + $actualMessageReceived = $message; + } + ); $numberPromiseContainer->resolve(105); $messagePromiseContainer->resolve("Your number is $numberToResolveWith"); + self::assertEquals("Your number is 105", $actualMessageReceived); } /** @@ -558,24 +660,24 @@ public function testFulfilledReturnsNewPromiseThatIsResolved2() { $innerComplete = null; $innerPromise = null; - $sut = new Promise(function($f, $r, $c) use(&$fulfill, &$reject, &$complete) { + $sut = new Promise(function($f, $r, $c) use (&$fulfill, &$reject, &$complete) { $fulfill = $f; $reject = $r; $complete = $c; }); // Define asynchronous behaviour: - $sut->then(function(string $name) use(&$innerFulfil, &$innerReject, &$innerComplete, &$innerPromise, &$searchTerm, &$receivedNames) { + $sut->then(function(string $name) use (&$innerFulfil, &$innerReject, &$innerComplete, &$innerPromise, &$searchTerm, &$receivedNames) { array_push($receivedNames, $name); $searchTerm = $name; - $innerPromise = new Promise(function($f, $r, $c) use(&$innerFulfil, &$innerReject, &$innerComplete) { + $innerPromise = new Promise(function($f, $r, $c) use (&$innerFulfil, &$innerReject, &$innerComplete) { $innerFulfil = $f; $innerReject = $r; $innerComplete = $c; }); return $innerPromise; - })->then(function(string $address) use(&$receivedAddresses) { + })->then(function(string $address) use (&$receivedAddresses) { array_push($receivedAddresses, $address); }); @@ -607,18 +709,18 @@ public function testCustomPromise_resolve() { $newPromise = new CustomPromise(); $deferred = new Deferred(); $deferredPromise = $deferred->getPromise(); - $deferredPromise->then(function($resolvedValue)use($newPromise) { + $deferredPromise->then(function($resolvedValue) use ($newPromise) { $newPromise->resolve($resolvedValue); - }, function($rejectedValue)use($newPromise) { + }, function($rejectedValue) use ($newPromise) { $newPromise->reject($rejectedValue); }); $resolution = null; $rejection = null; - $newPromise->then(function($resolvedValue)use(&$resolution) { + $newPromise->then(function($resolvedValue) use (&$resolution) { $resolution = $resolvedValue; - }, function($rejectedValue)use(&$rejection) { + }, function($rejectedValue) use (&$rejection) { $rejection = $rejectedValue; }); @@ -635,18 +737,18 @@ public function testCustomPromise_reject() { $deferred = new Deferred(); $deferredPromise = $deferred->getPromise(); - $deferredPromise->then(function($resolvedValue)use($customPromise) { + $deferredPromise->then(function($resolvedValue) use ($customPromise) { $customPromise->resolve($resolvedValue); - })->catch(function($rejectedValue)use($customPromise) { + })->catch(function($rejectedValue) use ($customPromise) { $customPromise->reject($rejectedValue); }); $resolution = null; $rejection = null; - $customPromise->then(function($resolvedValue)use(&$resolution) { + $customPromise->then(function($resolvedValue) use (&$resolution) { $resolution = $resolvedValue; - })->catch(function($rejectedValue)use(&$rejection) { + })->catch(function($rejectedValue) use (&$rejection) { $rejection = $rejectedValue; }); @@ -665,9 +767,9 @@ public function testPromise_rejectChain() { $deferred = new Deferred(); $deferredPromise = $deferred->getPromise(); - $deferredPromise->then(function($resolvedValue)use(&$thenCalls) { + $deferredPromise->then(function($resolvedValue) use (&$thenCalls) { array_push($thenCalls, $resolvedValue); - })->catch(function(Throwable $reason)use(&$catchCalls) { + })->catch(function(Throwable $reason) use (&$catchCalls) { array_push($catchCalls, $reason); }); @@ -675,11 +777,11 @@ public function testPromise_rejectChain() { $innerPromise = $innerDeferred->getPromise(); $rejection = new Exception("test rejection"); - $innerPromise->then(function(string $message)use($rejection) { + $innerPromise->then(function(string $message) use ($rejection) { if(!$message) { throw $rejection; } - })->catch(function(Throwable $reason)use($deferred) { + })->catch(function(Throwable $reason) use ($deferred) { $deferred->reject($reason); }); @@ -699,7 +801,7 @@ public function testPromise_notThrowWhenNoCatch():void { if($message === "error") { throw $expectedException; } - })->catch(function(Throwable $reason) use(&$caughtReasons) { + })->catch(function(Throwable $reason) use (&$caughtReasons) { array_push($caughtReasons, $reason); }); @@ -713,7 +815,7 @@ public function testPromise_throwWhenNoCatch():void { $deferred = new Deferred(); $deferredPromise = $deferred->getPromise(); - $deferredPromise->then(function(string $message) use($expectedException) { + $deferredPromise->then(function(string $message) use ($expectedException) { if($message === "error") { throw $expectedException; } @@ -724,13 +826,33 @@ public function testPromise_throwWhenNoCatch():void { $deferred->resolve("error"); } + public function testPromise_catchMethodCorrectType():void { + $deferred = new Deferred(); + $promise = $deferred->getPromise(); + $resolvedValue = null; + $rejectedReason = null; + + $promise->then(function(string $value) use(&$resolvedValue) { + $resolvedValue = $value; + })->catch(function(ValueError $valueError) use(&$rejectedReason) { + $rejectedReason = $valueError; + })->catch(function(ArithmeticError $arithmeticError) use(&$rejectedReason) { + $rejectedReason = $arithmeticError; + }); + + $triggeredError = new ArithmeticError("something bad happened"); + $deferred->reject($triggeredError); + self::assertNull($resolvedValue); + self::assertSame($triggeredError, $rejectedReason); + } + protected function getTestPromiseContainer():TestPromiseContainer { $resolveCallback = null; $rejectCallback = null; $completeCallback = null; $promise = new Promise(function($resolve, $reject, $complete) - use(&$resolveCallback, &$rejectCallback, &$completeCallback) { + use (&$resolveCallback, &$rejectCallback, &$completeCallback) { $resolveCallback = $resolve; $rejectCallback = $reject; $completeCallback = $complete; diff --git a/test/phpunit/TestPromiseContainer.php b/test/phpunit/TestPromiseContainer.php index 6d31d23..13b00a7 100644 --- a/test/phpunit/TestPromiseContainer.php +++ b/test/phpunit/TestPromiseContainer.php @@ -3,7 +3,6 @@ use Gt\Promise\PromiseInterface; use Gt\Promise\PromiseState; -use Http\Promise\Promise as HttpPromiseInterface; class TestPromiseContainer { private PromiseInterface $promise;