Skip to content
Browse files

[UPDATE] fixing issue #8

This update resolves #8 issue because now it merges multiple element
structure when identical element is declared with different structure
  • Loading branch information...
1 parent 57df7e5 commit 1a08868ad7227542c9afdd9a5f34bcdfe475227f @mikaelcom committed Sep 6, 2013
Showing with 10 additions and 5 deletions.
  1. +10 −5 WsdlToPhpGenerator.php
View
15 WsdlToPhpGenerator.php
@@ -720,6 +720,7 @@ private function initStructs()
$structsParams = array();
foreach($types as $type)
{
+ $typeSignature = md5($type);
/**
* Remove useless break line, tabs
*/
@@ -764,9 +765,13 @@ private function initStructs()
*/
$structName = $typeDef[1];
/**
- * Struct already known ?
+ * Struct already known? If not, then parse it and add attributes to it. We don't parse twice the same struct.
+ * This test now lets pass identically named elements with different structure such as the two followings:
+ * - struct Create { Create request; }
+ * - struct Create { ArrayOfDetailItem Details; string UserID; string Password; string TestMode; etc. }
+ * This will generate a Struct class containing the merge of all the different structures
*/
- if(in_array($structName,$structsDefined))
+ if(in_array($typeSignature,$structsDefined))
continue;
/**
* Collect struct params
@@ -800,7 +805,7 @@ private function initStructs()
if(!empty($structParamType) && !empty($structParamName) && !empty($structName))
{
$this->addStruct($structName,$structParamName,$structParamType);
- $structsDefined[] = $structName;
+ array_push($structsDefined,$typeSignature);
$structParamName = '';
$structParamType = '';
}
@@ -881,7 +886,7 @@ private function generateStructsClasses($_rootDirectory,$_rootDirectoryRights)
if(!$struct->getIsStruct())
continue;
$elementFolder = $this->getDirectory($_rootDirectory,$_rootDirectoryRights,$struct);
- $structsClassesFiles[] = $structClassFileName = $elementFolder . $struct->getPackagedName() . '.php';
+ array_push($structsClassesFiles,$structClassFileName = $elementFolder . $struct->getPackagedName() . '.php');
/**
* Generates file
*/
@@ -1002,7 +1007,7 @@ private function generateServicesClasses($_rootDirectory,$_rootDirectoryRights)
foreach($services as $serviceName=>$service)
{
$elementFolder = $this->getDirectory($_rootDirectory,$_rootDirectoryRights,$service);
- $servicesClassesFiles[] = $serviceClassFileName = $elementFolder . $service->getPackagedName() . '.php';
+ array_push($servicesClassesFiles,$serviceClassFileName = $elementFolder . $service->getPackagedName() . '.php');
/**
* Generates file
*/

0 comments on commit 1a08868

Please sign in to comment.
Something went wrong with that request. Please try again.