Merge "More Profiler class refactoring"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 21 Apr 2014 18:02:07 +0000 (18:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 21 Apr 2014 18:02:07 +0000 (18:02 +0000)
14 files changed:
RELEASE-NOTES-1.24
includes/AutoLoader.php
includes/search/SearchPostgres.php
languages/utils/CLDRPluralRuleConverter.php
languages/utils/CLDRPluralRuleConverterExpression.php [new file with mode: 0644]
languages/utils/CLDRPluralRuleConverterFragment.php [new file with mode: 0644]
languages/utils/CLDRPluralRuleConverterOperator.php [new file with mode: 0644]
languages/utils/CLDRPluralRuleConverter_Expression.php [deleted file]
languages/utils/CLDRPluralRuleConverter_Fragment.php [deleted file]
languages/utils/CLDRPluralRuleConverter_Operator.php [deleted file]
languages/utils/CLDRPluralRuleError.php
languages/utils/CLDRPluralRuleEvaluator.php
languages/utils/CLDRPluralRuleEvaluatorRange.php [new file with mode: 0644]
languages/utils/CLDRPluralRuleEvaluator_Range.php [deleted file]

index 500d19f..fd422fa 100644 (file)
@@ -33,6 +33,12 @@ changes to languages because of Bugzilla reports.
 * The Special:Search hooks SpecialSearchGo and SpecialSearchResultsAppend
   were removed as they were unused.
 
+==== Renamed classes ====
+* CLDRPluralRuleConverter_Expression to CLDRPluralRuleConverterExpression
+* CLDRPluralRuleConverter_Fragment to CLDRPluralRuleConverterFragment
+* CLDRPluralRuleConverter_Operator to CLDRPluralRuleConverterOperator
+* CLDRPluralRuleEvaluator_Range to CLDRPluralRuleEvaluatorRange
+
 == Compatibility ==
 
 MediaWiki 1.24 requires PHP 5.3.2 or later.
index d95ac57..97a3246 100644 (file)
@@ -1127,11 +1127,11 @@ $wgAutoloadLocalClasses = array(
        'Language' => 'languages/Language.php',
        'LanguageConverter' => 'languages/LanguageConverter.php',
        'CLDRPluralRuleConverter' => 'languages/utils/CLDRPluralRuleConverter.php',
-       'CLDRPluralRuleConverter_Expression' => 'languages/utils/CLDRPluralRuleConverter_Expression.php',
-       'CLDRPluralRuleConverter_Fragment' => 'languages/utils/CLDRPluralRuleConverter_Fragment.php',
-       'CLDRPluralRuleConverter_Operator' => 'languages/utils/CLDRPluralRuleConverter_Operator.php',
+       'CLDRPluralRuleConverterExpression' => 'languages/utils/CLDRPluralRuleConverterExpression.php',
+       'CLDRPluralRuleConverterFragment' => 'languages/utils/CLDRPluralRuleConverterFragment.php',
+       'CLDRPluralRuleConverterOperator' => 'languages/utils/CLDRPluralRuleConverterOperator.php',
        'CLDRPluralRuleEvaluator' => 'languages/utils/CLDRPluralRuleEvaluator.php',
-       'CLDRPluralRuleEvaluator_Range' => 'languages/utils/CLDRPluralRuleEvaluator_Range.php',
+       'CLDRPluralRuleEvaluatorRange' => 'languages/utils/CLDRPluralRuleEvaluatorRange.php',
        'CLDRPluralRuleError' => 'languages/utils/CLDRPluralRuleError.php',
 
        # maintenance
index 4da63b3..e4f4b55 100644 (file)
@@ -191,7 +191,7 @@ class SearchPostgres extends SearchDatabase {
 
        function update( $pageid, $title, $text ) {
                ## We don't want to index older revisions
-               $sql = "UPDATE pagecontent SET textvector = NULL WHERE old_id IN " .
+               $sql = "UPDATE pagecontent SET textvector = NULL WHERE textvector IS NOT NULL and old_id IN " .
                                "(SELECT rev_text_id FROM revision WHERE rev_page = " . intval( $pageid ) .
                                " ORDER BY rev_text_id DESC OFFSET 1)";
                $this->db->query( $sql );
index 65d57e0..1294b1a 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @author Niklas Laxström, Tim Starling
  *
@@ -97,6 +96,7 @@ class CLDRPluralRuleConverter {
         */
        public static function convert( $rule ) {
                $parser = new self( $rule );
+
                return $parser->doConvert();
        }
 
@@ -119,13 +119,13 @@ class CLDRPluralRuleConverter {
 
                // Iterate through all tokens, saving the operators and operands to a
                // stack per Dijkstra's shunting yard algorithm.
-               /** @var CLDRPluralRuleConverter_Operator $token */
+               /** @var CLDRPluralRuleConverterOperator $token */
                while ( false !== ( $token = $this->nextToken() ) ) {
                        // In this grammar, there are only binary operators, so every valid
                        // rule string will alternate between operator and operand tokens.
                        $expectOperator = !$expectOperator;
 
-                       if ( $token instanceof CLDRPluralRuleConverter_Expression ) {
+                       if ( $token instanceof CLDRPluralRuleConverterExpression ) {
                                // Operand
                                if ( $expectOperator ) {
                                        $token->error( 'unexpected operand' );
@@ -172,7 +172,7 @@ class CLDRPluralRuleConverter {
        /**
         * Fetch the next token from the input string.
         *
-        * @return CLDRPluralRuleConverter_Fragment The next token
+        * @return CLDRPluralRuleConverterFragment The next token
         */
        protected function nextToken() {
                if ( $this->pos >= $this->end ) {
@@ -192,6 +192,7 @@ class CLDRPluralRuleConverter {
                if ( $length !== 0 ) {
                        $token = $this->newNumber( substr( $this->rule, $this->pos, $length ), $this->pos );
                        $this->pos += $length;
+
                        return $token;
                }
 
@@ -200,6 +201,7 @@ class CLDRPluralRuleConverter {
                if ( $op2 === '..' || $op2 === '!=' ) {
                        $token = $this->newOperator( $op2, $this->pos, 2 );
                        $this->pos += 2;
+
                        return $token;
                }
 
@@ -207,7 +209,8 @@ class CLDRPluralRuleConverter {
                $op1 = $this->rule[$this->pos];
                if ( $op1 === ',' || $op1 === '=' || $op1 === '%' ) {
                        $token = $this->newOperator( $op1, $this->pos, 1 );
-                       $this->pos ++;
+                       $this->pos++;
+
                        return $token;
                }
 
@@ -235,6 +238,7 @@ class CLDRPluralRuleConverter {
                        if ( isset( self::$precedence[$bothWords] ) ) {
                                $token = $this->newOperator( $bothWords, $this->pos, $nextTokenPos - $this->pos );
                                $this->pos = $nextTokenPos;
+
                                return $token;
                        }
                }
@@ -243,13 +247,15 @@ class CLDRPluralRuleConverter {
                if ( isset( self::$precedence[$word1] ) ) {
                        $token = $this->newOperator( $word1, $this->pos, strlen( $word1 ) );
                        $this->pos += strlen( $word1 );
+
                        return $token;
                }
 
                // The single-character operand symbols
                if ( strpos( self::OPERAND_SYMBOLS, $word1 ) !== false ) {
                        $token = $this->newNumber( $word1, $this->pos );
-                       $this->pos ++;
+                       $this->pos++;
+
                        return $token;
                }
 
@@ -258,6 +264,7 @@ class CLDRPluralRuleConverter {
                        // Samples are like comments, they have no effect on rule evaluation.
                        // They run from the first sample indicator to the end of the string.
                        $this->pos = $this->end;
+
                        return false;
                }
 
@@ -269,7 +276,7 @@ class CLDRPluralRuleConverter {
         * a fragment with rpn and type members describing the result of that
         * operation.
         *
-        * @param CLDRPluralRuleConverter_Operator $op
+        * @param CLDRPluralRuleConverterOperator $op
         */
        protected function doOperation( $op ) {
                if ( count( $this->operands ) < 2 ) {
@@ -286,10 +293,10 @@ class CLDRPluralRuleConverter {
         *
         * @param string $text
         * @param int $pos
-        * @return CLDRPluralRuleConverter_Expression The numerical expression
+        * @return CLDRPluralRuleConverterExpression The numerical expression
         */
        protected function newNumber( $text, $pos ) {
-               return new CLDRPluralRuleConverter_Expression( $this, 'number', $text, $pos, strlen( $text ) );
+               return new CLDRPluralRuleConverterExpression( $this, 'number', $text, $pos, strlen( $text ) );
        }
 
        /**
@@ -298,10 +305,10 @@ class CLDRPluralRuleConverter {
         * @param string $type
         * @param int $pos
         * @param int $length
-        * @return CLDRPluralRuleConverter_Operator The operator
+        * @return CLDRPluralRuleConverterOperator The operator
         */
        protected function newOperator( $type, $pos, $length ) {
-               return new CLDRPluralRuleConverter_Operator( $this, $type, $pos, $length );
+               return new CLDRPluralRuleConverterOperator( $this, $type, $pos, $length );
        }
 
        /**
diff --git a/languages/utils/CLDRPluralRuleConverterExpression.php b/languages/utils/CLDRPluralRuleConverterExpression.php
new file mode 100644 (file)
index 0000000..1ee6b4c
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @author Niklas Laxström, Tim Starling
+ *
+ * @copyright Copyright © 2010-2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ *
+ * @file
+ * @since 1.20
+ */
+
+/**
+ * Helper for CLDRPluralRuleConverter.
+ * An expression object, representing a region of the input string (for error
+ * messages), the RPN notation used to evaluate it, and the result type for
+ * validation.
+ */
+class CLDRPluralRuleConverterExpression extends CLDRPluralRuleConverterFragment {
+       /** @var string */
+       public $type;
+
+       /** @var string */
+       public $rpn;
+
+       function __construct( $parser, $type, $rpn, $pos, $length ) {
+               parent::__construct( $parser, $pos, $length );
+               $this->type = $type;
+               $this->rpn = $rpn;
+       }
+
+       public function isType( $type ) {
+               if ( $type === 'range' && ( $this->type === 'range' || $this->type === 'number' ) ) {
+                       return true;
+               }
+               if ( $type === $this->type ) {
+                       return true;
+               }
+
+               return false;
+       }
+}
diff --git a/languages/utils/CLDRPluralRuleConverterFragment.php b/languages/utils/CLDRPluralRuleConverterFragment.php
new file mode 100644 (file)
index 0000000..df299cb
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * @author Niklas Laxström, Tim Starling
+ *
+ * @copyright Copyright © 2010-2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ *
+ * @file
+ * @since 1.20
+ */
+
+/**
+ * Helper for CLDRPluralRuleConverter.
+ * The base class for operators and expressions, describing a region of the input string.
+ */
+class CLDRPluralRuleConverterFragment {
+       public $parser, $pos, $length, $end;
+
+       function __construct( $parser, $pos, $length ) {
+               $this->parser = $parser;
+               $this->pos = $pos;
+               $this->length = $length;
+               $this->end = $pos + $length;
+       }
+
+       public function error( $message ) {
+               $text = $this->getText();
+               throw new CLDRPluralRuleError( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" );
+       }
+
+       public function getText() {
+               return substr( $this->parser->rule, $this->pos, $this->length );
+       }
+}
diff --git a/languages/utils/CLDRPluralRuleConverterOperator.php b/languages/utils/CLDRPluralRuleConverterOperator.php
new file mode 100644 (file)
index 0000000..4acda7f
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * @author Niklas Laxström, Tim Starling
+ *
+ * @copyright Copyright © 2010-2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ *
+ * @file
+ * @since 1.20
+ */
+
+/**
+ * Helper for CLDRPluralRuleConverter.
+ * An operator object, representing a region of the input string (for error
+ * messages), and the binary operator at that location.
+ */
+class CLDRPluralRuleConverterOperator extends CLDRPluralRuleConverterFragment {
+       /** @var string The name */
+       public $name;
+
+       /**
+        * Each op type has three characters: left operand type, right operand type and result type
+        *
+        *   b = boolean
+        *   n = number
+        *   r = range
+        *
+        * A number is a kind of range.
+        *
+        * @var array
+        */
+       static $opTypes = array(
+               'or' => 'bbb',
+               'and' => 'bbb',
+               'is' => 'nnb',
+               'is-not' => 'nnb',
+               'in' => 'nrb',
+               'not-in' => 'nrb',
+               'within' => 'nrb',
+               'not-within' => 'nrb',
+               'mod' => 'nnn',
+               ',' => 'rrr',
+               '..' => 'nnr',
+       );
+
+       /**
+        * Map converting from the abbrevation to the full form.
+        *
+        * @var array
+        */
+       static $typeSpecMap = array(
+               'b' => 'boolean',
+               'n' => 'number',
+               'r' => 'range',
+       );
+
+       /**
+        * Map for converting the new operators introduced in Rev 33 to the old forms
+        */
+       static $aliasMap = array(
+               '%' => 'mod',
+               '!=' => 'not-in',
+               '=' => 'in'
+       );
+
+       /**
+        * Initialize a new instance of a CLDRPluralRuleConverterOperator object
+        *
+        * @param CLDRPluralRuleConverter $parser The parser
+        * @param string $name The operator name
+        * @param int $pos The length
+        * @param int $length
+        */
+       function __construct( $parser, $name, $pos, $length ) {
+               parent::__construct( $parser, $pos, $length );
+               if ( isset( self::$aliasMap[$name] ) ) {
+                       $name = self::$aliasMap[$name];
+               }
+               $this->name = $name;
+       }
+
+       /**
+        * Compute the operation
+        *
+        * @param CLDRPluralRuleConverterExpression $left The left part of the expression
+        * @param CLDRPluralRuleConverterExpression $right The right part of the expression
+        * @return CLDRPluralRuleConverterExpression The result of the operation
+        */
+       public function operate( $left, $right ) {
+               $typeSpec = self::$opTypes[$this->name];
+
+               $leftType = self::$typeSpecMap[$typeSpec[0]];
+               $rightType = self::$typeSpecMap[$typeSpec[1]];
+               $resultType = self::$typeSpecMap[$typeSpec[2]];
+
+               $start = min( $this->pos, $left->pos, $right->pos );
+               $end = max( $this->end, $left->end, $right->end );
+               $length = $end - $start;
+
+               $newExpr = new CLDRPluralRuleConverterExpression( $this->parser, $resultType,
+                       "{$left->rpn} {$right->rpn} {$this->name}",
+                       $start, $length );
+
+               if ( !$left->isType( $leftType ) ) {
+                       $newExpr->error( "invalid type for left operand: expected $leftType, got {$left->type}" );
+               }
+
+               if ( !$right->isType( $rightType ) ) {
+                       $newExpr->error( "invalid type for right operand: expected $rightType, got {$right->type}" );
+               }
+
+               return $newExpr;
+       }
+}
diff --git a/languages/utils/CLDRPluralRuleConverter_Expression.php b/languages/utils/CLDRPluralRuleConverter_Expression.php
deleted file mode 100644 (file)
index 8352e72..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/**
- * @author Niklas Laxström, Tim Starling
- *
- * @copyright Copyright © 2010-2012, Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
- *
- * @file
- * @since 1.20
- */
-
-/**
- * Helper for CLDRPluralRuleConverter.
- * An expression object, representing a region of the input string (for error
- * messages), the RPN notation used to evaluate it, and the result type for
- * validation.
- */
-class CLDRPluralRuleConverter_Expression extends CLDRPluralRuleConverter_Fragment {
-       /** @var string */
-       public $type;
-
-       /** @var string */
-       public $rpn;
-
-       function __construct( $parser, $type, $rpn, $pos, $length ) {
-               parent::__construct( $parser, $pos, $length );
-               $this->type = $type;
-               $this->rpn = $rpn;
-       }
-
-       public function isType( $type ) {
-               if ( $type === 'range' && ( $this->type === 'range' || $this->type === 'number' ) ) {
-                       return true;
-               }
-               if ( $type === $this->type ) {
-                       return true;
-               }
-               return false;
-       }
-}
diff --git a/languages/utils/CLDRPluralRuleConverter_Fragment.php b/languages/utils/CLDRPluralRuleConverter_Fragment.php
deleted file mode 100644 (file)
index 88795a0..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- * @author Niklas Laxström, Tim Starling
- *
- * @copyright Copyright © 2010-2012, Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
- *
- * @file
- * @since 1.20
- */
-
-/**
- * Helper for CLDRPluralRuleConverter.
- * The base class for operators and expressions, describing a region of the input string.
- */
-class CLDRPluralRuleConverter_Fragment {
-       public $parser, $pos, $length, $end;
-
-       function __construct( $parser, $pos, $length ) {
-               $this->parser = $parser;
-               $this->pos = $pos;
-               $this->length = $length;
-               $this->end = $pos + $length;
-       }
-
-       public function error( $message ) {
-               $text = $this->getText();
-               throw new CLDRPluralRuleError( "$message at position " . ( $this->pos + 1 ) . ": \"$text\"" );
-       }
-
-       public function getText() {
-               return substr( $this->parser->rule, $this->pos, $this->length );
-       }
-}
diff --git a/languages/utils/CLDRPluralRuleConverter_Operator.php b/languages/utils/CLDRPluralRuleConverter_Operator.php
deleted file mode 100644 (file)
index c42953c..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-
-/**
- * @author Niklas Laxström, Tim Starling
- *
- * @copyright Copyright © 2010-2012, Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
- *
- * @file
- * @since 1.20
- */
-
-/**
- * Helper for CLDRPluralRuleConverter.
- * An operator object, representing a region of the input string (for error
- * messages), and the binary operator at that location.
- */
-class CLDRPluralRuleConverter_Operator extends CLDRPluralRuleConverter_Fragment {
-       /** @var string The name */
-       public $name;
-
-       /**
-        * Each op type has three characters: left operand type, right operand type and result type
-        *
-        *   b = boolean
-        *   n = number
-        *   r = range
-        *
-        * A number is a kind of range.
-        *
-        * @var array
-        */
-       static $opTypes = array(
-               'or' => 'bbb',
-               'and' => 'bbb',
-               'is' => 'nnb',
-               'is-not' => 'nnb',
-               'in' => 'nrb',
-               'not-in' => 'nrb',
-               'within' => 'nrb',
-               'not-within' => 'nrb',
-               'mod' => 'nnn',
-               ',' => 'rrr',
-               '..' => 'nnr',
-       );
-
-       /**
-        * Map converting from the abbrevation to the full form.
-        *
-        * @var array
-        */
-       static $typeSpecMap = array(
-               'b' => 'boolean',
-               'n' => 'number',
-               'r' => 'range',
-       );
-
-       /**
-        * Map for converting the new operators introduced in Rev 33 to the old forms
-        */
-       static $aliasMap = array(
-               '%' => 'mod',
-               '!=' => 'not-in',
-               '=' => 'in'
-       );
-
-       /**
-        * Initialize a new instance of a CLDRPluralRuleConverter_Operator object
-        *
-        * @param CLDRPluralRuleConverter $parser The parser
-        * @param string $name The operator name
-        * @param int $pos The length
-        * @param int $length
-        */
-       function __construct( $parser, $name, $pos, $length ) {
-               parent::__construct( $parser, $pos, $length );
-               if ( isset( self::$aliasMap[$name] ) ) {
-                       $name = self::$aliasMap[$name];
-               }
-               $this->name = $name;
-       }
-
-       /**
-        * Compute the operation
-        *
-        * @param CLDRPluralRuleConverter_Expression $left The left part of the expression
-        * @param CLDRPluralRuleConverter_Expression $right The right part of the expression
-        * @return CLDRPluralRuleConverter_Expression The result of the operation
-        */
-       public function operate( $left, $right ) {
-               $typeSpec = self::$opTypes[$this->name];
-
-               $leftType = self::$typeSpecMap[$typeSpec[0]];
-               $rightType = self::$typeSpecMap[$typeSpec[1]];
-               $resultType = self::$typeSpecMap[$typeSpec[2]];
-
-               $start = min( $this->pos, $left->pos, $right->pos );
-               $end = max( $this->end, $left->end, $right->end );
-               $length = $end - $start;
-
-               $newExpr = new CLDRPluralRuleConverter_Expression( $this->parser, $resultType,
-                       "{$left->rpn} {$right->rpn} {$this->name}",
-                       $start, $length );
-
-               if ( !$left->isType( $leftType ) ) {
-                       $newExpr->error( "invalid type for left operand: expected $leftType, got {$left->type}" );
-               }
-
-               if ( !$right->isType( $rightType ) ) {
-                       $newExpr->error( "invalid type for right operand: expected $rightType, got {$right->type}" );
-               }
-               return $newExpr;
-       }
-}
index 2ca3410..cc0b5d2 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * @author Niklas Laxström, Tim Starling
  *
@@ -18,4 +17,4 @@ class CLDRPluralRuleError extends MWException {
        function __construct( $message ) {
                parent::__construct( 'CLDR plural rule error: ' . $message );
        }
-}
\ No newline at end of file
+}
index 61ab947..7e7208a 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * Parse and evaluate a plural rule.
  *
@@ -30,7 +31,6 @@
  * @file
  * @since 1.20
  */
-
 class CLDRPluralRuleEvaluator {
        /**
         * Evaluate a number against a set of plural rules. If a rule passes,
@@ -42,6 +42,7 @@ class CLDRPluralRuleEvaluator {
         */
        public static function evaluate( $number, array $rules ) {
                $rules = self::compile( $rules );
+
                return self::evaluateCompiled( $number, $rules );
        }
 
@@ -58,6 +59,7 @@ class CLDRPluralRuleEvaluator {
                foreach ( $rules as &$rule ) {
                        $rule = CLDRPluralRuleConverter::convert( $rule );
                }
+
                return $rules;
        }
 
@@ -75,6 +77,7 @@ class CLDRPluralRuleEvaluator {
                $number = strval( $number );
                if ( !preg_match( '/^ -? ( ([0-9]+) (?: \. ([0-9]+) )? )$/x', $number, $m ) ) {
                        wfDebug( __METHOD__ . ": invalid number input, returning 'other'\n" );
+
                        return count( $rules );
                }
                if ( !isset( $m[3] ) ) {
@@ -139,8 +142,8 @@ class CLDRPluralRuleEvaluator {
         */
        private static function doOperation( $token, $left, $right ) {
                if ( in_array( $token, array( 'in', 'not-in', 'within', 'not-within' ) ) ) {
-                       if ( !( $right instanceof CLDRPluralRuleEvaluator_Range ) ) {
-                               $right = new CLDRPluralRuleEvaluator_Range( $right );
+                       if ( !( $right instanceof CLDRPluralRuleEvaluatorRange ) ) {
+                               $right = new CLDRPluralRuleEvaluatorRange( $right );
                        }
                }
                switch ( $token ) {
@@ -164,17 +167,19 @@ class CLDRPluralRuleEvaluator {
                                if ( is_int( $left ) ) {
                                        return (int)fmod( $left, $right );
                                }
+
                                return fmod( $left, $right );
                        case ',':
-                               if ( $left instanceof CLDRPluralRuleEvaluator_Range ) {
+                               if ( $left instanceof CLDRPluralRuleEvaluatorRange ) {
                                        $range = $left;
                                } else {
-                                       $range = new CLDRPluralRuleEvaluator_Range( $left );
+                                       $range = new CLDRPluralRuleEvaluatorRange( $left );
                                }
                                $range->add( $right );
+
                                return $range;
                        case '..':
-                               return new CLDRPluralRuleEvaluator_Range( $left, $right );
+                               return new CLDRPluralRuleEvaluatorRange( $left, $right );
                        default:
                                throw new CLDRPluralRuleError( "Invalid RPN token" );
                }
diff --git a/languages/utils/CLDRPluralRuleEvaluatorRange.php b/languages/utils/CLDRPluralRuleEvaluatorRange.php
new file mode 100644 (file)
index 0000000..a62eeb9
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+/**
+ * @author Niklas Laxström, Tim Starling
+ *
+ * @copyright Copyright © 2010-2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
+ *
+ * @file
+ * @since 1.20
+ */
+
+/**
+ * Evaluator helper class representing a range list.
+ */
+class CLDRPluralRuleEvaluatorRange {
+       /**
+        * The parts
+        *
+        * @var array
+        */
+       public $parts = array();
+
+       /**
+        * Initialize a new instance of CLDRPluralRuleEvaluatorRange
+        *
+        * @param int $start The start of the range
+        * @param int|bool $end The end of the range, or false if the range is not bounded.
+        */
+       function __construct( $start, $end = false ) {
+               if ( $end === false ) {
+                       $this->parts[] = $start;
+               } else {
+                       $this->parts[] = array( $start, $end );
+               }
+       }
+
+       /**
+        * Determine if the given number is inside the range.
+        *
+        * @param int $number The number to check
+        * @param bool $integerConstraint If true, also asserts the number is an integer; otherwise, number simply has to be inside the range.
+        * @return bool True if the number is inside the range; otherwise, false.
+        */
+       function isNumberIn( $number, $integerConstraint = true ) {
+               foreach ( $this->parts as $part ) {
+                       if ( is_array( $part ) ) {
+                               if ( ( !$integerConstraint || floor( $number ) === (float)$number )
+                                       && $number >= $part[0] && $number <= $part[1]
+                               ) {
+                                       return true;
+                               }
+                       } else {
+                               if ( $number == $part ) {
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+
+       /**
+        * Readable alias for isNumberIn( $number, false ), and the implementation
+        * of the "within" operator.
+        *
+        * @param int $number The number to check
+        * @return bool True if the number is inside the range; otherwise, false.
+        */
+       function isNumberWithin( $number ) {
+               return $this->isNumberIn( $number, false );
+       }
+
+       /**
+        * Add another part to this range.
+        *
+        * @param CLDRPluralRuleEvaluatorRange|int $other The part to add, either
+        *   a range object itself or a single number.
+        */
+       function add( $other ) {
+               if ( $other instanceof self ) {
+                       $this->parts = array_merge( $this->parts, $other->parts );
+               } else {
+                       $this->parts[] = $other;
+               }
+       }
+
+       /**
+        * Returns the string representation of the rule evaluator range.
+        * The purpose of this method is to help debugging.
+        *
+        * @return string The string representation of the rule evaluator range
+        */
+       function __toString() {
+               $s = 'Range(';
+               foreach ( $this->parts as $i => $part ) {
+                       if ( $i ) {
+                               $s .= ', ';
+                       }
+                       if ( is_array( $part ) ) {
+                               $s .= $part[0] . '..' . $part[1];
+                       } else {
+                               $s .= $part;
+                       }
+               }
+               $s .= ')';
+
+               return $s;
+       }
+}
diff --git a/languages/utils/CLDRPluralRuleEvaluator_Range.php b/languages/utils/CLDRPluralRuleEvaluator_Range.php
deleted file mode 100644 (file)
index 9732b8d..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-<?php
-/**
- * @author Niklas Laxström, Tim Starling
- *
- * @copyright Copyright © 2010-2012, Niklas Laxström
- * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
- *
- * @file
- * @since 1.20
- */
-
-/**
- * Evaluator helper class representing a range list.
- */
-class CLDRPluralRuleEvaluator_Range {
-       /**
-        * The parts
-        *
-        * @var array
-        */
-       public $parts = array();
-
-       /**
-        * Initialize a new instance of CLDRPluralRuleEvaluator_Range
-        *
-        * @param int $start The start of the range
-        * @param int|bool $end The end of the range, or false if the range is not bounded.
-        */
-       function __construct( $start, $end = false ) {
-               if ( $end === false ) {
-                       $this->parts[] = $start;
-               } else {
-                       $this->parts[] = array( $start, $end );
-               }
-       }
-
-       /**
-        * Determine if the given number is inside the range.
-        *
-        * @param int $number The number to check
-        * @param bool $integerConstraint If true, also asserts the number is an integer; otherwise, number simply has to be inside the range.
-        * @return bool True if the number is inside the range; otherwise, false.
-        */
-       function isNumberIn( $number, $integerConstraint = true ) {
-               foreach ( $this->parts as $part ) {
-                       if ( is_array( $part ) ) {
-                               if ( ( !$integerConstraint || floor( $number ) === (float)$number )
-                                       && $number >= $part[0] && $number <= $part[1]
-                               ) {
-                                       return true;
-                               }
-                       } else {
-                               if ( $number == $part ) {
-                                       return true;
-                               }
-                       }
-               }
-               return false;
-       }
-
-       /**
-        * Readable alias for isNumberIn( $number, false ), and the implementation
-        * of the "within" operator.
-        *
-        * @param int $number The number to check
-        * @return bool True if the number is inside the range; otherwise, false.
-        */
-       function isNumberWithin( $number ) {
-               return $this->isNumberIn( $number, false );
-       }
-
-       /**
-        * Add another part to this range.
-        *
-        * @param CLDRPluralRuleEvaluator_Range|int $other The part to add, either
-        *   a range object itself or a single number.
-        */
-       function add( $other ) {
-               if ( $other instanceof self ) {
-                       $this->parts = array_merge( $this->parts, $other->parts );
-               } else {
-                       $this->parts[] = $other;
-               }
-       }
-
-       /**
-        * Returns the string representation of the rule evaluator range.
-        * The purpose of this method is to help debugging.
-        *
-        * @return string The string representation of the rule evaluator range
-        */
-       function __toString() {
-               $s = 'Range(';
-               foreach ( $this->parts as $i => $part ) {
-                       if ( $i ) {
-                               $s .= ', ';
-                       }
-                       if ( is_array( $part ) ) {
-                               $s .= $part[0] . '..' . $part[1];
-                       } else {
-                               $s .= $part;
-                       }
-               }
-               $s .= ')';
-               return $s;
-       }
-
-}