Skip to content

PHP 8 support #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
composer.lock
vendor/
.idea
.DS_STORE
.phpunit.result.cache
.DS_STORE
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
29 changes: 13 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./tests/bootstrap.php"
colors="true">
<testsuites>
<testsuite>
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix="Interface.php">src/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<testsuites>
<testsuite name="tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
14 changes: 7 additions & 7 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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);
}
2 changes: 1 addition & 1 deletion tests/FunctionG2rpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions tests/FunctionGuzzleToReactPromiseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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();
}
}