From ee74445580419cdff9302e2837da4b1ae39446aa Mon Sep 17 00:00:00 2001 From: Yasser Bal Date: Wed, 27 May 2026 20:00:09 +0200 Subject: [PATCH 1/4] GenConfigCommand| print wsdl loading exceptions when output is verbose --- .../Console/Command/GenerateConfigCommand.php | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php index f866e9ee..36fc8a47 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php @@ -2,6 +2,7 @@ namespace Phpro\SoapClient\Console\Command; +use Laminas\Code\Generator\FileGenerator; use Phpro\SoapClient\CodeGenerator\Config\ClassMapConfig; use Phpro\SoapClient\CodeGenerator\Config\ClientConfig; use Phpro\SoapClient\CodeGenerator\Config\Destination; @@ -18,7 +19,6 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; -use Laminas\Code\Generator\FileGenerator; class GenerateConfigCommand extends Command { @@ -45,13 +45,13 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - $context = new ConfigContext(); + $context = new ConfigContext; $io = new SymfonyStyle($input, $output); - $required = new NotBlankValidator(); + $required = new NotBlankValidator; // Ask for config location: $destination = $input->getOption('config'); - if (!$destination) { + if (! $destination) { $destination = $io->ask( 'config location (Where to put the config, including .php)', 'config/soap-client.php' @@ -62,11 +62,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int $context->setWsdl($wsdlUri); $io->warning('Attempting to load WSDL... (this might take a while)'); - $wsdl = $this->loadWsdl($wsdlUri); - - if (!$wsdl) { + try { + $wsdl = $this->loadWsdl($wsdlUri); + } catch (\Throwable $e) { $io->warning('Could not load the provided WSDL with default engine options.'); + if ($output->isVerbose()) { + $io->text(''.$e::class.''); + $io->text($e->getMessage()); + } + if ($output->isVeryVerbose()) { + $io->text($e->getTraceAsString()); + } $io->info('Continuing generating configuration...'); + $wsdl = null; } $context->setDetectedXmlNamespaces($wsdl?->namespaces->namespaceToNameMap ?? []); @@ -80,24 +88,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespace = Normalizer::normalizeNamespace($io->ask('Namespace for your client', null, $required)); // Create configuration objects - $typeDestination = new Destination($baseDir . DIRECTORY_SEPARATOR . 'Type', $namespace . '\\Type'); + $typeDestination = new Destination($baseDir.DIRECTORY_SEPARATOR.'Type', $namespace.'\\Type'); $context->setTypeDestination($typeDestination); $clientDestination = new Destination($baseDir, $namespace); - $clientConfig = new ClientConfig($name . 'Client', $clientDestination); + $clientConfig = new ClientConfig($name.'Client', $clientDestination); $context->setClientConfig($clientConfig); - $classMapConfig = new ClassMapConfig($name . 'Classmap', $clientDestination); + $classMapConfig = new ClassMapConfig($name.'Classmap', $clientDestination); $context->setClassMapConfig($classMapConfig); // Create the config - $generator = new ConfigGenerator(); - $this->filesystem->putFileContents($destination, $generator->generate(new FileGenerator(), $context)); - $io->success('Config has been written to ' . $destination); + $generator = new ConfigGenerator; + $this->filesystem->putFileContents($destination, $generator->generate(new FileGenerator, $context)); + $io->success('Config has been written to '.$destination); - if (!$wsdl) { + if (! $wsdl) { $io->warning( - 'The WSDL could not be loaded with default options.' . + 'The WSDL could not be loaded with default options.'. 'You may need to configure custom engine options or verify the WSDL file manually before continuing.' ); @@ -107,15 +115,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int return self::SUCCESS; } - private function loadWsdl(string $wsdl): ?Wsdl1 + private function loadWsdl(string $wsdl): Wsdl1 { - try { - $options = EngineOptions::defaults($wsdl); - $loader = $options->getWsdlLoader(); + $options = EngineOptions::defaults($wsdl); + $loader = $options->getWsdlLoader(); - return (new Wsdl1Reader($loader))($wsdl); - } catch (\Throwable) { - return null; - } + return (new Wsdl1Reader($loader))($wsdl); } } From 4287b266b4ef747afad53512fe7d107288ff0f5b Mon Sep 17 00:00:00 2001 From: Yasser Bal Date: Thu, 28 May 2026 08:13:14 +0200 Subject: [PATCH 2/4] Fix - revert formatting changes --- .../Console/Command/GenerateConfigCommand.php | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php index 36fc8a47..5ac4cb71 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php @@ -2,7 +2,6 @@ namespace Phpro\SoapClient\Console\Command; -use Laminas\Code\Generator\FileGenerator; use Phpro\SoapClient\CodeGenerator\Config\ClassMapConfig; use Phpro\SoapClient\CodeGenerator\Config\ClientConfig; use Phpro\SoapClient\CodeGenerator\Config\Destination; @@ -19,6 +18,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; +use Laminas\Code\Generator\FileGenerator; class GenerateConfigCommand extends Command { @@ -45,13 +45,13 @@ protected function configure(): void protected function execute(InputInterface $input, OutputInterface $output): int { - $context = new ConfigContext; + $context = new ConfigContext(); $io = new SymfonyStyle($input, $output); - $required = new NotBlankValidator; + $required = new NotBlankValidator(); // Ask for config location: $destination = $input->getOption('config'); - if (! $destination) { + if (!$destination) { $destination = $io->ask( 'config location (Where to put the config, including .php)', 'config/soap-client.php' @@ -62,6 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $context->setWsdl($wsdlUri); $io->warning('Attempting to load WSDL... (this might take a while)'); + try { $wsdl = $this->loadWsdl($wsdlUri); } catch (\Throwable $e) { @@ -77,6 +78,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $wsdl = null; } + $context->setDetectedXmlNamespaces($wsdl?->namespaces->namespaceToNameMap ?? []); $context->setGenerateDocblocks($io->confirm('Should methods be generated with docblocks?', true)); $name = $io->ask( @@ -88,24 +90,24 @@ protected function execute(InputInterface $input, OutputInterface $output): int $namespace = Normalizer::normalizeNamespace($io->ask('Namespace for your client', null, $required)); // Create configuration objects - $typeDestination = new Destination($baseDir.DIRECTORY_SEPARATOR.'Type', $namespace.'\\Type'); + $typeDestination = new Destination($baseDir . DIRECTORY_SEPARATOR . 'Type', $namespace . '\\Type'); $context->setTypeDestination($typeDestination); $clientDestination = new Destination($baseDir, $namespace); - $clientConfig = new ClientConfig($name.'Client', $clientDestination); + $clientConfig = new ClientConfig($name . 'Client', $clientDestination); $context->setClientConfig($clientConfig); - $classMapConfig = new ClassMapConfig($name.'Classmap', $clientDestination); + $classMapConfig = new ClassMapConfig($name . 'Classmap', $clientDestination); $context->setClassMapConfig($classMapConfig); // Create the config - $generator = new ConfigGenerator; - $this->filesystem->putFileContents($destination, $generator->generate(new FileGenerator, $context)); - $io->success('Config has been written to '.$destination); + $generator = new ConfigGenerator(); + $this->filesystem->putFileContents($destination, $generator->generate(new FileGenerator(), $context)); + $io->success('Config has been written to ' . $destination); - if (! $wsdl) { + if (!$wsdl) { $io->warning( - 'The WSDL could not be loaded with default options.'. + 'The WSDL could not be loaded with default options.' . 'You may need to configure custom engine options or verify the WSDL file manually before continuing.' ); @@ -117,9 +119,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int private function loadWsdl(string $wsdl): Wsdl1 { - $options = EngineOptions::defaults($wsdl); - $loader = $options->getWsdlLoader(); + $options = EngineOptions::defaults($wsdl); + $loader = $options->getWsdlLoader(); - return (new Wsdl1Reader($loader))($wsdl); + return (new Wsdl1Reader($loader))($wsdl); } } From 2532534ce77b0de8db77f504a73b7899f136d2f6 Mon Sep 17 00:00:00 2001 From: Yasser Bal Date: Thu, 28 May 2026 08:14:38 +0200 Subject: [PATCH 3/4] GenerateConfigCommand - use io->error for verbose exceptions --- src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php index 5ac4cb71..0bab5f28 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php @@ -68,8 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } catch (\Throwable $e) { $io->warning('Could not load the provided WSDL with default engine options.'); if ($output->isVerbose()) { - $io->text(''.$e::class.''); - $io->text($e->getMessage()); + $io->error($e::class.': ' . $e->getMessage()); } if ($output->isVeryVerbose()) { $io->text($e->getTraceAsString()); From 1153321f76793e3d938ba1852d808fb7594618a2 Mon Sep 17 00:00:00 2001 From: Yasser Bal Date: Thu, 28 May 2026 09:28:44 +0200 Subject: [PATCH 4/4] GenerateConfigCommand - always print wsdl loading errors --- .../SoapClient/Console/Command/GenerateConfigCommand.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php index 0bab5f28..3b7227bf 100644 --- a/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php +++ b/src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php @@ -67,11 +67,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $wsdl = $this->loadWsdl($wsdlUri); } catch (\Throwable $e) { $io->warning('Could not load the provided WSDL with default engine options.'); - if ($output->isVerbose()) { - $io->error($e::class.': ' . $e->getMessage()); - } + $io->error([$e::class,$e->getMessage()]); if ($output->isVeryVerbose()) { - $io->text($e->getTraceAsString()); + $io->text(explode("\n", $e->getTraceAsString())); } $io->info('Continuing generating configuration...'); $wsdl = null;