@@ -119,11 +119,11 @@ public function getVar($key, $default = null, $hash = 'input', $type = 'none', $
119119 switch ($ hash )
120120 {
121121 case 'server ' :
122- return $ this ->server ($ key , $ default );
122+ return $ this ->server ($ key , $ default, $ type );
123123 break ;
124124
125125 case 'cookie ' :
126- return $ this ->cookie ($ key , $ default );
126+ return $ this ->cookie ($ key , $ default, $ type );
127127 break ;
128128
129129 case 'files ' :
@@ -164,15 +164,15 @@ public function getVar($key, $default = null, $hash = 'input', $type = 'none', $
164164 break ;
165165
166166 case 'post ' :
167- return $ this ->request ($ key , $ default );
167+ return $ this ->request ($ key , $ default, $ type );
168168 break ;
169169
170170 case 'get ' :
171- return $ this ->query ($ key , $ default );
171+ return $ this ->query ($ key , $ default, $ type );
172172 break ;
173173
174174 default :
175- return $ this ->input ($ key , $ default );
175+ return $ this ->input ($ key , $ default, $ type );
176176 break ;
177177 }
178178 }
@@ -283,7 +283,7 @@ public function getCmd($key = null, $default = null, $hash = 'input')
283283 */
284284 public function getArray ($ key = null , $ default = array (), $ hash = 'input ' )
285285 {
286- return (array ) $ this ->getVar ($ key , $ default , $ hash );
286+ return (array ) $ this ->getVar ($ key , $ default , $ hash, ' array ' );
287287 }
288288
289289 /**
@@ -537,9 +537,9 @@ protected function getInputSource()
537537 * @param mixed $default
538538 * @return string
539539 */
540- public function request ($ key = null , $ default = null )
540+ public function request ($ key = null , $ default = null , $ type = null )
541541 {
542- return $ this ->retrieveItem ('request ' , $ key , $ default );
542+ return $ this ->retrieveItem ('request ' , $ key , $ default, $ type );
543543 }
544544
545545 /**
@@ -549,9 +549,9 @@ public function request($key = null, $default = null)
549549 * @param mixed $default
550550 * @return string
551551 */
552- public function query ($ key = null , $ default = null )
552+ public function query ($ key = null , $ default = null , $ type = null )
553553 {
554- return $ this ->retrieveItem ('query ' , $ key , $ default );
554+ return $ this ->retrieveItem ('query ' , $ key , $ default, $ type );
555555 }
556556
557557 /**
@@ -561,9 +561,9 @@ public function query($key = null, $default = null)
561561 * @param mixed $default
562562 * @return string
563563 */
564- public function cookie ($ key = null , $ default = null )
564+ public function cookie ($ key = null , $ default = null , $ type = null )
565565 {
566- return $ this ->retrieveItem ('cookies ' , $ key , $ default );
566+ return $ this ->retrieveItem ('cookies ' , $ key , $ default, $ type );
567567 }
568568
569569 /**
@@ -597,9 +597,9 @@ public function file($key = null, $default = null)
597597 * @param mixed $default
598598 * @return string
599599 */
600- public function header ($ key = null , $ default = null )
600+ public function header ($ key = null , $ default = null , $ type = null )
601601 {
602- return $ this ->retrieveItem ('headers ' , $ key , $ default );
602+ return $ this ->retrieveItem ('headers ' , $ key , $ default, $ type );
603603 }
604604
605605 /**
@@ -609,9 +609,9 @@ public function header($key = null, $default = null)
609609 * @param mixed $default
610610 * @return string
611611 */
612- public function server ($ key = null , $ default = null )
612+ public function server ($ key = null , $ default = null , $ type = null )
613613 {
614- return $ this ->retrieveItem ('server ' , $ key , $ default );
614+ return $ this ->retrieveItem ('server ' , $ key , $ default, $ type );
615615 }
616616
617617 /**
@@ -622,14 +622,28 @@ public function server($key = null, $default = null)
622622 * @param mixed $default
623623 * @return string
624624 */
625- protected function retrieveItem ($ source , $ key , $ default )
625+ protected function retrieveItem ($ source , $ key , $ default, $ type = null )
626626 {
627627 if (is_null ($ key ))
628628 {
629629 return $ this ->$ source ->all ();
630630 }
631631
632- return $ this ->$ source ->get ($ key , $ default , true );
632+ if ($ type == 'array ' )
633+ {
634+ try
635+ {
636+ return $ this ->$ source ->all ($ key , $ default , true );
637+ }
638+ catch (\Symfony \Component \HttpFoundation \Exception \BadRequestException $ e )
639+ {
640+ return $ default ;
641+ }
642+ }
643+ else
644+ {
645+ return $ this ->$ source ->get ($ key , $ default , true );
646+ }
633647 }
634648
635649 /**
0 commit comments