aboutsummaryrefslogtreecommitdiff
path: root/lib/exTpl/IndexExpression.php
blob: ecb3241bee275c7633ea322188efbb9e1215dbff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace exTpl;

/**
 * IndexExpression represents the array index operator.
 */
class IndexExpression extends BinaryExpression
{
    /**
     * Returns the value of this expression.
     *
     * @param Context $context symbol table
     */
    public function value(Context $context): mixed
    {
        $left  = $this->left->value($context);
        $right = $this->right->value($context);

        return $left[$right];
    }
}