public function testFunctional() { $coll = new ListArray(); $coll[0] = 0; $coll->add(1); $coll->add(2); $coll->add(3); $coll->add(4); $this->assertSame([0, 1, 2, 3, 4], $coll->toArray()); unset($coll[0]); $this->assertSame([1, 2, 3, 4], $coll->toArray()); $coll->removeElement(2); $this->assertSame([1, 3, 4], $coll->toArray()); $coll->remove(2); $this->assertSame([1, 3], $coll->toArray()); $coll->remove(2); $this->assertSame([1, 3], $coll->toArray()); }
/** * @inheritdoc */ public function set($key, $value) { parent::set($key, $value); usort($this->elements, [$this, 'compare']); }