From f9d656722c96d30985a27bd514697f53368ff40e Mon Sep 17 00:00:00 2001 From: Atul-glo35265 Date: Wed, 16 Oct 2024 11:44:04 +0530 Subject: [PATCH] Fixing Psalm, Codesniffer and Phpunit issues Signed-off-by: Atul-glo35265 --- src/AutoDiscover.php | 15 ++++++++++----- test/AutoDiscoverTest.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/AutoDiscover.php b/src/AutoDiscover.php index 7fad38b..7454a2f 100644 --- a/src/AutoDiscover.php +++ b/src/AutoDiscover.php @@ -6,7 +6,6 @@ use Laminas\Server\Reflection; use Laminas\Soap\AutoDiscover\DiscoveryStrategy\DiscoveryStrategyInterface as DiscoveryStrategy; use Laminas\Soap\AutoDiscover\DiscoveryStrategy\ReflectionDiscovery; -use Laminas\Soap\Wsdl; use Laminas\Soap\Wsdl\ComplexTypeStrategy\ComplexTypeStrategyInterface as ComplexTypeStrategy; use Laminas\Uri; @@ -15,8 +14,10 @@ use function function_exists; use function get_class; use function gettype; +use function header; use function htmlspecialchars; use function is_array; +use function is_callable; use function is_object; use function is_string; use function is_subclass_of; @@ -624,15 +625,19 @@ public function toXml() } /** - * handle function + * Handle function * - * @param string $responseHandler + * @param string|null|callable $responseHandler * @return void */ public function handle($responseHandler = null) { - $responseHandler = $responseHandler ?? 'header'; - $responseHandler('Content-Type: text/xml'); + if (is_callable($responseHandler)) { + $responseHandler('Content-Type: text/xml'); + } else { + header($responseHandler ?? 'Content-Type: text/xml'); + } + echo $this->toXml(); } } diff --git a/test/AutoDiscoverTest.php b/test/AutoDiscoverTest.php index 500a75f..16003ca 100644 --- a/test/AutoDiscoverTest.php +++ b/test/AutoDiscoverTest.php @@ -1460,7 +1460,7 @@ public function testHandle() ob_start(); - $this->server->handle(function ($header) { + $this->server->handle(function (?string $header) { // Optionally verify the header if you're mocking $this->assertEquals('Content-Type: text/xml', $header); });