MediaWiki  1.23.2
CLDRPluralRuleConverter_Operator.php
Go to the documentation of this file.
1 <?php
2 
20  public $name;
21 
33  static $opTypes = array(
34  'or' => 'bbb',
35  'and' => 'bbb',
36  'is' => 'nnb',
37  'is-not' => 'nnb',
38  'in' => 'nrb',
39  'not-in' => 'nrb',
40  'within' => 'nrb',
41  'not-within' => 'nrb',
42  'mod' => 'nnn',
43  ',' => 'rrr',
44  '..' => 'nnr',
45  );
46 
52  static $typeSpecMap = array(
53  'b' => 'boolean',
54  'n' => 'number',
55  'r' => 'range',
56  );
57 
61  static $aliasMap = array(
62  '%' => 'mod',
63  '!=' => 'not-in',
64  '=' => 'in'
65  );
66 
75  function __construct( $parser, $name, $pos, $length ) {
76  parent::__construct( $parser, $pos, $length );
77  if ( isset( self::$aliasMap[$name] ) ) {
78  $name = self::$aliasMap[$name];
79  }
80  $this->name = $name;
81  }
82 
90  public function operate( $left, $right ) {
91  $typeSpec = self::$opTypes[$this->name];
92 
93  $leftType = self::$typeSpecMap[$typeSpec[0]];
94  $rightType = self::$typeSpecMap[$typeSpec[1]];
95  $resultType = self::$typeSpecMap[$typeSpec[2]];
96 
97  $start = min( $this->pos, $left->pos, $right->pos );
98  $end = max( $this->end, $left->end, $right->end );
99  $length = $end - $start;
100 
101  $newExpr = new CLDRPluralRuleConverter_Expression( $this->parser, $resultType,
102  "{$left->rpn} {$right->rpn} {$this->name}",
103  $start, $length );
104 
105  if ( !$left->isType( $leftType ) ) {
106  $newExpr->error( "invalid type for left operand: expected $leftType, got {$left->type}" );
107  }
108 
109  if ( !$right->isType( $rightType ) ) {
110  $newExpr->error( "invalid type for right operand: expected $rightType, got {$right->type}" );
111  }
112  return $newExpr;
113  }
114 }
CLDRPluralRuleConverter_Operator\$typeSpecMap
static $typeSpecMap
Definition: CLDRPluralRuleConverter_Operator.php:51
CLDRPluralRuleConverter_Operator\$opTypes
static $opTypes
Definition: CLDRPluralRuleConverter_Operator.php:32
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
CLDRPluralRuleConverter_Operator\$aliasMap
static $aliasMap
Map for converting the new operators introduced in Rev 33 to the old forms.
Definition: CLDRPluralRuleConverter_Operator.php:60
$right
return false if a UserGetRights hook might remove the named right $right
Definition: hooks.txt:2798
CLDRPluralRuleConverter_Fragment\$length
$length
Definition: CLDRPluralRuleConverter_Fragment.php:18
CLDRPluralRuleConverter_Fragment\$end
$end
Definition: CLDRPluralRuleConverter_Fragment.php:18
CLDRPluralRuleConverter_Fragment
Helper for CLDRPluralRuleConverter.
Definition: CLDRPluralRuleConverter_Fragment.php:17
CLDRPluralRuleConverter_Operator\__construct
__construct( $parser, $name, $pos, $length)
Initialize a new instance of a CLDRPluralRuleConverter_Operator object.
Definition: CLDRPluralRuleConverter_Operator.php:74
CLDRPluralRuleConverter_Fragment\$pos
$pos
Definition: CLDRPluralRuleConverter_Fragment.php:18
CLDRPluralRuleConverter_Expression
Helper for CLDRPluralRuleConverter.
Definition: CLDRPluralRuleConverter_Expression.php:19
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
CLDRPluralRuleConverter_Fragment\$parser
$parser
Definition: CLDRPluralRuleConverter_Fragment.php:18
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
CLDRPluralRuleConverter_Operator
Helper for CLDRPluralRuleConverter.
Definition: CLDRPluralRuleConverter_Operator.php:18
CLDRPluralRuleConverter_Operator\operate
operate( $left, $right)
Compute the operation.
Definition: CLDRPluralRuleConverter_Operator.php:89
CLDRPluralRuleConverter_Operator\$name
string $name
The name *.
Definition: CLDRPluralRuleConverter_Operator.php:19