Fixed issue #10

This commit is contained in:
Francis Besset 2011-09-14 22:03:46 +02:00
parent a0a92dd1b4
commit 33d1e4031c
2 changed files with 9 additions and 9 deletions

View File

@ -67,17 +67,12 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
$this->messageRefs[$hash] = $message; $this->messageRefs[$hash] = $message;
$class = $phpType; if (!$message instanceof $phpType) {
if ($class[0] == '\\') { throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', get_class($message), $phpType));
$class = substr($class, 1);
}
if (!$message instanceof $class) {
throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', get_class($message), $class));
} }
$r = new \ReflectionClass($message); $r = new \ReflectionClass($message);
foreach ($this->definitionComplexTypes[$class] as $type) { foreach ($this->definitionComplexTypes[$phpType] as $type) {
$p = $r->getProperty($type->getName()); $p = $r->getProperty($type->getName());
if ($p->isPublic()) { if ($p->isPublic()) {
$value = $message->{$type->getName()}; $value = $message->{$type->getName()};
@ -91,7 +86,7 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
} }
if (!$type->isNillable() && null === $value) { if (!$type->isNillable() && null === $value) {
throw new \InvalidArgumentException(sprintf('"%s::%s" cannot be null.', $class, $type->getName())); throw new \InvalidArgumentException(sprintf('"%s::%s" cannot be null.', $phpType, $type->getName()));
} }
} }

View File

@ -30,6 +30,11 @@ class Type
public function setPhpType($phpType) public function setPhpType($phpType)
{ {
$phpType = $phpType;
if ($phpType[0] == '\\') {
$phpType = substr($phpType, 1);
}
$this->phpType = $phpType; $this->phpType = $phpType;
} }