nicmart/Tree

PHP Warning: Undefined array key -1

pedzed opened this issue · 1 comments

Steps required to reproduce the problem

use Tree\Builder\NodeBuilder;

(new NodeBuilder)->value('some value')->end()->getNode();

Expected Result

An exception should to be thrown if pre-conditions are not met.

Actual Result

PHP Warning:  Undefined array key -1 in vendor/nicmart/tree/src/Builder/NodeBuilder.php on line 43

Code in question:

public function getNode(): NodeInterface
{
return $this->nodeStack[\count($this->nodeStack) - 1];
}

Thank you for reporting, @pedzed!