@@ -18,20 +18,22 @@ class ValueGenerator extends AbstractGenerator
1818 /**#@+
1919 * Constant values
2020 */
21- const TYPE_AUTO = 'auto ' ;
22- const TYPE_BOOLEAN = 'boolean ' ;
23- const TYPE_BOOL = 'bool ' ;
24- const TYPE_NUMBER = 'number ' ;
25- const TYPE_INTEGER = 'integer ' ;
26- const TYPE_INT = 'int ' ;
27- const TYPE_FLOAT = 'float ' ;
28- const TYPE_DOUBLE = 'double ' ;
29- const TYPE_STRING = 'string ' ;
30- const TYPE_ARRAY = 'array ' ;
31- const TYPE_CONSTANT = 'constant ' ;
32- const TYPE_NULL = 'null ' ;
33- const TYPE_OBJECT = 'object ' ;
34- const TYPE_OTHER = 'other ' ;
21+ const TYPE_AUTO = 'auto ' ;
22+ const TYPE_BOOLEAN = 'boolean ' ;
23+ const TYPE_BOOL = 'bool ' ;
24+ const TYPE_NUMBER = 'number ' ;
25+ const TYPE_INTEGER = 'integer ' ;
26+ const TYPE_INT = 'int ' ;
27+ const TYPE_FLOAT = 'float ' ;
28+ const TYPE_DOUBLE = 'double ' ;
29+ const TYPE_STRING = 'string ' ;
30+ const TYPE_ARRAY = 'array ' ;
31+ const TYPE_ARRAY_SHORT = 'array_short ' ;
32+ const TYPE_ARRAY_LONG = 'array_long ' ;
33+ const TYPE_CONSTANT = 'constant ' ;
34+ const TYPE_NULL = 'null ' ;
35+ const TYPE_OBJECT = 'object ' ;
36+ const TYPE_OTHER = 'other ' ;
3537 /**#@-*/
3638
3739 const OUTPUT_MULTIPLE_LINE = 'multipleLine ' ;
@@ -254,6 +256,8 @@ protected function getValidatedType($type)
254256 self ::TYPE_DOUBLE ,
255257 self ::TYPE_STRING ,
256258 self ::TYPE_ARRAY ,
259+ self ::TYPE_ARRAY_SHORT ,
260+ self ::TYPE_ARRAY_LONG ,
257261 self ::TYPE_CONSTANT ,
258262 self ::TYPE_NULL ,
259263 self ::TYPE_OBJECT ,
@@ -317,12 +321,21 @@ public function generate()
317321 $ type = $ this ->getAutoDeterminedType ($ value );
318322 }
319323
320- if ($ type == self ::TYPE_ARRAY ) {
324+ $ isArrayType = in_array ($ type , [self ::TYPE_ARRAY , self ::TYPE_ARRAY_LONG , self ::TYPE_ARRAY_SHORT ]);
325+
326+ if ($ isArrayType ) {
321327 foreach ($ value as &$ curValue ) {
322328 if ($ curValue instanceof self) {
323329 continue ;
324330 }
325- $ curValue = new self ($ curValue , self ::TYPE_AUTO , self ::OUTPUT_MULTIPLE_LINE , $ this ->getConstants ());
331+
332+ if (is_array ($ curValue )) {
333+ $ newType = $ type ;
334+ } else {
335+ $ newType = self ::TYPE_AUTO ;
336+ }
337+
338+ $ curValue = new self ($ curValue , $ newType , self ::OUTPUT_MULTIPLE_LINE , $ this ->getConstants ());
326339 }
327340 }
328341
@@ -348,7 +361,17 @@ public function generate()
348361 $ output .= $ value ;
349362 break ;
350363 case self ::TYPE_ARRAY :
351- $ output .= 'array( ' ;
364+ case self ::TYPE_ARRAY_LONG :
365+ case self ::TYPE_ARRAY_SHORT :
366+ if ($ type == self ::TYPE_ARRAY_SHORT ) {
367+ $ startArray = '[ ' ;
368+ $ endArray = '] ' ;
369+ } else {
370+ $ startArray = 'array( ' ;
371+ $ endArray = ') ' ;
372+ }
373+
374+ $ output .= $ startArray ;
352375 if ($ this ->outputMode == self ::OUTPUT_MULTIPLE_LINE ) {
353376 $ output .= self ::LINE_FEED . str_repeat ($ this ->indentation , $ this ->arrayDepth + 1 );
354377 }
@@ -384,7 +407,7 @@ public function generate()
384407 }
385408 $ output .= self ::LINE_FEED . str_repeat ($ this ->indentation , $ this ->arrayDepth );
386409 }
387- $ output .= ' ) ' ;
410+ $ output .= $ endArray ;
388411 break ;
389412 case self ::TYPE_OTHER :
390413 default :
0 commit comments