protected function checkComplexType($phpType, $message) { $hash = spl_object_hash($message); if (isset($this->messageRefs[$hash])) { return $this->messageRefs[$hash]; } $this->messageRefs[$hash] = $message; $messageBinder = new MessageBinder($message); foreach ($this->typeRepository->getType($phpType)->all() as $type) { $property = $type->getName(); $value = $messageBinder->readProperty($property); if (null !== $value) { $value = $this->processType($type->getType(), $value); $messageBinder->writeProperty($property, $value); } elseif (!$type->isNillable()) { // @TODO use xmlType instead of phpType throw new \SoapFault('SOAP_ERROR_COMPLEX_TYPE', sprintf('"%s:%s" cannot be null.', ucfirst($phpType), $type->getName())); } } return $message; }
private function checkComplexType($phpType, $message) { $hash = spl_object_hash($message); if (isset($this->messageRefs[$hash])) { return $this->messageRefs[$hash]; } $this->messageRefs[$hash] = $message; if (!$message instanceof $phpType) { throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', $phpType, get_class($message))); } $messageBinder = new MessageBinder($message); foreach ($this->typeRepository->getType($phpType)->all() as $type) { $property = $type->getName(); $value = $messageBinder->readProperty($property); if (null !== $value) { $value = $this->processType($type->getType(), $value); $messageBinder->writeProperty($property, $value); } if (!$type->isNillable() && null === $value) { throw new \InvalidArgumentException(sprintf('"%s::%s" cannot be null.', $phpType, $type->getName())); } } return $message; }