dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
resources: Remove deprecated 'jquery.placeholder' module
[lhc/web/wiklou.git]
/
includes
/
PathRouter.php
diff --git
a/includes/PathRouter.php
b/includes/PathRouter.php
index
e5979b8
..
cc6fc4a
100644
(file)
--- a/
includes/PathRouter.php
+++ b/
includes/PathRouter.php
@@
-27,20
+27,20
@@
*
* $router->add( "/wiki/$1" );
* - Matches /wiki/Foo style urls and extracts the title
*
* $router->add( "/wiki/$1" );
* - Matches /wiki/Foo style urls and extracts the title
- * $router->add(
array( 'edit' => "/edit/$key" ), array( 'action' => '$key' )
);
+ * $router->add(
[ 'edit' => "/edit/$key" ], [ 'action' => '$key' ]
);
* - Matches /edit/Foo style urls and sets action=edit
* $router->add( '/$2/$1',
* - Matches /edit/Foo style urls and sets action=edit
* $router->add( '/$2/$1',
- *
array( 'variant' => '$2' )
,
- *
array( '$2' => array( 'zh-hant', 'zh-hans' )
+ *
[ 'variant' => '$2' ]
,
+ *
[ '$2' => [ 'zh-hant', 'zh-hans' ] ]
* );
* - Matches /zh-hant/Foo or /zh-hans/Foo
* );
* - Matches /zh-hant/Foo or /zh-hans/Foo
- * $router->addStrict( "/foo/Bar",
array( 'title' => 'Baz' )
);
+ * $router->addStrict( "/foo/Bar",
[ 'title' => 'Baz' ]
);
* - Matches /foo/Bar explicitly and uses "Baz" as the title
* - Matches /foo/Bar explicitly and uses "Baz" as the title
- * $router->add( '/help/$1',
array( 'title' => 'Help:$1' )
);
+ * $router->add( '/help/$1',
[ 'title' => 'Help:$1' ]
);
* - Matches /help/Foo with "Help:Foo" as the title
* - Matches /help/Foo with "Help:Foo" as the title
- * $router->add( '/$1',
array( 'foo' => array( 'value' => 'bar$2' )
);
+ * $router->add( '/$1',
[ 'foo' => [ 'value' => 'bar$2' ] ]
);
* - Matches /Foo and sets 'foo' to 'bar$2' without $2 being replaced
* - Matches /Foo and sets 'foo' to 'bar$2' without $2 being replaced
- * $router->add( '/$1',
array( 'data:foo' => 'bar' ), array( 'callback' => 'functionname' )
);
+ * $router->add( '/$1',
[ 'data:foo' => 'bar' ], [ 'callback' => 'functionname' ]
);
* - Matches /Foo, adds the key 'foo' with the value 'bar' to the data array
* and calls functionname( &$matches, $data );
*
* - Matches /Foo, adds the key 'foo' with the value 'bar' to the data array
* and calls functionname( &$matches, $data );
*
@@
-56,7
+56,7
@@
* - The default behavior is equivalent to `array( 'title' => '$1' )`,
* if you don't want the title parameter you can explicitly use `array( 'title' => false )`
* - You can specify a value that won't have replacements in it
* - The default behavior is equivalent to `array( 'title' => '$1' )`,
* if you don't want the title parameter you can explicitly use `array( 'title' => false )`
* - You can specify a value that won't have replacements in it
- * using `'foo' =>
array( 'value' => 'bar' )
;`
+ * using `'foo' =>
[ 'value' => 'bar' ]
;`
*
* Options:
* - The option keys $1, $2, etc... can be specified to restrict the possible values
*
* Options:
* - The option keys $1, $2, etc... can be specified to restrict the possible values
@@
-75,7
+75,7
@@
class PathRouter {
/**
* @var array
*/
/**
* @var array
*/
- private $patterns =
array()
;
+ private $patterns =
[]
;
/**
* Protected helper to do the actual bulk work of adding a single pattern.
/**
* Protected helper to do the actual bulk work of adding a single pattern.
@@
-124,9
+124,9
@@
class PathRouter {
// of a pattern for a little more efficiency
$paramArrKey = 'value';
}
// of a pattern for a little more efficiency
$paramArrKey = 'value';
}
- $params[$paramName] =
array(
+ $params[$paramName] =
[
$paramArrKey => $paramData
$paramArrKey => $paramData
-
)
;
+
]
;
}
}
}
}
@@
-135,17
+135,17
@@
class PathRouter {
foreach ( $options as $optionName => $optionData ) {
if ( preg_match( '/^\$\d+$/u', $optionName ) ) {
if ( !is_array( $optionData ) ) {
foreach ( $options as $optionName => $optionData ) {
if ( preg_match( '/^\$\d+$/u', $optionName ) ) {
if ( !is_array( $optionData ) ) {
- $options[$optionName] =
array( $optionData )
;
+ $options[$optionName] =
[ $optionData ]
;
}
}
}
}
}
}
- $pattern = (object)
array(
+ $pattern = (object)
[
'path' => $path,
'params' => $params,
'options' => $options,
'key' => $key,
'path' => $path,
'params' => $params,
'options' => $options,
'key' => $key,
-
)
;
+
]
;
$pattern->weight = self::makeWeight( $pattern );
$this->patterns[] = $pattern;
}
$pattern->weight = self::makeWeight( $pattern );
$this->patterns[] = $pattern;
}
@@
-157,7
+157,7
@@
class PathRouter {
* @param array $params The params for this path pattern
* @param array $options The options for this path pattern
*/
* @param array $params The params for this path pattern
* @param array $options The options for this path pattern
*/
- public function add( $path, $params =
array(), $options = array()
) {
+ public function add( $path, $params =
[], $options = []
) {
if ( is_array( $path ) ) {
foreach ( $path as $key => $onePath ) {
$this->doAdd( $onePath, $params, $options, $key );
if ( is_array( $path ) ) {
foreach ( $path as $key => $onePath ) {
$this->doAdd( $onePath, $params, $options, $key );
@@
-174,7
+174,7
@@
class PathRouter {
* @param array $params
* @param array $options
*/
* @param array $params
* @param array $options
*/
- public function addStrict( $path, $params =
array(), $options = array()
) {
+ public function addStrict( $path, $params =
[], $options = []
) {
$options['strict'] = true;
$this->add( $path, $params, $options );
}
$options['strict'] = true;
$this->add( $path, $params, $options );
}
@@
-184,7
+184,7
@@
class PathRouter {
* (most heavily weighted) patterns are at the start of the array.
*/
protected function sortByWeight() {
* (most heavily weighted) patterns are at the start of the array.
*/
protected function sortByWeight() {
- $weights =
array()
;
+ $weights =
[]
;
foreach ( $this->patterns as $key => $pattern ) {
$weights[$key] = $pattern->weight;
}
foreach ( $this->patterns as $key => $pattern ) {
$weights[$key] = $pattern->weight;
}
@@
-253,7
+253,7
@@
class PathRouter {
// array() (a match with no data) but our WebRequest caller
// expects array() even when we have no matches so return
// a array() when we have null
// array() (a match with no data) but our WebRequest caller
// expects array() even when we have no matches so return
// a array() when we have null
- return is_null( $matches ) ?
array()
: $matches;
+ return is_null( $matches ) ?
[]
: $matches;
}
/**
}
/**
@@
-270,8
+270,8
@@
class PathRouter {
$regexp = preg_replace( '#\\\\\$(\d+)#u', '(?P<par$1>.+?)', $regexp );
$regexp = "#^{$regexp}$#";
$regexp = preg_replace( '#\\\\\$(\d+)#u', '(?P<par$1>.+?)', $regexp );
$regexp = "#^{$regexp}$#";
- $matches =
array()
;
- $data =
array()
;
+ $matches =
[]
;
+ $data =
[]
;
// Try to match the path we were asked to parse with our regexp
if ( preg_match( $regexp, $path, $m ) ) {
// Try to match the path we were asked to parse with our regexp
if ( preg_match( $regexp, $path, $m ) ) {
@@
-342,7
+342,7
@@
class PathRouter {
// If this match includes a callback, execute it
if ( isset( $pattern->options['callback'] ) ) {
// If this match includes a callback, execute it
if ( isset( $pattern->options['callback'] ) ) {
- call_user_func_array( $pattern->options['callback'],
array( &$matches, $data )
);
+ call_user_func_array( $pattern->options['callback'],
[ &$matches, $data ]
);
}
} else {
// Our regexp didn't match, return null to signify no match.
}
} else {
// Our regexp didn't match, return null to signify no match.
@@
-364,11
+364,11
@@
class PathRouterPatternReplacer {
* difference between a $1 that was not replaced and a $1 that was part of
* the content a $1 was replaced with.
* @param string $value
* difference between a $1 that was not replaced and a $1 that was part of
* the content a $1 was replaced with.
* @param string $value
- * @return string
+ * @return string
|false
*/
public function replace( $value ) {
$this->error = false;
*/
public function replace( $value ) {
$this->error = false;
- $value = preg_replace_callback( '/\$(\d+|key)/u',
array( $this, 'callback' )
, $value );
+ $value = preg_replace_callback( '/\$(\d+|key)/u',
[ $this, 'callback' ]
, $value );
if ( $this->error ) {
return false;
}
if ( $this->error ) {
return false;
}