Complex classes like SoapClient often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SoapClient, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 17 | class SoapClient extends \SoapClient implements SoapClientInterface  | 
            ||
| 18 | { | 
            ||
| 19 | /**  | 
            ||
| 20 | * @var array  | 
            ||
| 21 | */  | 
            ||
| 22 | protected $options;  | 
            ||
| 23 | /**  | 
            ||
| 24 | * @var EventDispatcherInterface  | 
            ||
| 25 | */  | 
            ||
| 26 | protected $dispatcher;  | 
            ||
| 27 | /**  | 
            ||
| 28 | * @var array  | 
            ||
| 29 | */  | 
            ||
| 30 | private $mockRequests = [];  | 
            ||
| 31 | /**  | 
            ||
| 32 | * @var array  | 
            ||
| 33 | */  | 
            ||
| 34 | private $mockResponses = [];  | 
            ||
| 35 | |||
| 36 | /**  | 
            ||
| 37 | * SoapClient constructor.  | 
            ||
| 38 | * @param null $wsdl  | 
            ||
| 39 | * @param array|null $options  | 
            ||
| 40 | */  | 
            ||
| 41 | 18 | public function __construct($wsdl = null, array $options = [])  | 
            |
| 78 | |||
| 79 | 6 | public function getOptions(): array  | 
            |
| 83 | |||
| 84 | 9 | public function __call($function_name, $arguments)  | 
            |
| 98 | |||
| 99 | public function __soapCall(  | 
            ||
| 118 | |||
| 119 | /**  | 
            ||
| 120 | * @param string $request  | 
            ||
| 121 | * @param string $location  | 
            ||
| 122 | * @param string $action  | 
            ||
| 123 | * @param int $version  | 
            ||
| 124 | * @param null $one_way  | 
            ||
| 125 | * @return bool|string  | 
            ||
| 126 | */  | 
            ||
| 127 | 6 | public function __doRequest($request, $location, $action, $version, $one_way = null)  | 
            |
| 189 | |||
| 190 | /**  | 
            ||
| 191 | * Triggered before a request is executed  | 
            ||
| 192 | *  | 
            ||
| 193 | * @param string $id  | 
            ||
| 194 | * @param string $resource  | 
            ||
| 195 | * @param string $requestContent  | 
            ||
| 196 | */  | 
            ||
| 197 | 6 | protected function preCall(string $id, string $resource, string $requestContent = null)  | 
            |
| 201 | |||
| 202 | /**  | 
            ||
| 203 | * @param string $id  | 
            ||
| 204 | * @param string $resource  | 
            ||
| 205 | * @param string $response  | 
            ||
| 206 | */  | 
            ||
| 207 | 6 | protected function postCall(string $id, string $resource, string $response = null)  | 
            |
| 219 | |||
| 220 | /**  | 
            ||
| 221 | * @param string $id  | 
            ||
| 222 | * @param string $resource  | 
            ||
| 223 | * @param string $requestContent  | 
            ||
| 224 | * @param \Exception $exception  | 
            ||
| 225 | */  | 
            ||
| 226 | 3 | protected function faultCall(string $id, string $resource, string $requestContent, \Exception $exception)  | 
            |
| 233 | |||
| 234 | /**  | 
            ||
| 235 | * @param string $wsdl  | 
            ||
| 236 | * @return string  | 
            ||
| 237 | */  | 
            ||
| 238 | 18 | protected function resolveLocation($wsdl)  | 
            |
| 249 | |||
| 250 | /**  | 
            ||
| 251 | * @param array $mockRequests  | 
            ||
| 252 | */  | 
            ||
| 253 | 12 | public function setMockRequests(array $mockRequests)  | 
            |
| 257 | |||
| 258 | /**  | 
            ||
| 259 | * @param array $mockResponses  | 
            ||
| 260 | */  | 
            ||
| 261 | 12 | public function setMockResponses(array $mockResponses)  | 
            |
| 265 | |||
| 266 | /**  | 
            ||
| 267 | * @param EventDispatcherInterface $dispatcher  | 
            ||
| 268 | * @required  | 
            ||
| 269 | */  | 
            ||
| 270 | 18 | public function setDispatcher(EventDispatcherInterface $dispatcher)  | 
            |
| 278 | |||
| 279 | /**  | 
            ||
| 280 | * @param $function_name  | 
            ||
| 281 | * @param $arguments  | 
            ||
| 282 | * @param $e  | 
            ||
| 283 | */  | 
            ||
| 284 | 3 | protected function handleFault($function_name, $arguments, $e): void  | 
            |
| 295 | |||
| 296 | /**  | 
            ||
| 297 | * @param Event $event  | 
            ||
| 298 | * @param string $eventName  | 
            ||
| 299 | */  | 
            ||
| 300 | 9 | private function dispatch(Event $event, $eventName)  | 
            |
| 315 | }  | 
            ||
| 316 | 
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: