PluralExpression final class
Minn\I18n\PluralExpression · public/minn/src/Minn/I18n/PluralExpression.php · 147 lines
The C subset a Plural-Forms header writes its rule in: the number n, integer literals, parentheses, ! and unary minus, * / %, + -, the four comparisons, == and !=, && and ||, and the ternary, with C's precedence and the ternary binding to the right. Parsed into a small tree once and evaluated per number; nothing is ever handed to PHP to run.
Used by 1
Constants and properties
| private | TOKEN = '/\\G\\s*(\\d+|n|==|!=|<=|>=|&&|\\|\\||[<>!?:()+\\-*\\/%])/' | |
| private | BINARY = array ( '||' => 1, '&&' => 2, '==' => 3, '!=' => 3, '<' => 4, '>' => 4, '<=' => 4, '>=' => 4, '+' => 5, '-' => 5, '*' => 6, '/' => 6, '%' => 6, ) |
Public
Internals 5
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | binary(string $operator, int $left, int $right): int# | ||||
| private | tokens(string $expression): ?array# | @return list<string>|null | |||
| private | ternary(array $tokens, int $position): ?array# |
@return array<int, mixed>|null | |||
| private | binaryLevel(array $tokens, int $position, int $level): ?array# | One level of left-associative binary operators, and every tighter level under it.
@return array<int, mixed>|null | |||
| private | unary(array $tokens, int $position): ?array# |
@return array<int, mixed>|null |
Nothing matches.