public function testReduce() { $first = Token::identifier('hello'); $second = Token::identifier('world'); $collection = new NodeCollection([$first, $second], FALSE); $ret = $collection->reduce(function ($carry, TokenNode $node) { return $carry === '' ? $node->getText() : $carry . ' ' . $node->getText(); }, ''); $this->assertEquals('hello world', $ret); }