diff --git a/.gitignore b/.gitignore index 5d38ddb..d6ad1f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ composer.lock vendor/ .idea -.DS_STORE \ No newline at end of file +.phpunit.result.cache +.DS_STORE diff --git a/composer.json b/composer.json index 881ddeb..d247dfc 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,11 @@ "files": ["src/functions.php"] }, "require": { - "react/promise": "^2.0", - "guzzlehttp/promises": "^1.0" + "react/promise": "^3.0", + "guzzlehttp/promises": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.6" + "phpunit/phpunit": "^10.0" }, "license": "MIT", "authors": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index cab45eb..ca4f242 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,14 @@ - - - - tests - - - - - src - - src/ - - - - \ No newline at end of file + + + + tests + + + + + + src + + + diff --git a/src/functions.php b/src/functions.php index 4d09714..b3d4284 100644 --- a/src/functions.php +++ b/src/functions.php @@ -2,17 +2,17 @@ namespace Tickner\GuzzleToReactPromise; -use GuzzleHttp\Promise\Promise as GuzzlePromise; +use GuzzleHttp\Promise\PromiseInterface as GuzzlePromiseInterface; use React\Promise\Deferred as ReactDeferred; -use React\Promise\Promise as ReactPromise; +use React\Promise\PromiseInterface as ReactPromiseInterface; /** - * Transforms a GuzzleHttp\Promise\Promise to a React\Promise\Promise. + * Transforms a GuzzleHttp\Promise\PromiseInterface to a React\Promise\PromiseInterface. * * @param GuzzlePromise $guzzlePromise * @return ReactPromise */ -function guzzleToReactPromise(GuzzlePromise $guzzlePromise) { +function guzzleToReactPromise(GuzzlePromiseInterface $guzzlePromise): ReactPromiseInterface { $deferred = new ReactDeferred(); $guzzlePromise->then( @@ -30,9 +30,9 @@ function($error) use ($deferred) { /** * An alias for the "guzzleToReactPromise" function. * - * @param GuzzlePromise $promise - * @return ReactPromise + * @param GuzzlePromiseInterface $promise + * @return ReactPromiseInterface */ -function g2rp(GuzzlePromise $promise) { +function g2rp(GuzzlePromiseInterface $promise): ReactPromiseInterface { return guzzleToReactPromise($promise); } diff --git a/tests/FunctionG2rpTest.php b/tests/FunctionG2rpTest.php index b303ac1..d08eb63 100644 --- a/tests/FunctionG2rpTest.php +++ b/tests/FunctionG2rpTest.php @@ -11,7 +11,7 @@ final class FunctionG2rpTest extends TestCase /** * @test */ - public function g2rp_is_an_alias_for_guzzle_to_react_promise_function() + public function g2rp_is_an_alias_for_guzzle_to_react_promise_function(): void { $guzzlePromise = new GuzzlePromise(); $reactPromise = \Tickner\GuzzleToReactPromise\g2rp($guzzlePromise); diff --git a/tests/FunctionGuzzleToReactPromiseTest.php b/tests/FunctionGuzzleToReactPromiseTest.php index cc13a3d..6c6822c 100644 --- a/tests/FunctionGuzzleToReactPromiseTest.php +++ b/tests/FunctionGuzzleToReactPromiseTest.php @@ -11,7 +11,7 @@ final class FunctionGuzzleToReactPromiseTest extends TestCase /** * @test */ - public function it_converts_a_guzzle_promise_to_a_react_promise() + public function it_converts_a_guzzle_promise_to_a_react_promise(): void { $guzzlePromise = new GuzzlePromise(); $reactPromise = \Tickner\GuzzleToReactPromise\guzzleToReactPromise($guzzlePromise); @@ -21,7 +21,7 @@ public function it_converts_a_guzzle_promise_to_a_react_promise() /** * @test */ - public function the_converted_react_promise_gets_fulfilled_when_the_guzzle_promise_resolves() + public function the_converted_react_promise_gets_fulfilled_when_the_guzzle_promise_resolves(): void { $guzzlePromise = new GuzzlePromise(); $promisedVal = null; @@ -77,6 +77,6 @@ function() { private function runGuzzlePromisesTaskQueue() { // Guzzle Promises require the use of a singleton \GuzzleHttp\Promise\TaskQueue - \GuzzleHttp\Promise\queue()->run(); + \GuzzleHttp\Promise\Utils::queue()->run(); } }