*
* @param array $elements
*/
- public function __construct(array $elements = array())
+ public function __construct(array $elements = [])
{
$this->elements = $elements;
}
public function offsetSet($offset, $value)
{
if ( ! isset($offset)) {
- return $this->add($value);
+ $this->add($value);
+ return;
}
$this->set($offset, $value);
*/
public function offsetUnset($offset)
{
- return $this->remove($offset);
+ $this->remove($offset);
}
/**
*/
public function get($key)
{
- return isset($this->elements[$key]) ? $this->elements[$key] : null;
+ return $this->elements[$key] ?? null;
}
/**
/**
* {@inheritDoc}
+ *
+ * @return static
*/
public function map(Closure $func)
{
/**
* {@inheritDoc}
+ *
+ * @return static
*/
public function filter(Closure $p)
{
*/
public function partition(Closure $p)
{
- $matches = $noMatches = array();
+ $matches = $noMatches = [];
foreach ($this->elements as $key => $element) {
if ($p($key, $element)) {
}
}
- return array($this->createFrom($matches), $this->createFrom($noMatches));
+ return [$this->createFrom($matches), $this->createFrom($noMatches)];
}
/**
*/
public function clear()
{
- $this->elements = array();
+ $this->elements = [];
}
/**