Skip to content

Make it possible to configure a mapping of type namespaces based on xmlns#599

Merged
veewee merged 5 commits intophpro:v5.xfrom
veewee:type-namespace-map
Feb 27, 2026
Merged

Make it possible to configure a mapping of type namespaces based on xmlns#599
veewee merged 5 commits intophpro:v5.xfrom
veewee:type-namespace-map

Conversation

@veewee
Copy link
Copy Markdown
Contributor

@veewee veewee commented Dec 19, 2025

See #571

This is a breaking change, since it introduces a new way of configuring the code generation.
The models and contexts also changed.

Example:

use Phpro\SoapClient\CodeGenerator\Config\ClassMapConfig;
use Phpro\SoapClient\CodeGenerator\Config\ClientConfig;
use Phpro\SoapClient\CodeGenerator\Config\Destination;
use Phpro\SoapClient\CodeGenerator\Config\TypeNamespaceMap;
use Phpro\SoapClient\CodeGenerator\TypeNamespaceMap\Strategy\PrefixBasedTypeNamespaceStrategy;

return Config::create()
    ->setEngine($engine = DefaultEngineFactory::create(
        EngineOptions::defaults('your.wsdl')
    ))
    ->setTypeNamespaceMap(
        TypeNamespaceMap::create(fallback: new Destination('src/Type', 'App\\Type'))
           // Explicit mappings (generated during wizard : config setup)
            ->withMapping('http://xoev.de/schemata/xzufi/2_2_0', new Destination('src/Type/Xoev', 'App\\Type\\Xoev'))
            ->withMapping('http://www.opengis.net/gml/3.2', new Destination('src/Type/Gml', 'App\\Type\\Gml'))
            ->withMapping('http://www.isotc211.org/2005/gmd', new Destination('src/Type/Gmd', 'App\\Type\\Gmd'))
            ->withMapping('http://www.isotc211.org/2005/gmc', new Destination('src/Type/Gmc', 'App\\Type\\Gmc'))
            ->withMapping('http://www.isotc211.org/2005/gco', new Destination('src/Type/Gco', 'App\\Type\\Gco'))
            ->withMapping('http://www.isotc211.org/2005/gss', new Destination('src/Type/Gss', 'App\\Type\\Gss'))
            ->withMapping('http://www.isotc211.org/2005/gts', new Destination('src/Type/Gts', 'App\\Type\\Gts'))
            ->withMapping('http://www.w3.org/1999/xlink', new Destination('src/Type/Xlink', 'App\\Type\\Xlink'))

            // You could also specify a strategy that will be used if no mapping is found:
            ->withStrategy(new PrefixBasedTypeNamespaceStrategy())
    )
    ->setClient(new ClientConfig('MyClient', new Destination('src', 'App')))
    ->setClassMap(new ClassMapConfig('MyClassmap', new Destination('src', 'App')));

@veewee veewee marked this pull request as draft December 19, 2025 12:20
Comment thread src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php Outdated
Comment thread src/Phpro/SoapClient/Console/Command/GenerateConfigCommand.php Outdated
@veewee veewee changed the title Make it possible to configure a mapping of type namespaces based on xmlns [WIP] Make it possible to configure a mapping of type namespaces based on xmlns Dec 19, 2025
@veewee veewee force-pushed the type-namespace-map branch from 7674629 to 35fc5de Compare January 30, 2026 07:19
@veewee veewee force-pushed the type-namespace-map branch 5 times, most recently from 69dffd1 to 69fb234 Compare January 30, 2026 15:51
@veewee veewee force-pushed the type-namespace-map branch from 69fb234 to 587f35b Compare January 30, 2026 15:59
@veewee veewee changed the base branch from v4.x to v5.x February 27, 2026 06:09
Comment thread src/Phpro/SoapClient/CodeGenerator/Config/TypeNamespaceMap.php Outdated
@veewee veewee force-pushed the type-namespace-map branch from 669f867 to 7a6e341 Compare February 27, 2026 08:57
@veewee veewee force-pushed the type-namespace-map branch from 7a6e341 to 23d6efe Compare February 27, 2026 09:13
@veewee veewee marked this pull request as ready for review February 27, 2026 09:24
@veewee veewee requested a review from Copilot February 27, 2026 09:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces a major breaking change (v4 to v5) that enables configuration of type namespace mappings based on XML namespaces (xmlns). The change addresses issue #571, which requested support for types in multiple namespaces using PHP 8.4's Clark notation.

Changes:

  • Introduces new configuration value objects (Destination, ClientConfig, ClassMapConfig, TypeNamespaceMap) to replace scattered string-based configuration
  • Implements XML namespace-aware type generation with explicit mappings and strategy-based resolution
  • Makes duplicate type detection namespace-aware (types in different target PHP namespaces are no longer considered duplicates)
  • Updates all model classes, contexts, generators, and console commands to work with the new configuration structure
  • Adds comprehensive test coverage for new functionality
  • Includes detailed documentation and upgrade guide

Reviewed changes

Copilot reviewed 113 out of 113 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Phpro/SoapClient/CodeGenerator/Config/* New configuration value objects and TypeNamespaceMap implementation
src/Phpro/SoapClient/CodeGenerator/Model/* Updated to use TypeNamespaceMap instead of plain strings
src/Phpro/SoapClient/CodeGenerator/Context/* Updated to use new config objects
src/Phpro/SoapClient/CodeGenerator/*Generator.php Updated generators to work with new configuration
src/Phpro/SoapClient/Soap/Metadata/Manipulators/DuplicateTypes/* Namespace-aware duplicate detection
src/Phpro/SoapClient/Console/Command/* Updated commands to use new configuration
test/**/*Test.php Comprehensive test coverage for changes
docs/**/*.md Updated documentation and upgrade guide

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@veewee veewee changed the title [WIP] Make it possible to configure a mapping of type namespaces based on xmlns Make it possible to configure a mapping of type namespaces based on xmlns Feb 27, 2026
@veewee veewee merged commit 6bfdcc7 into phpro:v5.x Feb 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants