From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/PathRouter.php | 62 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'includes/PathRouter.php') diff --git a/includes/PathRouter.php b/includes/PathRouter.php index 3e298a58..2dbc7ec0 100644 --- a/includes/PathRouter.php +++ b/includes/PathRouter.php @@ -1,4 +1,25 @@ '$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 + * - You can specify a value that won't have replacements in it * using `'foo' => array( 'value' => 'bar' );` * * Options: @@ -51,11 +72,20 @@ */ class PathRouter { + /** + * @var array + */ + private $patterns = array(); + /** * Protected helper to do the actual bulk work of adding a single pattern. * This is in a separate method so that add() can handle the difference between * a single string $path and an array() $path that contains multiple path * patterns each with an associated $key to pass on. + * @param $path string + * @param $params array + * @param $options array + * @param $key null|string */ protected function doAdd( $path, $params, $options, $key = null ) { // Make sure all paths start with a / @@ -123,9 +153,9 @@ class PathRouter { /** * Add a new path pattern to the path router * - * @param $path The path pattern to add - * @param $params The params for this path pattern - * @param $options The options for this path pattern + * @param $path string|array The path pattern to add + * @param $params array The params for this path pattern + * @param $options array The options for this path pattern */ public function add( $path, $params = array(), $options = array() ) { if ( is_array( $path ) ) { @@ -140,6 +170,9 @@ class PathRouter { /** * Add a new path pattern to the path router with the strict option on * @see self::add + * @param $path string|array + * @param $params array + * @param $options array */ public function addStrict( $path, $params = array(), $options = array() ) { $options['strict'] = true; @@ -158,6 +191,10 @@ class PathRouter { array_multisort( $weights, SORT_DESC, SORT_NUMERIC, $this->patterns ); } + /** + * @param $pattern object + * @return float|int + */ protected static function makeWeight( $pattern ) { # Start with a weight of 0 $weight = 0; @@ -195,14 +232,14 @@ class PathRouter { /** * Parse a path and return the query matches for the path * - * @param $path The path to parse + * @param $path string The path to parse * @return Array The array of matches for the path */ public function parse( $path ) { // Make sure our patterns are sorted by weight so the most specific // matches are tested first $this->sortByWeight(); - + $matches = null; foreach ( $this->patterns as $pattern ) { @@ -219,6 +256,11 @@ class PathRouter { return is_null( $matches ) ? array() : $matches; } + /** + * @param $path string + * @param $pattern string + * @return array|null + */ protected static function extractTitle( $path, $pattern ) { // Convert the path pattern into a regexp we can match with $regexp = preg_quote( $pattern->path, '#' ); @@ -321,6 +363,8 @@ class PathRouterPatternReplacer { * We do this inside of a replacement callback because after replacement we can't tell the * difference between a $1 that was not replaced and a $1 that was part of * the content a $1 was replaced with. + * @param $value string + * @return string */ public function replace( $value ) { $this->error = false; @@ -331,6 +375,10 @@ class PathRouterPatternReplacer { return $value; } + /** + * @param $m array + * @return string + */ protected function callback( $m ) { if ( $m[1] == "key" ) { if ( is_null( $this->key ) ) { @@ -348,4 +396,4 @@ class PathRouterPatternReplacer { } } -} \ No newline at end of file +} -- cgit v1.2.2