From: Alexander Ebert Date: Mon, 9 Oct 2023 16:10:27 +0000 (+0200) Subject: Implement `IteratorAggregate` to delegate iteration of the available label pickers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ac4f51f66d1804296e08bada2565eade2a720fce;p=GitHub%2FWoltLab%2FWCF.git Implement `IteratorAggregate` to delegate iteration of the available label pickers --- diff --git a/wcfsetup/install/files/lib/system/label/LabelPickerGroup.class.php b/wcfsetup/install/files/lib/system/label/LabelPickerGroup.class.php index 15984d6447..2df533ef87 100644 --- a/wcfsetup/install/files/lib/system/label/LabelPickerGroup.class.php +++ b/wcfsetup/install/files/lib/system/label/LabelPickerGroup.class.php @@ -15,7 +15,7 @@ use wcf\system\database\util\PreparedStatementConditionBuilder; * @license GNU Lesser General Public License * @since 6.1 */ -final class LabelPickerGroup implements \Countable, \Iterator +final class LabelPickerGroup implements \Countable, \IteratorAggregate { /** * @var LabelPicker[] @@ -27,8 +27,6 @@ final class LabelPickerGroup implements \Countable, \Iterator */ private readonly array $positionToGroupID; - private int $position = 0; - /** * @param LabelPicker[] $labelPickers */ @@ -204,30 +202,9 @@ final class LabelPickerGroup implements \Countable, \Iterator return \count($this->labelPickers); } - public function current(): LabelPicker - { - $groupID = $this->positionToGroupID[$this->position]; - return $this->labelPickers[$groupID]; - } - - public function key(): int - { - return $this->position; - } - - public function next(): void - { - $this->position++; - } - - public function rewind(): void - { - $this->position = 0; - } - - public function valid(): bool + public function getIterator(): \Traversable { - return isset($this->positionToGroupID[$this->position]); + return new \ArrayIterator($this->labelPickers); } /**