Merge remote-tracking branch 'origin/master' into client
This commit is contained in:
commit
48a7e1c991
|
@ -81,9 +81,11 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
{
|
{
|
||||||
$hash = spl_object_hash($message);
|
$hash = spl_object_hash($message);
|
||||||
if (isset($this->messageRefs[$hash])) {
|
if (isset($this->messageRefs[$hash])) {
|
||||||
return $message;
|
return $this->messageRefs[$hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->messageRefs[$hash] = $message;
|
||||||
|
|
||||||
$r = new \ReflectionClass($message);
|
$r = new \ReflectionClass($message);
|
||||||
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
||||||
$p = $r->getProperty($type->getName());
|
$p = $r->getProperty($type->getName());
|
||||||
|
@ -101,6 +103,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->messageRefs[$hash] = $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -65,6 +65,8 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
||||||
return $this->messageRefs[$hash];
|
return $this->messageRefs[$hash];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->messageRefs[$hash] = $message;
|
||||||
|
|
||||||
$class = $phpType;
|
$class = $phpType;
|
||||||
if ($class[0] == '\\') {
|
if ($class[0] == '\\') {
|
||||||
$class = substr($class, 1);
|
$class = substr($class, 1);
|
||||||
|
@ -79,18 +81,20 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
||||||
$p = $r->getProperty($type->getName());
|
$p = $r->getProperty($type->getName());
|
||||||
if ($p->isPublic()) {
|
if ($p->isPublic()) {
|
||||||
$value = $message->{$type->getName()};
|
$value = $message->{$type->getName()};
|
||||||
|
|
||||||
|
$message->{$type->getName()} = $this->processType($type->getValue(), $value);
|
||||||
} else {
|
} else {
|
||||||
$p->setAccessible(true);
|
$p->setAccessible(true);
|
||||||
$value = $p->getValue($message);
|
$value = $p->getValue($message);
|
||||||
}
|
|
||||||
|
|
||||||
$value = $this->processType($type->getValue(), $value);
|
$p->setValue($message, $this->processType($type->getValue(), $value));
|
||||||
|
}
|
||||||
|
|
||||||
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.', $class, $type->getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->messageRefs[$hash] = $message;
|
return $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -130,6 +130,25 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(array('foo' => array()), $result);
|
$this->assertEquals(array('foo' => array()), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProccessMessagePreventInfiniteRecursion()
|
||||||
|
{
|
||||||
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$foo = new Fixtures\FooRecursive('foo', '');
|
||||||
|
$bar = new Fixtures\BarRecursive($foo, 10394);
|
||||||
|
$foo->setBar($bar);
|
||||||
|
|
||||||
|
$result = $messageBinder->processMessage(
|
||||||
|
new Definition\Method('prevent_infinite_recursion', null, array(), array(
|
||||||
|
new Definition\Argument('foo_recursive', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive')),
|
||||||
|
)),
|
||||||
|
array($foo),
|
||||||
|
$this->getDefinitionComplexTypes()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertEquals(array('foo_recursive' => $foo), $result);
|
||||||
|
}
|
||||||
|
|
||||||
public function messageProvider()
|
public function messageProvider()
|
||||||
{
|
{
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
@ -188,16 +207,24 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
array('bar', 'int'),
|
array('bar', 'int'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->definitionComplexTypes['\BeSimple\SoapBundle\Tests\ServiceBinding\fixtures\Bar'] = $this->createComplexTypeCollection(array(
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'] = $this->createComplexTypeCollection(array(
|
||||||
array('foo', 'string'),
|
array('foo', 'string'),
|
||||||
array('bar', 'int', true),
|
array('bar', 'int', true),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->definitionComplexTypes['\BeSimple\SoapBundle\Tests\ServiceBinding\fixtures\FooBar'] = $this->createComplexTypeCollection(array(
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooBar'] = $this->createComplexTypeCollection(array(
|
||||||
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo'),
|
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo'),
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'] = $this->createComplexTypeCollection(array(
|
||||||
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'),
|
||||||
|
));
|
||||||
|
|
||||||
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'] = $this->createComplexTypeCollection(array(
|
||||||
|
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'),
|
||||||
|
));
|
||||||
|
|
||||||
return $definitionComplexTypes;
|
return $definitionComplexTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue