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)) {
|
if (preg_match('/^([^\[]+)\[\]$/', $phpType, $match)) {
|
||||||
$isArray = true;
|
$isArray = true;
|
||||||
|
$array = array();
|
||||||
$phpType = $match[1];
|
$phpType = $match[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO Fix array reference
|
// @TODO Fix array reference
|
||||||
if (isset($this->definitionComplexTypes[$phpType])) {
|
if (isset($this->definitionComplexTypes[$phpType])) {
|
||||||
if ($isArray) {
|
if ($isArray) {
|
||||||
$array = array();
|
if (isset($message->item)) {
|
||||||
|
|
||||||
foreach ($message->item as $complexType) {
|
foreach ($message->item as $complexType) {
|
||||||
$array[] = $this->checkComplexType($phpType, $complexType);
|
$array[] = $this->checkComplexType($phpType, $complexType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$message = $array;
|
$message = $array;
|
||||||
} else {
|
} else {
|
||||||
$message = $this->checkComplexType($phpType, $message);
|
$message = $this->checkComplexType($phpType, $message);
|
||||||
}
|
}
|
||||||
} elseif ($isArray) {
|
} elseif ($isArray) {
|
||||||
|
if (isset($message->item)) {
|
||||||
$message = $message->item;
|
$message = $message->item;
|
||||||
|
} else {
|
||||||
|
$message = $array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
|
|
|
@ -115,6 +115,21 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
$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()
|
public function messageProvider()
|
||||||
{
|
{
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
@ -153,6 +168,14 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
array('foo' => array('foo', 'bar', 'barfoo'), 'bar' => 4),
|
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;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue