Fixed error if an array is empty in RpcLiteralRequestMessageBinder
This commit is contained in:
parent
958efd3431
commit
faf8b58108
|
@ -49,24 +49,29 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
|||
|
||||
if (preg_match('/^([^\[]+)\[\]$/', $phpType, $match)) {
|
||||
$isArray = true;
|
||||
$array = array();
|
||||
$phpType = $match[1];
|
||||
}
|
||||
|
||||
// @TODO Fix array reference
|
||||
if (isset($this->definitionComplexTypes[$phpType])) {
|
||||
if ($isArray) {
|
||||
$array = array();
|
||||
|
||||
if (isset($message->item)) {
|
||||
foreach ($message->item as $complexType) {
|
||||
$array[] = $this->checkComplexType($phpType, $complexType);
|
||||
}
|
||||
}
|
||||
|
||||
$message = $array;
|
||||
} else {
|
||||
$message = $this->checkComplexType($phpType, $message);
|
||||
}
|
||||
} elseif ($isArray) {
|
||||
if (isset($message->item)) {
|
||||
$message = $message->item;
|
||||
} else {
|
||||
$message = $array;
|
||||
}
|
||||
}
|
||||
|
||||
return $message;
|
||||
|
|
|
@ -115,6 +115,21 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
||||
}
|
||||
|
||||
public function testProcessMessageWithEmptyArrayComplexType()
|
||||
{
|
||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||
|
||||
$result = $messageBinder->processMessage(
|
||||
new Definition\Method('empty_array_complex_type', null, array(), array(
|
||||
new Definition\Argument('foo', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]')),
|
||||
)),
|
||||
array(new \stdClass()),
|
||||
$this->getDefinitionComplexTypes()
|
||||
);
|
||||
|
||||
$this->assertEquals(array('foo' => array()), $result);
|
||||
}
|
||||
|
||||
public function messageProvider()
|
||||
{
|
||||
$messages = array();
|
||||
|
@ -153,6 +168,14 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||
array('foo' => array('foo', 'bar', 'barfoo'), 'bar' => 4),
|
||||
);
|
||||
|
||||
$messages[] = array(
|
||||
new Definition\Method('empty_array', null, array(), array(
|
||||
new Definition\Argument('foo', new Definition\Type('string[]')),
|
||||
)),
|
||||
array(new \stdClass()),
|
||||
array('foo' => array()),
|
||||
);
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue