Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use external classes as property types. #548

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Sep 27, 2024

Fixes #543, #531

Allows to specify a PHP class as property type:

use Phpro\SoapClient\Soap\Metadata\Manipulators\TypeReplacer\TypeReplacer;
use Soap\Engine\Metadata\Model\XsdType;
use Soap\WsdlReader\Metadata\Predicate\IsOfType;

class GuidTypeReplacer implements TypeReplacer
{
    public function __invoke(XsdType $xsdType): XsdType
    {
        $check = new IsOfType('http://microsoft.com/wsdl/types/', 'guid');
        if (!$check($xsdType)) {
            return $xsdType;
        }

        return $xsdType->copy(\Ramsey\Uuid\UuidInterface::class);
    }
}

This will result in:

namespace MyNamespace;

class MyType
{
    /**
     * Type specific docs
     *
     * @var \Ramsey\Uuid\UuidInterface
     */
    private \Ramsey\Uuid\UuidInterface $prop1;
}

(it will also be known this way in the other assemblers like Getters, Setters, ...)

/cc @rauanmayemir: The implementation is a bit tricky, but it does the job. Feel free to play around with it.

@veewee veewee force-pushed the use-external-classes-as-prop-types branch 2 times, most recently from 04cf0a8 to 02e2936 Compare September 27, 2024 12:11
@rauanmayemir
Copy link

Could you rebase with changes from main?

@veewee veewee force-pushed the use-external-classes-as-prop-types branch from 02e2936 to dfa7fde Compare September 27, 2024 12:51
@veewee
Copy link
Contributor Author

veewee commented Sep 27, 2024

@rauanmayemir done

@veewee veewee added this to the 4.0.0 milestone Sep 27, 2024
@rauanmayemir
Copy link

I believe this works. 🙌
I think all these changes warrant 4.0.0-alpha2, no?

@veewee veewee merged commit 8946e9c into phpro:v4.x Sep 27, 2024
12 checks passed
@veewee
Copy link
Contributor Author

veewee commented Sep 27, 2024

Yes, tagged it
https://github.com/phpro/soap-client/releases/tag/4.0.0-alpha2

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.

v4 codegen: php type encoder
2 participants