Neos\Eel\Tests\Unit\AbstractEvaluatorTest::methodCallExpressions PHP Method

methodCallExpressions() public method

public methodCallExpressions ( ) : array
return array
    public function methodCallExpressions()
    {
        // Wrap an array with functions inside a context
        $contextArray = ['count' => function ($array) {
            return count($array);
        }, 'pow' => function ($base, $exp) {
            return pow($base, $exp);
        }, 'funcs' => ['dup' => function ($array) {
            return array_map(function ($item) {
                return $item * 2;
            }, $array);
        }], 'foo' => function () {
            return ['a' => 'a1', 'b' => 'b1'];
        }, 'arr' => ['a' => 1, 'b' => 2, 'c' => 3], 'someVariable' => 'b'];
        $c = new Context($contextArray);
        $protectedContext = new \Neos\Eel\ProtectedContext($contextArray);
        $protectedContext->whitelist('*');
        return [['count(arr)', $c, 3], ['pow(2, 8)', $c, 256], ['count(arr) + 1', $c, 4], ['pow(2, count(arr) + 1)', $c, 16], ['funcs.dup(arr).b', $c, 4], ['funcs.dup(arr)[someVariable]', $c, 4], ['foo()[someVariable]', $c, 'b1'], ['foo()[someVariable]', $protectedContext, 'b1'], ['unknwn.func()', $c, null]];
    }