Neos\Eel\Helper\ArrayHelper::pop PHP Method

pop() public method

Note: This differs from the JavaScript behavior of Array.pop which will return the popped element. An empty array will result in an empty array again.
public pop ( array $array ) : array
$array array
return array The array without the last element
    public function pop(array $array)
    {
        if ($array === []) {
            return $array;
        }
        array_pop($array);
        return $array;
    }

Usage Example

 /**
  * @test
  * @dataProvider popExamples
  */
 public function popWorks($array, $expected)
 {
     $helper = new ArrayHelper();
     $poppedArray = $helper->pop($array);
     $this->assertEquals($expected, $poppedArray);
 }