Permalink
Browse files

[UPDATE] php doc enhancement

[UPDATE] php doc enhancement
Ensure header type is well retrieved from the message part
  • Loading branch information...
1 parent 99a7403 commit ea076fc508846666e8363bb3d2e9e96acee377f6 @mikaelcom committed Jan 24, 2013
Showing with 39 additions and 24 deletions.
  1. +39 −24 WsdlToPhpGenerator.php
View
@@ -2408,36 +2408,51 @@ protected function manageWsdlNodeHeader($_wsdlLocation = '',DOMNode $_domNode,$_
if($nodesLength == 1 && ($nodes->item(0) instanceof DOMNode) && stripos($nodes->item(0)->nodeName,'part') !== false)
{
$part = $nodes->item(0);
- $partElement = explode(':',$part->hasAttribute('element')?$part->getAttribute('element'):'');
- $partElement = count($partElement)?$partElement[count($partElement) - 1]:'';
- /**
- * Find element part in the WSDLs
- */
- foreach($this->getWsdls() as $wsdlLocation=>$meta)
+ $partElement = '';
+ $partAttributes = array(
+ 'element',
+ 'type');
+ foreach($partAttributes as $partAttributeName)
{
- $domDocument = self::wsdlLocationToDomDocument($wsdlLocation);
- if($domDocument instanceof DOMDocument)
+ if($part->hasAttribute($partAttributeName))
{
- $domXPath = new DOMXPath($domDocument);
- $nodes = $domXPath->query("//*[@name='$partElement']");
- $nodesLength = $nodes->length;
- $nodeIndex = 0;
- while($nodeIndex < $nodesLength && (!($nodes->item($nodeIndex) instanceof DOMElement) || (($nodes->item($nodeIndex) instanceof DOMElement) && (!$nodes->item($nodeIndex)->hasAttribute('type') || ($nodes->item($nodeIndex)->hasAttribute('type') && $nodes->item($nodeIndex)->getAttribute('type') === '')))) && $nodeIndex++);
- if($nodeIndex <= $nodesLength && ($nodes->item($nodeIndex) instanceof DOMElement) && $nodes->item($nodeIndex)->hasAttribute('type') && $nodes->item($nodeIndex)->getAttribute('type') != '')
- {
- $headerType = explode(':',$nodes->item($nodeIndex)->getAttribute('type'));
- $headerType = $headerType[count($headerType) - 1];
- if($this->getStruct($headerType) && $this->getStruct($headerType)->getIsStruct())
- $headerType = '{@link ' . $this->getStruct($headerType)->getPackagedName() . '}';
+ $partElements = explode(':',$part->getAttribute($partAttributeName));
+ $partElement = count($partElements)?$partElements[count($partElements) - 1]:'';
+ if(!empty($partElement))
break;
+ }
+ }
+ if(!empty($partElement))
+ {
+ /**
+ * Find element part in the WSDLs
+ */
+ foreach($this->getWsdls() as $wsdlLocation=>$meta)
+ {
+ $domDocument = self::wsdlLocationToDomDocument($wsdlLocation);
+ if($domDocument instanceof DOMDocument)
+ {
+ $domXPath = new DOMXPath($domDocument);
+ $nodes = $domXPath->query("//*[@name='$partElement']");
+ $nodesLength = $nodes->length;
+ $nodeIndex = 0;
+ while($nodeIndex < $nodesLength && (!($nodes->item($nodeIndex) instanceof DOMElement) || (($nodes->item($nodeIndex) instanceof DOMElement) && (!$nodes->item($nodeIndex)->hasAttribute('type') || ($nodes->item($nodeIndex)->hasAttribute('type') && $nodes->item($nodeIndex)->getAttribute('type') === '')))) && $nodeIndex++);
+ if($nodeIndex <= $nodesLength && ($nodes->item($nodeIndex) instanceof DOMElement) && $nodes->item($nodeIndex)->hasAttribute('type') && $nodes->item($nodeIndex)->getAttribute('type') != '')
+ {
+ $headerType = explode(':',$nodes->item($nodeIndex)->getAttribute('type'));
+ $headerType = $headerType[count($headerType) - 1];
+ if($this->getStruct($headerType) && $this->getStruct($headerType)->getIsStruct())
+ $headerType = '{@link ' . $this->getStruct($headerType)->getPackagedName() . '}';
+ break;
+ }
}
}
+ /**
+ * Element type not found, then it's maybe an already known struct ?
+ */
+ if(empty($headerType) && $this->getStruct($partElement) && $this->getStruct($partElement)->getIsStruct())
+ $headerType = '{@link ' . $this->getStruct($partElement)->getPackagedName() . '}';
}
- /**
- * Element type not found, then it's maybe an already known struct ?
- */
- if(empty($headerType) && $this->getStruct($partElement) && $this->getStruct($partElement)->getIsStruct())
- $headerType = '{@link ' . $this->getStruct($partElement)->getPackagedName() . '}';
}
}
if(!empty($headerType))

0 comments on commit ea076fc

Please sign in to comment.