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

Fix overriding the custom SoapClient class #51

Merged
merged 1 commit into from
Feb 5, 2024
Merged

Fix overriding the custom SoapClient class #51

merged 1 commit into from
Feb 5, 2024

Conversation

chyovev
Copy link
Contributor

@chyovev chyovev commented Feb 1, 2024

Hey,

in general all services extending the AbstractSoapClientBase class use PHP's default SoapClient class to handle requests, which is specified as a constant in the SoapClientInterface: DEFAULT_SOAP_CLIENT_CLASS.

As per documentation, a custom SoapClient class can be used by overriding said constant:

DEFAULT_SOAP_CLIENT_CLASS = '\SoapClient': this is the default SoapClient class that is used to send the request. Feel free to override it if you want to use another SoapClient class

However, simply overriding it does not work since the underlying SoapClient initialization method (initSoapClient()) relies on the value returned by the getSoapClientClassName() method which in turn reads the constant as a self::, i.e. as defined in the actual abstract class (or the interface in this case). Kind of like reading a private property inside a parent class – overriding in the child class has no effect.

If we use late static bindings on the other hand, it would read the constant's value from the extended class first, and then use the interface constant as a fallback: static:: instead of self::. Like turning a private property protected.

Currently, if my service extends the AbstractSoapClientBase class using all its functionality, but I decide to use a custom SoapClient, I would have to override the getSoapClientClassName() method in my service class. It would be easier if I could just specify it by overriding the DEFAULT_SOAP_CLIENT_CLASS constant – like the documentation suggests I should do 😊

@mikaelcom mikaelcom merged commit b2685f8 into WsdlToPhp:develop Feb 5, 2024
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants