3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Toolset\ChangeSet; /** * Class ChangeSet * * Represents a set of iteratable, countable Changes * * @package ChangeSet */ class ChangeSet implements \Iterator, \ArrayAccess, \Countable { /** * @var Change[] */ protected $changes = array(); /** * @var int Iterator position key */ private $position = 0; /** * Add a Change to the ChangeSet * * @param Change $change * * @throws ChangesetValidationException When a Change response with false to an isValid() call * * @return false When a change with the same id already exists */ public function addChange(Change $change) { if (!$change->isValid()) { throw new ChangeSetValidationException( sprintf("Attempted to add an invalid Change to a ChangeSet. Change: %s", $change) ); } foreach ($this->changes as $changeWeAlreadyHave) { if ($changeWeAlreadyHave->getId() === $change->getId()) { return false; } } $this->changes[] = $change; } /** * Remove a Change from the ChangeSet * * @param Change $change */ public function removeChange(Change $change) { array_walk($this->changes, function($changeToCheck, $key) use ($change) { /** @var Change $changeToCheck */ if ($changeToCheck->getId() === $change->getId()) { unset($this->changes[$key]); } }); } /** * Get changes * * @return Change[] */ public function getChanges() { return $this->changes; } /** * {@inheritdoc} * * @return Change */ public function current() { return $this->changes[$this->position]; } /** * {@inheritdoc} */ public function next() { ++$this->position; } /** * {@inheritdoc} */ public function key() { return $this->position; } /** * {@inheritdoc} */ public function valid() { return isset($this->changes[$this->position]); } /** * {@inheritdoc} */ public function rewind() { $this->position = 0; } /** * {@inheritdoc} */ public function count() { return count($this->changes); } /** * {@inheritdoc} */ public function offsetGet($offset) { return isset($this->changes[$offset]) ? $this->changes[$offset] : null; } /** * {@inheritdoc} */ public function offsetSet($offset, $value) { if (is_null($offset)) { $this->changes[] = $value; } else { $this->changes[$offset] = $value; } } /** * {@inheritdoc} */ public function offsetExists($offset) { return isset($this->changes[$offset]); } /** * {@inheritdoc} */ public function offsetUnset($offset) { unset($this->changes[$offset]); } }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Toolset\ChangeSet\ChangeSet::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 77 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 84 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 91 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 98 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 105 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 140 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 119 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 126 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 147 Deprecated: Return type of Toolset\ChangeSet\ChangeSet::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/XOG60 on line 112

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
81.93 ms | 2506 KiB | 4 Q