Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.0RC1
-
Fix Version/s: 1.7.0
-
Component/s: Zend_Soap_Wsdl
-
Labels:None
Description
In most applications, when returning an array of data this is restricted to one type.
Wouldn't it be a good practice to adopt java language syntax style "type[]" to declare
the return type "array of types" in the @return Doc Comment?
This usage is more important in the AutoDiscovery generation of WSDL
file than to declare the "correct" return value "array" for generating a PHPdoc API
document. I think it could be accepted for usage as syntax description of this types.
And although it has been rejected as PHP specific implementation in method headers
using it in @return is still a very good practice.
As I can take from the following php.net comment this is also practice in Zend Studio:
http://de2.php.net/manual/en/function.soap-soapserver-construct.php#84772
I've put together a quick hack (Zend_Soap_Wsdl.complexTypeArray.patch attached) that will probably need some cleanup work, but as far as I can tell it generates the desired result. It uses the "type[]" syntax, works with simple and complex types, and even arrays of arrays and so on (that is, you can have a return type of "string[][][]" however deep you desire).
Since the WSDL also allows for specifying minimum and maximum occurrances of elements, I went ahead and implemented that as well in the form of "type[<min>,<max>]". <min> and <max> can be any positive number, or "*". It's probably overkill, not to mention non-standard syntax in the PHP world, but it's also easy to remove from the patch. But if you wanted to declare that a function or method is going to return an array of one to five users, you can use "User[1,5]", and the complexType will be named "User1to5Array".