diff --git a/.phive/phars.xml b/.phive/phars.xml index 980defa..c27a737 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - + diff --git a/psalm.xml b/psalm.xml index 613611b..218e0ad 100644 --- a/psalm.xml +++ b/psalm.xml @@ -2,7 +2,6 @@ - - - diff --git a/src/AbusedClient.php b/src/AbusedClient.php index 94fdaaf..e2dca2a 100644 --- a/src/AbusedClient.php +++ b/src/AbusedClient.php @@ -6,6 +6,7 @@ use Soap\Engine\HttpBinding\SoapRequest; use Soap\Engine\HttpBinding\SoapResponse; +use Soap\ExtSoapEngine\ErrorHandling\ExtSoapErrorHandler; use Soap\ExtSoapEngine\Exception\RequestException; use SoapClient; @@ -63,7 +64,11 @@ public function doActualRequest( bool $oneWay = false ): string { $this->__last_request = $request; - $this->__last_response = (string) parent::__doRequest($request, $location, $action, $version, $oneWay); + $this->__last_response = (string) ExtSoapErrorHandler::handleNullResponse( + ExtSoapErrorHandler::handleInternalErrors( + fn (): ?string => parent::__doRequest($request, $location, $action, $version, $oneWay) + ) + ); return $this->__last_response; } diff --git a/src/ErrorHandling/ExtSoapErrorHandler.php b/src/ErrorHandling/ExtSoapErrorHandler.php new file mode 100644 index 0000000..3e860d6 --- /dev/null +++ b/src/ErrorHandling/ExtSoapErrorHandler.php @@ -0,0 +1,82 @@ +expectException(RequestException::class); + + ExtSoapErrorHandler::handleNullResponse(null); + } + + public function test_it_can_deal_with_non_null_responses(): void + { + $res = ExtSoapErrorHandler::handleNullResponse('hello'); + + static::assertSame('hello', $res); + } + + public function test_it_can_detect_no_internal_errors_during_callback(): void + { + $res = ExtSoapErrorHandler::handleInternalErrors( + static fn () => 'hello' + ); + + static::assertSame($res, 'hello'); + } + + public function test_it_can_detect_internal_errors_during_callback(): void + { + $this->expectException(RequestException::class); + $this->expectExceptionMessage('hello'); + + ExtSoapErrorHandler::handleInternalErrors( + static function () { + trigger_error('hello'); + return 'x'; + } + ); + } +} diff --git a/tools/psalm.phar b/tools/psalm.phar index 0452e69..945fcd4 100755 Binary files a/tools/psalm.phar and b/tools/psalm.phar differ