Issue

ZF-10004: Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence hard coded attributes "name", "minOccurs" and "maxOccurs"

Issue Type: Improvement Created: 2010-06-17T06:19:53.000+0000 Last Updated: 2012-11-20T21:37:41.000+0000 Status: Open Fix version(s): Reporter: Timo Karvinen (timo.karvinen) Assignee: None Tags: - Zend_Soap_Wsdl

Related issues: Attachments:

Description

Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence has hard coded attributes for the element as follows:

<pre class="highlight">
$element->setAttribute('name',      'item');
$element->setAttribute('minOccurs', 0);
$element->setAttribute('maxOccurs', 'unbounded');

Which of course is very inflexible.

I have modified my ArrayOfTypeSequence so that it scans comments for a definitions like this:

<pre class="highlight">
* @var object[0,10] $objectArray

 or like

* @var string[0,5] $stringArray

for getting minOccurs and maxOccurs values.

I have added 2 instances variables to the class, with the current hard coded values provided as default values:

<pre class="highlight">
private $minOccurs = 0;
private $maxOccurs = "unbounded";

And in the beginning of public function addComplexType($type)

I scan for and set these values as follows:

<pre class="highlight">
if (preg_match_all ("/([a-z]+)(\[)([0-9]+),([0-9]+)(\])/is", $type, $matches))
{
    $this->minOccurs = $matches[3][0];
    $this->maxOccurs = $matches[4][0];
    // Remove minOccurs and maxOccurs definitions from $type so they don't mess other functions
    $type = $matches[1][0] . $matches[2][0] . $matches[5][0];
}

Then in protected function _addElementFromWsdlAndChildTypes I set them as:

<pre class="highlight">
$element->setAttribute('name',      substr($arrayType, 7));
$element->setAttribute('minOccurs', $this->minOccurs);
$element->setAttribute('maxOccurs', $this->maxOccurs);

Here I also set name to $arrayType without the "ArrayOf" prefix, which is much more compliant with some clients than the hard coded 'item'.

Also in protected function _getStrippedXsdType($singularType) the name is changed from original which messes up some things.

The function does this:

<pre class="highlight">
return ucfirst(substr(strtolower($singularType), 4));

Where the name is lower cased and then first char upper cased, I don't think this should be done, instead I have the line as follows:

<pre class="highlight">
return substr($singularType, 4);

Comments

No comments to display

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts