MDL-73424 general: Internal methods must have same type as parent

Otherwise the error is thrown in PHP8.1
This commit is contained in:
Marina Glancy
2022-10-10 16:46:13 +02:00
parent cc4fec275f
commit 41b93bd7e5
42 changed files with 154 additions and 98 deletions
@@ -202,6 +202,7 @@ class test_counting_iterator implements \Iterator {
*
* @return mixed Can return any type.
*/
#[\ReturnTypeWillChange]
public function current() {
$this->count++;
return false;
@@ -219,7 +220,7 @@ class test_counting_iterator implements \Iterator {
/**
* Goes on to the next element.
*/
public function next() {
public function next(): void {
$this->pos++;
}
@@ -228,6 +229,7 @@ class test_counting_iterator implements \Iterator {
*
* @throws \coding_exception Always
*/
#[\ReturnTypeWillChange]
public function key() {
throw new \coding_exception('Unsupported');
}
@@ -237,14 +239,14 @@ class test_counting_iterator implements \Iterator {
*
* @return bool True if still valid
*/
public function valid() {
public function valid(): bool {
return $this->pos < 3;
}
/**
* Rewinds the iterator.
*/
public function rewind() {
public function rewind(): void {
$this->pos = 0;
}
}