From 3af6a04c692b5a91690fe456a97f58304db37acc Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 2 May 2022 13:39:24 +0300 Subject: [PATCH] Use IteratorDecorator from core As far as I can tell, EchoIteratorDecorator is functionally identical to IteratorDecorator from includes/libs/iterators/ in core, so why have a separate copy? (EchoIteratorDecorator does pass through the return value of next() or rewind(), if any, but there shouldn't be any per the Iterator interface.) Change-Id: Ic763ec19c15f67d9c9b42ebffb88c52b9056ed22 --- extension.json | 1 - includes/iterator/CallbackIterator.php | 2 +- includes/iterator/IteratorDecorator.php | 34 ---------------------- includes/iterator/NotRecursiveIterator.php | 2 +- 4 files changed, 2 insertions(+), 37 deletions(-) delete mode 100644 includes/iterator/IteratorDecorator.php diff --git a/extension.json b/extension.json index 6aa060ae4..8a38e75ea 100644 --- a/extension.json +++ b/extension.json @@ -1106,7 +1106,6 @@ "EchoHtmlDigestEmailFormatter": "includes/formatters/EchoHtmlDigestEmailFormatter.php", "EchoHtmlEmailFormatter": "includes/formatters/EchoHtmlEmailFormatter.php", "EchoIcon": "includes/formatters/EchoIcon.php", - "EchoIteratorDecorator": "includes/iterator/IteratorDecorator.php", "EchoLocalCache": "includes/cache/LocalCache.php", "EchoMentionInSummaryPresentationModel": "includes/formatters/MentionInSummaryPresentationModel.php", "EchoMentionPresentationModel": "includes/formatters/MentionPresentationModel.php", diff --git a/includes/iterator/CallbackIterator.php b/includes/iterator/CallbackIterator.php index d08a10dd9..fe47e0ffb 100644 --- a/includes/iterator/CallbackIterator.php +++ b/includes/iterator/CallbackIterator.php @@ -3,7 +3,7 @@ /** * Applies a callback to all values returned from the iterator */ -class EchoCallbackIterator extends EchoIteratorDecorator { +class EchoCallbackIterator extends IteratorDecorator { /** @var callable */ protected $callable; diff --git a/includes/iterator/IteratorDecorator.php b/includes/iterator/IteratorDecorator.php deleted file mode 100644 index 222bb7939..000000000 --- a/includes/iterator/IteratorDecorator.php +++ /dev/null @@ -1,34 +0,0 @@ -iterator = $iterator; - } - - public function current() { - return $this->iterator->current(); - } - - public function key() { - return $this->iterator->key(); - } - - public function next() { - return $this->iterator->next(); - } - - public function rewind() { - return $this->iterator->rewind(); - } - - public function valid() { - return $this->iterator->valid(); - } -} diff --git a/includes/iterator/NotRecursiveIterator.php b/includes/iterator/NotRecursiveIterator.php index 4416dd10f..c5fb4aed6 100644 --- a/includes/iterator/NotRecursiveIterator.php +++ b/includes/iterator/NotRecursiveIterator.php @@ -7,7 +7,7 @@ * Alternatively wraps a recursive iterator to prevent recursing deeper * than the wrapped iterator. */ -class EchoNotRecursiveIterator extends EchoIteratorDecorator implements RecursiveIterator { +class EchoNotRecursiveIterator extends IteratorDecorator implements RecursiveIterator { public function hasChildren() { return false; }