@@ -52,35 +52,35 @@ class Route extends Nette\Object implements Application\IRouter
5252 public static $ defaultFlags = 0 ;
5353
5454 /** @var array */
55- public static $ styles = array (
56- '# ' => array ( // default style for path parameters
55+ public static $ styles = [
56+ '# ' => [ // default style for path parameters
5757 self ::PATTERN => '[^/]+ ' ,
58- self ::FILTER_OUT => array ( __CLASS__ , 'param2path ' ) ,
59- ) ,
60- '?# ' => array ( // default style for query parameters
61- ) ,
62- 'module ' => array (
58+ self ::FILTER_OUT => [ __CLASS__ , 'param2path ' ] ,
59+ ] ,
60+ '?# ' => [ // default style for query parameters
61+ ] ,
62+ 'module ' => [
6363 self ::PATTERN => '[a-z][a-z0-9.-]* ' ,
64- self ::FILTER_IN => array ( __CLASS__ , 'path2presenter ' ) ,
65- self ::FILTER_OUT => array ( __CLASS__ , 'presenter2path ' ) ,
66- ) ,
67- 'presenter ' => array (
64+ self ::FILTER_IN => [ __CLASS__ , 'path2presenter ' ] ,
65+ self ::FILTER_OUT => [ __CLASS__ , 'presenter2path ' ] ,
66+ ] ,
67+ 'presenter ' => [
6868 self ::PATTERN => '[a-z][a-z0-9.-]* ' ,
69- self ::FILTER_IN => array ( __CLASS__ , 'path2presenter ' ) ,
70- self ::FILTER_OUT => array ( __CLASS__ , 'presenter2path ' ) ,
71- ) ,
72- 'action ' => array (
69+ self ::FILTER_IN => [ __CLASS__ , 'path2presenter ' ] ,
70+ self ::FILTER_OUT => [ __CLASS__ , 'presenter2path ' ] ,
71+ ] ,
72+ 'action ' => [
7373 self ::PATTERN => '[a-z][a-z0-9-]* ' ,
74- self ::FILTER_IN => array ( __CLASS__ , 'path2action ' ) ,
75- self ::FILTER_OUT => array ( __CLASS__ , 'action2path ' ) ,
76- ) ,
77- '?module ' => array (
78- ) ,
79- '?presenter ' => array (
80- ) ,
81- '?action ' => array (
82- ) ,
83- ) ;
74+ self ::FILTER_IN => [ __CLASS__ , 'path2action ' ] ,
75+ self ::FILTER_OUT => [ __CLASS__ , 'action2path ' ] ,
76+ ] ,
77+ '?module ' => [
78+ ] ,
79+ '?presenter ' => [
80+ ] ,
81+ '?action ' => [
82+ ] ,
83+ ] ;
8484
8585 /** @var string */
8686 private $ mask ;
@@ -95,7 +95,7 @@ class Route extends Nette\Object implements Application\IRouter
9595 private $ aliases ;
9696
9797 /** @var array of [value & fixity, filterIn, filterOut] */
98- private $ metadata = array () ;
98+ private $ metadata = [] ;
9999
100100 /** @var array */
101101 private $ xlat ;
@@ -118,22 +118,22 @@ class Route extends Nette\Object implements Application\IRouter
118118 * @param array|string default values or metadata
119119 * @param int flags
120120 */
121- public function __construct ($ mask , $ metadata = array () , $ flags = 0 )
121+ public function __construct ($ mask , $ metadata = [] , $ flags = 0 )
122122 {
123123 if (is_string ($ metadata )) {
124124 $ a = strrpos ($ metadata , ': ' );
125125 if (!$ a ) {
126126 throw new Nette \InvalidArgumentException ("Second argument must be array or string in format Presenter:action, ' $ metadata' given. " );
127127 }
128- $ metadata = array (
128+ $ metadata = [
129129 self ::PRESENTER_KEY => substr ($ metadata , 0 , $ a ),
130130 'action ' => $ a === strlen ($ metadata ) - 1 ? NULL : substr ($ metadata , $ a + 1 ),
131- ) ;
131+ ] ;
132132 } elseif ($ metadata instanceof \Closure || $ metadata instanceof Nette \Callback) {
133- $ metadata = array (
133+ $ metadata = [
134134 self ::PRESENTER_KEY => 'Nette:Micro ' ,
135135 'callback ' => $ metadata ,
136- ) ;
136+ ] ;
137137 }
138138
139139 $ this ->flags = $ flags | static ::$ defaultFlags ;
@@ -156,12 +156,12 @@ public function match(Nette\Http\IRequest $httpRequest)
156156 if ($ this ->type === self ::HOST ) {
157157 $ host = $ url ->getHost ();
158158 $ path = '// ' . $ host . $ url ->getPath ();
159- $ host = ip2long ($ host ) ? array ( $ host) : array_reverse (explode ('. ' , $ host ));
160- $ re = strtr ($ re , array (
159+ $ host = ip2long ($ host ) ? [ $ host] : array_reverse (explode ('. ' , $ host ));
160+ $ re = strtr ($ re , [
161161 '/%basePath%/ ' => preg_quote ($ url ->getBasePath (), '# ' ),
162162 '%tld% ' => preg_quote ($ host [0 ], '# ' ),
163163 '%domain% ' => preg_quote (isset ($ host [1 ]) ? "$ host [1 ]. $ host [0 ]" : $ host [0 ], '# ' ),
164- ) );
164+ ] );
165165
166166 } elseif ($ this ->type === self ::RELATIVE ) {
167167 $ basePath = $ url ->getBasePath ();
@@ -184,7 +184,7 @@ public function match(Nette\Http\IRequest $httpRequest)
184184 }
185185
186186 // assigns matched values to parameters
187- $ params = array () ;
187+ $ params = [] ;
188188 foreach ($ matches as $ k => $ v ) {
189189 if (is_string ($ k ) && $ v !== '' ) {
190190 $ params [$ this ->aliases [$ k ]] = $ v ;
@@ -262,7 +262,7 @@ public function match(Nette\Http\IRequest $httpRequest)
262262 $ params ,
263263 $ httpRequest ->getPost (),
264264 $ httpRequest ->getFiles (),
265- array ( Application \Request::SECURED => $ httpRequest ->isSecured ())
265+ [ Application \Request::SECURED => $ httpRequest ->isSecured ()]
266266 );
267267 }
268268
@@ -343,7 +343,7 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
343343
344344 // compositing path
345345 $ sequence = $ this ->sequence ;
346- $ brackets = array () ;
346+ $ brackets = [] ;
347347 $ required = NULL ; // NULL for auto-optional
348348 $ url = '' ;
349349 $ i = count ($ sequence ) - 1 ;
@@ -401,12 +401,12 @@ public function constructUrl(Application\Request $appRequest, Nette\Http\Url $re
401401
402402 } else {
403403 $ host = $ refUrl ->getHost ();
404- $ host = ip2long ($ host ) ? array ( $ host) : array_reverse (explode ('. ' , $ host ));
405- $ url = strtr ($ url , array (
404+ $ host = ip2long ($ host ) ? [ $ host] : array_reverse (explode ('. ' , $ host ));
405+ $ url = strtr ($ url , [
406406 '/%basePath%/ ' => $ refUrl ->getBasePath (),
407407 '%tld% ' => $ host [0 ],
408408 '%domain% ' => isset ($ host [1 ]) ? "$ host [1 ]. $ host [0 ]" : $ host [0 ],
409- ) );
409+ ] );
410410 $ url = ($ this ->flags & self ::SECURED ? 'https: ' : 'http: ' ) . $ url ;
411411 }
412412
@@ -452,7 +452,7 @@ private function setMask($mask, array $metadata)
452452
453453 foreach ($ metadata as $ name => $ meta ) {
454454 if (!is_array ($ meta )) {
455- $ metadata [$ name ] = $ meta = array ( self ::VALUE => $ meta) ;
455+ $ metadata [$ name ] = $ meta = [ self ::VALUE => $ meta] ;
456456 }
457457
458458 if (array_key_exists (self ::VALUE , $ meta )) {
@@ -465,7 +465,7 @@ private function setMask($mask, array $metadata)
465465
466466 if (strpbrk ($ mask , '?<[ ' ) === FALSE ) {
467467 $ this ->re = '# ' . preg_quote ($ mask , '# ' ) . '/?\z#A ' ;
468- $ this ->sequence = array ( $ mask) ;
468+ $ this ->sequence = [ $ mask] ;
469469 $ this ->metadata = $ metadata ;
470470 return ;
471471 }
@@ -474,7 +474,7 @@ private function setMask($mask, array $metadata)
474474 // <parameter-name[=default] [pattern] [#class]> or [ or ] or ?...
475475 $ parts = Strings::split ($ mask , '/<([^>#= ]+)(=[^># ]*)? *([^>#]*)(#?[^>\[\]]*)>|(\[!?|\]|\s*\?.*)/ ' );
476476
477- $ this ->xlat = array () ;
477+ $ this ->xlat = [] ;
478478 $ i = count ($ parts ) - 1 ;
479479
480480 // PARSE QUERY PART OF MASK
@@ -520,9 +520,9 @@ private function setMask($mask, array $metadata)
520520 // PARSE PATH PART OF MASK
521521 $ brackets = 0 ; // optional level
522522 $ re = '' ;
523- $ sequence = array () ;
523+ $ sequence = [] ;
524524 $ autoOptional = TRUE ;
525- $ aliases = array () ;
525+ $ aliases = [] ;
526526 do {
527527 array_unshift ($ sequence , $ parts [$ i ]);
528528 $ re = preg_quote ($ parts [$ i ], '# ' ) . $ re ;
@@ -647,7 +647,7 @@ public function getMask()
647647 */
648648 public function getDefaults ()
649649 {
650- $ defaults = array () ;
650+ $ defaults = [] ;
651651 foreach ($ this ->metadata as $ name => $ meta ) {
652652 if (isset ($ meta ['fixity ' ])) {
653653 $ defaults [$ name ] = $ meta [self ::VALUE ];
@@ -678,7 +678,7 @@ public function getFlags()
678678 public function getTargetPresenters ()
679679 {
680680 if ($ this ->flags & self ::ONE_WAY ) {
681- return array () ;
681+ return [] ;
682682 }
683683
684684 $ m = $ this ->metadata ;
@@ -693,7 +693,7 @@ public function getTargetPresenters()
693693 }
694694
695695 if (isset ($ m [self ::PRESENTER_KEY ]['fixity ' ]) && $ m [self ::PRESENTER_KEY ]['fixity ' ] === self ::CONSTANT ) {
696- return array ( $ module . $ m [self ::PRESENTER_KEY ][self ::VALUE ]) ;
696+ return [ $ module . $ m [self ::PRESENTER_KEY ][self ::VALUE ]] ;
697697 }
698698 return NULL ;
699699 }
@@ -711,7 +711,7 @@ private static function renameKeys($arr, $xlat)
711711 return $ arr ;
712712 }
713713
714- $ res = array () ;
714+ $ res = [] ;
715715 $ occupied = array_flip ($ xlat );
716716 foreach ($ arr as $ k => $ v ) {
717717 if (isset ($ xlat [$ k ])) {
@@ -817,7 +817,7 @@ public static function addStyle($style, $parent = '#')
817817 static ::$ styles [$ style ] = static ::$ styles [$ parent ];
818818
819819 } else {
820- static ::$ styles [$ style ] = array () ;
820+ static ::$ styles [$ style ] = [] ;
821821 }
822822 }
823823
0 commit comments