Merge "Update wikimedia/normalized-exception to 2.1.1"
[mediawiki.git] / includes / libs / iterators / IteratorDecorator.php
blobd97da4fd8ab3838dce2f1ea71b8c5b2021f16458
1 <?php
2 /**
3 * Allows extending classes to decorate an Iterator with
4 * reduced boilerplate.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
21 * @stable to extend
22 * @file
23 * @ingroup Maintenance
25 abstract class IteratorDecorator implements Iterator {
26 protected Iterator $iterator;
28 /**
29 * @stable to call
31 * @param Iterator $iterator
33 public function __construct( Iterator $iterator ) {
34 $this->iterator = $iterator;
37 /**
38 * @inheritDoc
39 * @stable to override
41 #[\ReturnTypeWillChange]
42 public function current() {
43 return $this->iterator->current();
46 /**
47 * @inheritDoc
48 * @stable to override
50 #[\ReturnTypeWillChange]
51 public function key() {
52 return $this->iterator->key();
55 /**
56 * @inheritDoc
57 * @stable to override
59 public function next(): void {
60 $this->iterator->next();
63 /**
64 * @inheritDoc
65 * @stable to override
67 public function rewind(): void {
68 $this->iterator->rewind();
71 /**
72 * @inheritDoc
73 * @stable to override
75 public function valid(): bool {
76 return $this->iterator->valid();