Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - removing the "item" object type and using the actual object type for arrays #1

Merged
merged 3 commits into from
Sep 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
composer.lock
phpunit.xml
.idea/*
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,24 @@ public function processMessage(Method $messageDefinition, $message, TypeReposito
protected function processType($phpType, $message)
{
$isArray = false;
$arrayOfTypeName = '';

$type = $this->typeRepository->getType($phpType);
if ($type instanceof ArrayOfType) {
$isArray = true;
$array = array();
$arrayOfTypeName = str_replace('ArrayOf', '', $type->getXmlType());

$type = $this->typeRepository->getType($type->get('item')->getType());
$type = $this->typeRepository->getType($type->get($arrayOfTypeName)->getType());
}

// @TODO Fix array reference
if ($type instanceof ComplexType) {
$phpType = $type->getPhpType();

if ($isArray) {
if (isset($message->item)) {
foreach ($message->item as $complexType) {
if (isset($message->{$arrayOfTypeName})) {
foreach ($message->{$arrayOfTypeName} as $complexType) {
$array[] = $this->checkComplexType($phpType, $complexType);
}

Expand All @@ -84,8 +86,8 @@ protected function processType($phpType, $message)
$message = $this->checkComplexType($phpType, $message);
}
} elseif ($isArray) {
if (isset($message->item)) {
$message = $message->item;
if (isset($message->{$arrayOfTypeName})) {
$message = $message->{$arrayOfTypeName};
} else {
$message = $array;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ private function processType($phpType, $message)
$type = $this->typeRepository->getType($phpType);
if ($type instanceof ArrayOfType) {
$isArray = true;
$arrayOfTypeName = str_replace('ArrayOf', '', $type->getXmlType());

$type = $this->typeRepository->getType($type->get('item')->getType());
$type = $this->typeRepository->getType($type->get($arrayOfTypeName)->getType());
}

if ($type instanceof ComplexType) {
Expand Down
2 changes: 1 addition & 1 deletion src/BeSimple/SoapCommon/Definition/Type/ArrayOfType.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function __construct($phpType, $arrayOf, $xmlTypeOf)

parent::__construct($phpType, 'ArrayOf'.ucfirst($xmlTypeOf ?: $arrayOf));

$this->add('item', $arrayOf);
$this->add($xmlTypeOf, $arrayOf);
}
}