From 8ca6cc32b2c789a3149861159ad258f2cb9491e3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:39:39 +0200 Subject: Adding upstream version 2.11.4. Signed-off-by: Daniel Baumann --- library/vendor/Zend/Soap/Wsdl/Exception.php | 36 ++++ .../vendor/Zend/Soap/Wsdl/Strategy/Abstract.php | 65 ++++++++ library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php | 58 +++++++ .../Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php | 142 ++++++++++++++++ .../Soap/Wsdl/Strategy/ArrayOfTypeSequence.php | 154 +++++++++++++++++ .../vendor/Zend/Soap/Wsdl/Strategy/Composite.php | 183 +++++++++++++++++++++ .../Zend/Soap/Wsdl/Strategy/DefaultComplexType.php | 89 ++++++++++ .../vendor/Zend/Soap/Wsdl/Strategy/Interface.php | 48 ++++++ 8 files changed, 775 insertions(+) create mode 100644 library/vendor/Zend/Soap/Wsdl/Exception.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/Abstract.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php create mode 100644 library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php (limited to 'library/vendor/Zend/Soap/Wsdl') diff --git a/library/vendor/Zend/Soap/Wsdl/Exception.php b/library/vendor/Zend/Soap/Wsdl/Exception.php new file mode 100644 index 0000000..11397f0 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Exception.php @@ -0,0 +1,36 @@ +_context = $context; + } + + /** + * Return the current Zend_Soap_Wsdl context object + * + * @return Zend_Soap_Wsdl + */ + public function getContext() + { + return $this->_context; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php b/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php new file mode 100644 index 0000000..13f352e --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/AnyType.php @@ -0,0 +1,58 @@ +_inProcess)) { + return "tns:" . $type; + } + $this->_inProcess[$type] = $type; + + $nestingLevel = $this->_getNestedCount($type); + + if($nestingLevel > 1) { + throw new Zend_Soap_Wsdl_Exception( + "ArrayOfTypeComplex cannot return nested ArrayOfObject deeper than ". + "one level. Use array object properties to return deep nested data. + "); + } + + $singularType = $this->_getSingularPhpType($type); + + if(!class_exists($singularType)) { + throw new Zend_Soap_Wsdl_Exception(sprintf( + "Cannot add a complex type %s that is not an object or where ". + "class could not be found in 'DefaultComplexType' strategy.", $type + )); + } + + if($nestingLevel == 1) { + // The following blocks define the Array of Object structure + $xsdComplexTypeName = $this->_addArrayOfComplexType($singularType, $type); + } else { + $xsdComplexTypeName = $singularType; + } + + // The array for the objects has been created, now build the object definition: + if(!in_array($singularType, $this->getContext()->getTypes())) { + parent::addComplexType($singularType); + } + + unset($this->_inProcess[$type]); + return "tns:".$xsdComplexTypeName; + } + + protected function _addArrayOfComplexType($singularType, $type) + { + $dom = $this->getContext()->toDomDocument(); + + $xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType); + + if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) { + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $xsdComplexTypeName); + + $complexContent = $dom->createElement("xsd:complexContent"); + $complexType->appendChild($complexContent); + + $xsdRestriction = $dom->createElement("xsd:restriction"); + $xsdRestriction->setAttribute('base', 'soap-enc:Array'); + $complexContent->appendChild($xsdRestriction); + + $xsdAttribute = $dom->createElement("xsd:attribute"); + $xsdAttribute->setAttribute("ref", "soap-enc:arrayType"); + $xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType)); + $xsdRestriction->appendChild($xsdAttribute); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($xsdComplexTypeName); + } + + return $xsdComplexTypeName; + } + + protected function _getXsdComplexTypeName($type) + { + return sprintf('ArrayOf%s', $type); + } + + /** + * From a nested definition with type[], get the singular PHP Type + * + * @param string $type + * @return string + */ + protected function _getSingularPhpType($type) + { + return str_replace("[]", "", $type); + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php new file mode 100644 index 0000000..e82ea50 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/ArrayOfTypeSequence.php @@ -0,0 +1,154 @@ +_getNestedCount($type); + + if($nestedCounter > 0) { + $singularType = $this->_getSingularType($type); + + for($i = 1; $i <= $nestedCounter; $i++) { + $complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4); + $childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1); + + $this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName); + } + // adding the PHP type which is resolved to a nested XSD type. therefore add only once. + $this->getContext()->addType($complexTypeName); + + return "tns:$complexTypeName"; + } else if (!in_array($type, $this->getContext()->getTypes())) { + // New singular complex type + return parent::addComplexType($type); + } else { + // Existing complex type + return $this->getContext()->getType($type); + } + } + + /** + * Return the ArrayOf or simple type name based on the singular xsdtype and the nesting level + * + * @param string $singularType + * @param int $level + * @return string + */ + protected function _getTypeNameBasedOnNestingLevel($singularType, $level) + { + if($level == 0) { + // This is not an Array anymore, return the xsd simple type + return $singularType; + } else { + $prefix = str_repeat("ArrayOf", $level); + $xsdType = $this->_getStrippedXsdType($singularType); + $arrayType = $prefix.$xsdType; + return "tns:$arrayType"; + } + } + + /** + * Strip the xsd: from a singularType and Format it nice for ArrayOf naming + * + * @param string $singularType + * @return string + */ + protected function _getStrippedXsdType($singularType) + { + return ucfirst(substr(strtolower($singularType), 4)); + } + + /** + * From a nested defintion with type[], get the singular xsd:type + * + * @throws Zend_Soap_Wsdl_Exception When no xsd:simpletype can be detected. + * @param string $type + * @return string + */ + protected function _getSingularType($type) + { + $singulartype = $this->getContext()->getType(str_replace("[]", "", $type)); + return $singulartype; + } + + /** + * Return the array nesting level based on the type name + * + * @param string $type + * @return integer + */ + protected function _getNestedCount($type) + { + return substr_count($type, "[]"); + } + + /** + * Append the complex type definition to the WSDL via the context access + * + * @param string $arrayType + * @param string $childTypeName + * @return void + */ + protected function _addElementFromWsdlAndChildTypes($arrayType, $childTypeName) + { + if (!in_array($arrayType, $this->getContext()->getTypes())) { + $dom = $this->getContext()->toDomDocument(); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $arrayType); + + $sequence = $dom->createElement('xsd:sequence'); + + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', 'item'); + $element->setAttribute('type', $childTypeName); + $element->setAttribute('minOccurs', 0); + $element->setAttribute('maxOccurs', 'unbounded'); + $sequence->appendChild($element); + + $complexType->appendChild($sequence); + + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($arrayType); + } + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php b/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php new file mode 100644 index 0000000..a80120e --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/Composite.php @@ -0,0 +1,183 @@ + Strategy pairs. + * + * @var array + */ + protected $_typeMap = array(); + + /** + * Default Strategy of this composite + * + * @var string|Zend_Soap_Wsdl_Strategy_Interface + */ + protected $_defaultStrategy; + + /** + * Context WSDL file that this composite serves + * + * @var Zend_Soap_Wsdl|null + */ + protected $_context; + + /** + * Construct Composite WSDL Strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param array $typeMap + * @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy + */ + public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType") + { + foreach($typeMap AS $type => $strategy) { + $this->connectTypeToStrategy($type, $strategy); + } + $this->_defaultStrategy = $defaultStrategy; + } + + /** + * Connect a complex type to a given strategy. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy + * @return Zend_Soap_Wsdl_Strategy_Composite + */ + public function connectTypeToStrategy($type, $strategy) + { + if(!is_string($type)) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map."); + } + $this->_typeMap[$type] = $strategy; + return $this; + } + + /** + * Return default strategy of this composite + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getDefaultStrategy() + { + $strategy = $this->_defaultStrategy; + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy; + } + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Default Strategy for Complex Types is not a valid strategy object." + ); + } + $this->_defaultStrategy = $strategy; + return $strategy; + } + + /** + * Return specific strategy or the default strategy of this type. + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return Zend_Soap_Wsdl_Strategy_Interface + */ + public function getStrategyOfType($type) + { + if(isset($this->_typeMap[$type])) { + $strategy = $this->_typeMap[$type]; + + if(is_string($strategy) && class_exists($strategy)) { + $strategy = new $strategy(); + } + + if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Strategy for Complex Type '".$type."' is not a valid strategy object." + ); + } + $this->_typeMap[$type] = $strategy; + } else { + $strategy = $this->getDefaultStrategy(); + } + return $strategy; + } + + /** + * Method accepts the current WSDL context file. + * + * @param Zend_Soap_Wsdl $context + */ + public function setContext(Zend_Soap_Wsdl $context) + { + $this->_context = $context; + return $this; + } + + /** + * Create a complex type based on a strategy + * + * @throws Zend_Soap_Wsdl_Exception + * @param string $type + * @return string XSD type + */ + public function addComplexType($type) + { + if(!($this->_context instanceof Zend_Soap_Wsdl) ) { + /** + * @see Zend_Soap_Wsdl_Exception + */ + throw new Zend_Soap_Wsdl_Exception( + "Cannot add complex type '".$type."', no context is set for this composite strategy." + ); + } + + $strategy = $this->getStrategyOfType($type); + $strategy->setContext($this->_context); + return $strategy->addComplexType($type); + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php b/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php new file mode 100644 index 0000000..3baf804 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php @@ -0,0 +1,89 @@ +getContext()->toDomDocument(); + $class = new ReflectionClass($type); + + $defaultProperties = $class->getDefaultProperties(); + + $complexType = $dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $type); + + $all = $dom->createElement('xsd:all'); + + foreach ($class->getProperties() as $property) { + if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) { + + /** + * @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType' + * node for describing other classes used as attribute types for current class + */ + $element = $dom->createElement('xsd:element'); + $element->setAttribute('name', $propertyName = $property->getName()); + $element->setAttribute('type', $this->getContext()->getType(trim($matches[1][0]))); + + // If the default value is null, then this property is nillable. + if ($defaultProperties[$propertyName] === null) { + $element->setAttribute('nillable', 'true'); + } + + $all->appendChild($element); + } + } + + $complexType->appendChild($all); + $this->getContext()->getSchema()->appendChild($complexType); + $this->getContext()->addType($type); + + return "tns:$type"; + } +} diff --git a/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php b/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php new file mode 100644 index 0000000..9a57605 --- /dev/null +++ b/library/vendor/Zend/Soap/Wsdl/Strategy/Interface.php @@ -0,0 +1,48 @@ + $context + */ + public function setContext(Zend_Soap_Wsdl $context); + + /** + * Create a complex type based on a strategy + * + * @param string $type + * @return string XSD type + */ + public function addComplexType($type); +} -- cgit v1.2.3