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

[UPDATE] enhancements

[UPDATE] enhancements
Ensure that generated classes (structs, services, enumerations) are
named uniquely by updating WsdlToPhpModel::getPackagedName() method
using WsdlToPhpModel::uniqueName()
Clean WsdlToPhpStructAttributeValue::getCleanName() call in
WsdltophpStruct::getClassBody()
Remove useless comments and add test case
  • Loading branch information...
mikaelcom committed Jan 29, 2013
1 parent ea076fc commit 32fba77bf508ed334d8c2527e74110b8652a1d80
Showing with 22 additions and 13 deletions.
  1. +13 −5 WsdlToPhpGenerator.php
  2. +8 −7 WsdlToPhpModel.php
  3. +1 −1 WsdlToPhpStruct.php
@@ -81,6 +81,7 @@
* <li>{@link https://raw.github.com/jkinred/psphere/master/psphere/wsdl/vimService.wsdl}</li>
* <li>{@link http://staging.timatic.aero/timaticwebservices/timatic3.WSDL}</li>
* <li>{@link http://www.reservationfactory.com/wsdls/air_v21_0/Air.wsdl}</li>
* <li>{@link http://voipnow2demo.4psa.com//soap2/schema/3.0.0/voipnowservice.wsdl}</li>
* </ul>
* </li>
* <li>Multiple service operations returns the same response type (getResult() doc comment must return one type of each) :
@@ -98,7 +99,7 @@
* <li>PHP reserved keyword in operation name (ex : list, add), replaced by _{keyword} :
* <ul>
* <li>{@link https://api5.successfactors.eu/sfapi/v1/soap12?wsdl}</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl]</li>
* <li>{@link https://webservices.netsuite.com/wsdl/v2012_2_0/netsuite.wsdl}</li>
* </ul>
* </li>
* <li>Send ArrayAsParameter and ParametersAsArray case :
@@ -251,6 +252,11 @@
* <li>{@link http://www.martonhouse.net/Invensys/InvensysAPI.asmx?WSDL}</li>
* </ul>
* </li>
* <li>Similar struct name:
* <ul>
* <li>{@link http://voipnow2demo.4psa.com//soap2/schema/3.0.0/voipnowservice.wsdl} timeInterval/TimeInterval, recharge/Recharge</li>
* </ul>
* </li>
* <li>Biggest Packages generated :
* <ul>
* <li>{@link https://raw.github.com/jkinred/psphere/master/psphere/wsdl/vimService.wsdl}</li>
@@ -1864,9 +1870,11 @@ protected function wsdlsLoaded()
{
if(count($this->getWsdls()))
{
$wsdlLocation = implode('',array_slice(array_keys($this->getWsdls()),0,1));
if(is_string($wsdlLocation) && !empty($wsdlLocation))
$this->manageWsdlLocation($wsdlLocation,null,'','header');
foreach($this->getWsdls() as $wsdlLocation=>$wsdlData)
{
if(is_string($wsdlLocation) && !empty($wsdlLocation))
$this->manageWsdlLocation($wsdlLocation,null,'','header');
}
}
}
/**
@@ -2523,7 +2531,7 @@ protected function manageWsdlNodeHeader($_wsdlLocation = '',DOMNode $_domNode,$_
$wsdlLocationContent = preg_replace('(<!--.*-->)','',$wsdlLocationContent);
}
if(!empty($wsdlLocationContent))
$dom->loadXML($wsdlLocationContent);
@$dom->loadXML($wsdlLocationContent);
else
$dom = null;
self::setGlobal($globalKey,$dom);
@@ -90,7 +90,7 @@ public function getComment($_part = '')
{
case 1:
array_push($comments,'File for class ' . $this->getPackagedName());
array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName()); // . (count($this->getDocSubPackages())?'\\':'') . implode('\\',$this->getDocSubPackages()));
array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
if(count($this->getDocSubPackages()))
array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
array_push($comments,'@date ' . date('Y-m-d'));
@@ -100,7 +100,7 @@ public function getComment($_part = '')
if($this->getDocumentation() != '')
array_push($comments,'Documentation : ' . $this->getDocumentation());
$this->addMetaComment($comments,false,true);
array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName()); // . (count($this->getDocSubPackages())?'\\':'') . implode('\\',$this->getDocSubPackages()));
array_push($comments,'@package ' . WsdlToPhpGenerator::getPackageName());
if(count($this->getDocSubPackages()))
array_push($comments,'@subpackage ' . implode(',',$this->getDocSubPackages()));
array_push($comments,'@date ' . date('Y-m-d'));
@@ -384,11 +384,12 @@ public function nameIsClean()
* @uses WsdlToPhpGenerator::getPackageName()
* @uses WsdlToPhpModel::getCleanName()
* @uses WsdlToPhpModel::getContextualPart()
* @uses WsdlToPhpModel::uniqueName() to ensure unique naming of struct case sensitively
* @return string
*/
public function getPackagedName()
{
return WsdlToPhpGenerator::getPackageName() . $this->getContextualPart() . ucfirst($this->getCleanName());
return WsdlToPhpGenerator::getPackageName() . $this->getContextualPart() . ucfirst(self::uniqueName($this->getCleanName(),$this->getContextualPart()));
}
/**
* Allows to define the contextual part of the class name for the package
@@ -492,13 +493,13 @@ public static function replaceReservedPhpKeyword($_keyword,$_context)
* Static method wich returns a unique name case sensitively
* Useful to name methods case sensitively distinct, see http://the-echoplex.net/log/php-case-sensitivity
* @param string $_name the original name
* @param string $_ownerName the name of owner
* @param string $_context the context where the name is needed unique
* @return string
*/
protected static function uniqueName($_name,$_ownerName)
protected static function uniqueName($_name,$_context)
{
$insensitiveKey = strtolower($_name . '_' . $_ownerName);
$sensitiveKey = $_name . '_' . $_ownerName;
$insensitiveKey = strtolower($_name . '_' . $_context);
$sensitiveKey = $_name . '_' . $_context;
if(array_key_exists($sensitiveKey,self::$uniqueNames))
return self::$uniqueNames[$sensitiveKey];
elseif(!array_key_exists($insensitiveKey,self::$uniqueNames))
@@ -86,7 +86,7 @@ public function getClassBody(&$_body)
array_push($_body,array(
'comment'=>$value->getComment()));
array_push($_body,$value->getDeclaration($this->getName(),$index));
array_push($constantsDefined,$this->getPackagedName() . '::' . $value->getCleanName($this->getName(),$index));
array_push($constantsDefined,$this->getPackagedName() . '::' . $value->getCleanName());
}
/**
* valueIsValid() method comments

0 comments on commit 32fba77

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