Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

[UPDATE] php doc and WsdlToPhpGenerator updates

[UPDATE] php doc and WsdlToPhpGenerator updates

WsdlToPhpGenerator::manageWsdlNodeAttribute() is now well used. It means
it is used for attribute tags and attribut elements (part of a struct).
WsdlTophpGenerator::manageWsdlNodeElement() is now used for element tags
only and is empty for now.

WsdlTophpModel::cleanComment() displays unique values depending on its
last parameter value.

Minor php doc updates
  • Loading branch information...
mikaelcom committed Feb 11, 2013
1 parent 9194b3e commit d7f6fb61d8ee04d210078957d1edc85e7759291c
Showing with 53 additions and 33 deletions.
  1. +1 −1 WsdlToPhpFunction.php
  2. +44 −24 WsdlToPhpGenerator.php
  3. +4 −3 WsdlToPhpModel.php
  4. +1 −1 WsdlToPhpService.php
  5. +1 −2 WsdlToPhpStructAttribute.php
  6. +2 −2 WsdlToPhpStructValue.php
@@ -41,7 +41,7 @@ public function __construct($_name,$_parameterType,$_returnType,WsdlToPhpService
$this->setOwner($_wsdlToPhpService);
}
/**
* Returns the commment lines for this function
* Returns the comment lines for this function
* @see WsdlToPhpModel::getComment()
* @uses WsdlToPhpStructAttribute::getGetterName()
* @uses WsdlToPhpFunction::getParameterType()
@@ -2034,9 +2034,14 @@ protected function manageWsdlNode($_wsdlLocation = '',$_domNode = null,$_fromWsd
elseif(stripos($_domNode->nodeName,'enumeration') !== false)
$this->manageWsdlNodeEnumeration($_wsdlLocation,$_domNode,$_fromWsdlLocation);
/**
* Element's, part of a struct
* Element's, part of a struct called attribute
*/
elseif((stripos($_domNode->nodeName,'element') !== false || stripos($_domNode->nodeName,'attribute') !== false) && $_domNode->hasAttribute('name') && $_domNode->getAttribute('name') != '' && $_domNode->hasAttribute('type') && $_domNode->getAttribute('type') != '')
elseif($_domNode->hasAttribute('name') && $_domNode->getAttribute('name') != '' && $_domNode->hasAttribute('type') && $_domNode->getAttribute('type') != '')
$this->manageWsdlNodeAttribute($_wsdlLocation,$_domNode,$_fromWsdlLocation);
/**
* Element
*/
elseif(stripos($_domNode->nodeName,'element') !== false)
$this->manageWsdlNodeElement($_wsdlLocation,$_domNode,$_fromWsdlLocation);
/**
* Documentation's
@@ -2235,13 +2240,15 @@ protected function manageWsdlNodeRestriction($_wsdlLocation = '',DOMNode $_domNo
$childNode = $childNodes->item($i);
/**
* Not an enumeration restriction :
* <code>
* <xs:simpleType name="duration">
* -<xs:restriction base="xs:duration">
* --<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
* --<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
* --<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
* -</xs:restriction>
* </xs:simpleType>
* </code>
*/
if($childNode && stripos($childNode->nodeName,'enumeration') === false && $childNode->hasAttributes())
{
@@ -2293,20 +2300,8 @@ protected function manageWsdlNodeElement($_wsdlLocation = '',DOMNode $_domNode,$
{
self::auditInit('managewsdlnode_element',!empty($_wsdlLocation)?$_wsdlLocation:$_fromWsdlLocation);
/**
* Find parent node of this element node
* Nothing to do yet
*/
$parentNode = self::findSuitableParent($_domNode);
if($parentNode)
{
$attributes = $_domNode->attributes;
$attributesLength = $attributes->length;
for($i = 0;$i < $attributesLength;$i++)
{
$attribute = $attributes->item($i);
if($attribute && $attribute->nodeName != 'name' && $attribute->nodeName != 'type')
$this->addStructAttributeMeta($parentNode->getAttribute('name'),$_domNode->getAttribute('name'),$attribute->nodeName,$attribute->nodeValue);
}
}
self::audit('managewsdlnode_element',!empty($_wsdlLocation)?$_wsdlLocation:$_fromWsdlLocation);
}
/**
@@ -2437,13 +2432,15 @@ protected function manageWsdlNodeExtension($_wsdlLocation = '',DOMNode $_domNode
{
/**
* Avoid infinite loop on case like this when looping/managing inheritance :
* <code>
* <xs:complexType name="duration">
* -<xs:simpleContent>
* --<xs:extension base="xs:duration">
* ---<xs:attributeGroup ref="tns:commonAttributes"/>
* --</xs:extension>
* -</xs:simpleContent>
* </xs:complexType>
* </code>
*/
if($inheritsName !== $parentNode->getAttribute('name'))
$this->setStructInheritance($parentNode->getAttribute('name'),$inheritsName);
@@ -2631,22 +2628,45 @@ protected function manageWsdlNodeHeader($_wsdlLocation = '',DOMNode $_domNode,$_
*/
protected function manageWsdlNodeAttribute($_wsdlLocation = '',DOMNode $_domNode,$_fromWsdlLocation = '',$_nodeNameMatch = null)
{
if(($_domNode instanceof DOMElement) && $_domNode->hasAttribute('name') && $_domNode->getAttribute('name') && $_domNode->hasAttribute('type') && $_domNode->getAttribute('type'))
if($_nodeNameMatch === 'attribute')
{
if(($_domNode instanceof DOMElement) && $_domNode->hasAttribute('name') && $_domNode->getAttribute('name') && $_domNode->hasAttribute('type') && $_domNode->getAttribute('type'))
{
$parentNode = self::findSuitableParent($_domNode);
if($parentNode)
{
$attributeModel = $this->getStructAttribute($parentNode->getAttribute('name'),$_domNode->getAttribute('name'));
$type = explode(':',$_domNode->getAttribute('type'));
$typeModel = WsdlToPhpModel::getModelByName($type[count($type) - 1]);
if($attributeModel && (!$attributeModel->getType() || strtolower($attributeModel->getType()) == 'unknown') && $typeModel)
{
if($typeModel->getIsRestriction())
$attributeModel->setType($typeModel->getName());
elseif(!$typeModel->getIsStruct() && $typeModel->getInheritance())
$attributeModel->setType($typeModel->getInheritance());
}
}
}
}
else
{
self::auditInit('managewsdlnode_attribute',!empty($_wsdlLocation)?$_wsdlLocation:$_fromWsdlLocation);
/**
* Find parent node of this element node
*/
$parentNode = self::findSuitableParent($_domNode);
if($parentNode)
{
$attributeModel = $this->getStructAttribute($parentNode->getAttribute('name'),$_domNode->getAttribute('name'));
$type = explode(':',$_domNode->getAttribute('type'));
$typeModel = WsdlToPhpModel::getModelByName($type[count($type) - 1]);
if($attributeModel && (!$attributeModel->getType() || strtolower($attributeModel->getType()) == 'unknown') && $typeModel)
$attributes = $_domNode->attributes;
$attributesLength = $attributes->length;
for($i = 0;$i < $attributesLength;$i++)
{
if($typeModel->getIsRestriction())
$attributeModel->setType($typeModel->getName());
elseif(!$typeModel->getIsStruct() && $typeModel->getInheritance())
$attributeModel->setType($typeModel->getInheritance());
$attribute = $attributes->item($i);
if($attribute && $attribute->nodeName != 'name' && $attribute->nodeName != 'type')
$this->addStructAttributeMeta($parentNode->getAttribute('name'),$_domNode->getAttribute('name'),$attribute->nodeName,$attribute->nodeValue);
}
}
self::audit('managewsdlnode_attribute',!empty($_wsdlLocation)?$_wsdlLocation:$_fromWsdlLocation);
}
}
/**
@@ -232,7 +232,7 @@ protected function addMetaComment(array &$_comments = array(),$_addStars = false
{
foreach($this->getMeta() as $metaName=>$metaValue)
{
$cleanedMetaValue = self::cleanComment($metaValue);
$cleanedMetaValue = self::cleanComment($metaValue,$metaName == self::META_DOCUMENTATION?' ':',',stripos($metaName,'SOAPHeader') !== false);
if(($_ignoreDocumentation && $metaName == self::META_DOCUMENTATION) || $cleanedMetaValue === '')
continue;
array_push($metaComments,($_addStars?' * ':'') . "\t- $metaName : $cleanedMetaValue");
@@ -549,13 +549,14 @@ public static function getValueWithinItsType($_value)
* Clean comment
* @param string $_comment the comment to clean
* @param string $_glueSeparator ths string to use when gathering values
* @param bool $_uniqueValues indicates if comment values must be unique or not
* @return string
*/
public static function cleanComment($_comment,$_glueSeparator = ',')
public static function cleanComment($_comment,$_glueSeparator = ',',$_uniqueValues = true)
{
if(!is_scalar($_comment) && !is_array($_comment))
return '';
return trim(str_replace('*/','*[:slash:]',is_scalar($_comment)?$_comment:implode($_glueSeparator,array_unique($_comment))));
return trim(str_replace('*/','*[:slash:]',is_scalar($_comment)?$_comment:implode($_glueSeparator,$_uniqueValues?array_unique($_comment):$_comment)));
}
/**
* Returns the generic name of the WsdlClass
@@ -48,7 +48,7 @@ public function getDocSubPackages()
'Services');
}
/**
* Returns the commment lines for this function
* Returns the comment lines for this function
* @uses WsdlToPhpModel::getModelByName()
* @uses WsdlToPhpModel::getPackagedName()
* @uses WsdlToPhpService::getFunctions()
@@ -33,7 +33,7 @@ public function __construct($_name,$_type,WsdlToPhpStruct $_wsdlToPhpStruct)
$this->setOwner($_wsdlToPhpStruct);
}
/**
* Returns the commment lines for this attribute
* Returns the comment lines for this attribute
* @see WsdlToPhpModel::getComment()
* @uses WsdlToPhpModel::getName()
* @uses WsdlToPhpStruct::getIsStruct()
@@ -82,7 +82,6 @@ public function getUniqueName()
}
/**
* Returns the declaration of the attribute
* @see WsdlToPhpModel::getDeclaration()
* @uses WsdlToPhpModel::getCleanName()
* @return string
*/
@@ -42,9 +42,9 @@ public function __construct($_name,$_index,WsdlToPhpStruct $_wsdlToPhpStruct)
* @see WsdlToPhpModel::getCleanName()
* @uses WsdlToPhpModel::getCleanName()
* @uses WsdlToPhpModel::getName()
* @uses WsdlToPhpModel::getOwner()
* @uses WsdlToPhpStructValue::constantSuffix()
* @uses WsdlToPhpStructValue::getIndex()
* @uses WsdlToPhpStructValue::getOwner()
* @uses WsdlToPhpGenerator::getOptionGenericConstantsNames()
* @return string
*/
@@ -84,7 +84,7 @@ public function setIndex($_index)
return ($this->index = $_index);
}
/**
* Returns the commment lines for this value
* Returns the comment lines for this value
* @see WsdlToPhpModel::getComment()
* @uses WsdlToPhpStructValue::getValue()
* @uses WsdlToPhpModel::addMetaComment()

0 comments on commit d7f6fb6

Please sign in to comment.
You can’t perform that action at this time.