From ed5f472747b0d6754b659728efba77f155ca48b1 Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Thu, 27 Mar 2025 20:59:08 +0100 Subject: [PATCH 1/2] Update dependencies --- composer.json | 8 ++++---- tests/FunctionalTest.php | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index d5b7a47..38a8472 100644 --- a/composer.json +++ b/composer.json @@ -18,12 +18,12 @@ }, "require": { "php": ">=7.1", - "react/http": "^1.5", - "react/promise": "^2.1 || ^1.2", + "react/http": "^1.11", + "react/promise": "^3.2 || ^2.1 || ^1.2", "ext-soap": "*" }, "require-dev": { - "clue/block-react": "^1.0", - "phpunit/phpunit": "^9.3 || ^7.5" + "react/async": "^4.3 || ^3.2", + "phpunit/phpunit": "^9.6 || ^7.5" } } diff --git a/tests/FunctionalTest.php b/tests/FunctionalTest.php index f18af1d..b6ea770 100644 --- a/tests/FunctionalTest.php +++ b/tests/FunctionalTest.php @@ -2,12 +2,12 @@ namespace Clue\Tests\React\Soap; -use Clue\React\Block; +use React\Async; +use React\Http\Browser; use Clue\React\Soap\Client; use Clue\React\Soap\Proxy; use PHPUnit\Framework\TestCase; -use React\EventLoop\Loop; -use React\Http\Browser; + class BankResponse { @@ -55,7 +55,7 @@ public function testBlzService() $promise = $api->getBank(array('blz' => '12070000')); - $result = Block\await($promise, Loop::get()); + $result = Async\await($promise); $this->assertIsObject($result); $this->assertTrue(isset($result->details)); @@ -77,7 +77,7 @@ public function testBlzServiceWithClassmapReturnsExpectedType() $promise = $api->getBank(array('blz' => '12070000')); - $result = Block\await($promise, Loop::get()); + $result = Async\await($promise); $this->assertInstanceOf('Clue\Tests\React\Soap\BankResponse', $result); $this->assertTrue(isset($result->details)); @@ -97,7 +97,7 @@ public function testBlzServiceWithSoapV12() $promise = $api->getBank(array('blz' => '12070000')); - $result = Block\await($promise, Loop::get()); + $result = Async\await($promise); $this->assertIsObject($result); $this->assertTrue(isset($result->details)); @@ -117,7 +117,7 @@ public function testBlzServiceNonWsdlModeReturnedWithoutOuterResultStructure() // $promise = $api->getBank(new SoapParam('12070000', 'ns1:blz')); $promise = $api->getBank(new \SoapVar('12070000', XSD_STRING, null, null, 'blz', 'http://thomas-bayer.com/blz/')); - $result = Block\await($promise, Loop::get()); + $result = Async\await($promise); $this->assertIsObject($result); $this->assertFalse(isset($result->details)); @@ -158,7 +158,7 @@ public function testBlzServiceWithInvalidMethodRejectsWithSoapFault() $this->expectException(\SoapFault::class); $this->expectExceptionMessage('Function ("doesNotExist") is not a valid method for this service'); - Block\await($promise, Loop::get()); + Async\await($promise); } public function testCancelMethodRejectsWithRuntimeException() @@ -170,7 +170,7 @@ public function testCancelMethodRejectsWithRuntimeException() $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('cancelled'); - Block\await($promise, Loop::get()); + Async\await($promise); } public function testTimeoutRejectsWithRuntimeException() @@ -185,7 +185,7 @@ public function testTimeoutRejectsWithRuntimeException() $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('timed out'); - Block\await($promise, Loop::get()); + Async\await($promise); } public function testGetLocationForFunctionName() @@ -236,7 +236,7 @@ public function testWithLocationInvalidRejectsWithRuntimeException() $promise = $api->getBank(array('blz' => '12070000')); $this->expectException(\RuntimeException::class); - Block\await($promise, Loop::get()); + Async\await($promise); } public function testWithLocationRestoredToOriginalResolves() @@ -248,7 +248,7 @@ public function testWithLocationRestoredToOriginalResolves() $promise = $api->getBank(array('blz' => '12070000')); - $result = Block\await($promise, Loop::get()); + $result = Async\await($promise); $this->assertIsObject($result); } } From e1c778d1a000d27ef184f9a8850e3fec411d964b Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Thu, 27 Mar 2025 21:00:19 +0100 Subject: [PATCH 2/2] Use Laminas Diactoros for PSR-7 and PSR-17 --- composer.json | 1 + src/Protocol/ClientEncoder.php | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 38a8472..5be48c5 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ "php": ">=7.1", "react/http": "^1.11", "react/promise": "^3.2 || ^2.1 || ^1.2", + "laminas/laminas-diactoros": "^3.5 || ^2.4", "ext-soap": "*" }, "require-dev": { diff --git a/src/Protocol/ClientEncoder.php b/src/Protocol/ClientEncoder.php index 8b065b9..ab63e8f 100644 --- a/src/Protocol/ClientEncoder.php +++ b/src/Protocol/ClientEncoder.php @@ -3,7 +3,8 @@ namespace Clue\React\Soap\Protocol; use Psr\Http\Message\RequestInterface; -use RingCentral\Psr7\Request; +use Laminas\Diactoros\Request; +use Laminas\Diactoros\StreamFactory; /** * @internal @@ -56,11 +57,13 @@ public function __doRequest($request, $location, $action, $version, $one_way = 0 ); } + $body = (new StreamFactory())->createStream((string)$request); + $this->request = new Request( - 'POST', (string)$location, - $headers, - (string)$request + 'POST', + $body, + $headers ); // do not actually block here, just pretend we're done...