MDL-73424 general: Internal methods must have same type as parent
Otherwise the error is thrown in PHP8.1
This commit is contained in:
@@ -40,23 +40,25 @@ class backup_array_iterator implements iterator {
|
||||
$this->arr = $arr;
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
return reset($this->arr);
|
||||
public function rewind(): void {
|
||||
reset($this->arr);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return current($this->arr);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return key($this->arr);
|
||||
}
|
||||
|
||||
public function next() {
|
||||
return next($this->arr);
|
||||
public function next(): void {
|
||||
next($this->arr);
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return key($this->arr) !== null;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +34,21 @@
|
||||
*/
|
||||
class backup_null_iterator implements iterator {
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ class repeat_event_collection implements event_collection_interface {
|
||||
);
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
public function getIterator(): \Traversable {
|
||||
$parentrecord = $this->get_parent_record();
|
||||
foreach ($this->load_event_records() as $eventrecords) {
|
||||
foreach ($eventrecords as $eventrecord) {
|
||||
|
||||
@@ -200,7 +200,7 @@ class core_calendar_action_event_test_event_collection implements event_collecti
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
public function getIterator(): \Traversable {
|
||||
foreach ($this->events as $event) {
|
||||
yield $event;
|
||||
}
|
||||
|
||||
@@ -464,7 +464,7 @@ class core_calendar_event_mapper_test_event_collection implements event_collecti
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
public function getIterator(): \Traversable {
|
||||
foreach ($this->events as $event) {
|
||||
yield $event;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class core_calendar_event_test_event_collection implements event_collection_inte
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function getIterator() {
|
||||
public function getIterator(): \Traversable {
|
||||
foreach ($this->events as $event) {
|
||||
yield $event;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ class core_course_category implements renderable, cacheable_object, IteratorAggr
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
$ret = array();
|
||||
foreach (self::$coursecatfields as $property => $unused) {
|
||||
if ($this->$property !== false) {
|
||||
|
||||
@@ -336,7 +336,7 @@ class core_course_list_element implements IteratorAggregate {
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
$ret = array('id' => $this->record->id);
|
||||
foreach ($this->record as $property => $value) {
|
||||
$ret[$property] = $value;
|
||||
|
||||
+1
-1
@@ -5217,7 +5217,7 @@ abstract class context extends stdClass implements IteratorAggregate {
|
||||
* Now we can convert context object to array using convert_to_array(),
|
||||
* and feed it properly to json_encode().
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
$ret = array(
|
||||
'id' => $this->id,
|
||||
'contextlevel' => $this->contextlevel,
|
||||
|
||||
@@ -129,6 +129,7 @@ class chart_axis implements JsonSerializable {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'label' => $this->label,
|
||||
|
||||
@@ -43,6 +43,7 @@ class chart_bar extends chart_base {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['horizontal'] = $this->get_horizontal();
|
||||
|
||||
@@ -77,6 +77,7 @@ class chart_base implements JsonSerializable, renderable {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
global $CFG;
|
||||
return [
|
||||
|
||||
@@ -42,6 +42,7 @@ class chart_line extends chart_base {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['smooth'] = $this->get_smooth();
|
||||
|
||||
@@ -42,6 +42,7 @@ class chart_pie extends chart_base {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
$data = parent::jsonSerialize();
|
||||
$data['doughnut'] = $this->get_doughnut();
|
||||
|
||||
@@ -183,6 +183,7 @@ class chart_series implements JsonSerializable {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
$data = [
|
||||
'label' => $this->label,
|
||||
|
||||
@@ -88,6 +88,7 @@ class recordset_walk implements \Iterator {
|
||||
*
|
||||
* @return mixed|bool The returned value type will depend on the callback.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
|
||||
if (!$this->recordset->valid()) {
|
||||
@@ -111,8 +112,8 @@ class recordset_walk implements \Iterator {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function next() {
|
||||
return $this->recordset->next();
|
||||
public function next(): void {
|
||||
$this->recordset->next();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,6 +121,7 @@ class recordset_walk implements \Iterator {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->recordset->key();
|
||||
}
|
||||
@@ -133,7 +135,7 @@ class recordset_walk implements \Iterator {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
if (!$valid = $this->recordset->valid()) {
|
||||
$this->close();
|
||||
}
|
||||
@@ -145,7 +147,7 @@ class recordset_walk implements \Iterator {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
// No rewind as it is not implemented in moodle_recordset.
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -984,7 +984,7 @@ abstract class base implements \IteratorAggregate {
|
||||
*
|
||||
* @return \ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): \Traversable {
|
||||
return new \ArrayIterator($this->data);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ abstract class moodle_recordset implements Iterator {
|
||||
* Rewinds are not supported!
|
||||
* @return void
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
// no seeking, sorry - let's ignore it ;-)
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,10 +62,12 @@ class mysqli_native_moodle_recordset extends moodle_recordset {
|
||||
return $row;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object)$this->current;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
// return first column value as key
|
||||
if (!$this->current) {
|
||||
@@ -75,11 +77,11 @@ class mysqli_native_moodle_recordset extends moodle_recordset {
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->current = $this->fetch_next();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !empty($this->current);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,12 @@ class oci_native_moodle_recordset extends moodle_recordset {
|
||||
return $row;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object)$this->current;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
// return first column value as key
|
||||
if (!$this->current) {
|
||||
@@ -69,11 +71,11 @@ class oci_native_moodle_recordset extends moodle_recordset {
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->current = $this->fetch_next();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !empty($this->current);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,12 @@ class pdo_moodle_recordset extends moodle_recordset {
|
||||
return $row;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object)$this->current;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
// return first column value as key
|
||||
if (!$this->current) {
|
||||
@@ -68,11 +70,11 @@ class pdo_moodle_recordset extends moodle_recordset {
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->current = $this->fetch_next();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !empty($this->current);
|
||||
}
|
||||
|
||||
|
||||
@@ -133,10 +133,12 @@ class pgsql_native_moodle_recordset extends moodle_recordset {
|
||||
return $row;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object)$this->current;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
// return first column value as key
|
||||
if (!$this->current) {
|
||||
@@ -146,11 +148,11 @@ class pgsql_native_moodle_recordset extends moodle_recordset {
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->current = $this->fetch_next();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !empty($this->current);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,10 +105,12 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
return $row;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object)$this->current;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
// return first column value as key
|
||||
if (!$this->current) {
|
||||
@@ -118,7 +120,7 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
return $key;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
if ($this->buffer === null) {
|
||||
$this->current = $this->fetch_next();
|
||||
} else {
|
||||
@@ -126,7 +128,7 @@ class sqlsrv_native_moodle_recordset extends moodle_recordset {
|
||||
}
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !empty($this->current);
|
||||
}
|
||||
|
||||
|
||||
@@ -106,28 +106,31 @@ class read_slave_moodle_recordset_special extends \moodle_recordset {
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return stdClass
|
||||
* @return \stdClass
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return new stdClass();
|
||||
return new \stdClass();
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next() {
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ class read_slave_moodle_recordset_special extends moodle_recordset {
|
||||
* Iterator interface
|
||||
* @return stdClass
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return new stdClass();
|
||||
}
|
||||
@@ -51,19 +52,20 @@ class read_slave_moodle_recordset_special extends moodle_recordset {
|
||||
* Iterator interface
|
||||
* @return void
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
}
|
||||
/**
|
||||
* Iterator interface
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ class zip_archive extends file_archive {
|
||||
*
|
||||
* @return int number of files
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
if (!isset($this->za)) {
|
||||
return false;
|
||||
}
|
||||
@@ -509,6 +509,7 @@ class zip_archive extends file_archive {
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
if (!isset($this->za)) {
|
||||
return false;
|
||||
@@ -522,6 +523,7 @@ class zip_archive extends file_archive {
|
||||
*
|
||||
* @return int current file index
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->pos;
|
||||
}
|
||||
@@ -529,14 +531,14 @@ class zip_archive extends file_archive {
|
||||
/**
|
||||
* Moves forward to next file.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->pos++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewinds back to the first file.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->pos = 0;
|
||||
}
|
||||
|
||||
@@ -545,7 +547,7 @@ class zip_archive extends file_archive {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
if (!isset($this->za)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1568,7 +1568,7 @@ class cm_info implements IteratorAggregate {
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
// Make sure dynamic properties are retrieved prior to view properties.
|
||||
$this->obtain_dynamic_data();
|
||||
$ret = array();
|
||||
@@ -3207,7 +3207,7 @@ class section_info implements IteratorAggregate {
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
$ret = array();
|
||||
foreach (get_object_vars($this) as $key => $value) {
|
||||
if (substr($key, 0, 1) == '_') {
|
||||
|
||||
@@ -1243,7 +1243,7 @@ class navigation_node_collection implements IteratorAggregate, Countable {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return $this->count;
|
||||
}
|
||||
/**
|
||||
@@ -1254,7 +1254,7 @@ class navigation_node_collection implements IteratorAggregate, Countable {
|
||||
*
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
public function getIterator(): Traversable {
|
||||
return new ArrayIterator($this->collection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ class filter implements Countable, Iterator, JsonSerializable {
|
||||
/**
|
||||
* Return the current filter value.
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
if ($this->iteratorposition === null) {
|
||||
$this->rewind();
|
||||
@@ -121,6 +122,7 @@ class filter implements Countable, Iterator, JsonSerializable {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
if ($this->iteratorposition === null) {
|
||||
$this->rewind();
|
||||
@@ -258,6 +260,7 @@ class filter implements Countable, Iterator, JsonSerializable {
|
||||
*
|
||||
* @return mixed|object
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return (object) [
|
||||
'name' => $this->get_name(),
|
||||
|
||||
@@ -295,6 +295,7 @@ abstract class filterset implements JsonSerializable {
|
||||
*
|
||||
* @return mixed|object
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize() {
|
||||
return (object) [
|
||||
'jointype' => $this->get_join_type(),
|
||||
|
||||
@@ -1933,23 +1933,25 @@ class core_completionlib_fake_recordset implements Iterator {
|
||||
$this->index = 0;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return $this->values[$this->index];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->values[$this->index];
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->index++;
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->index = 0;
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return count($this->values) > $this->index;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
class xml_format_exception extends moodle_exception {
|
||||
/** @var string */
|
||||
public $errorstring;
|
||||
/** @var int */
|
||||
public $line;
|
||||
/** @var char */
|
||||
public $char;
|
||||
/**
|
||||
|
||||
@@ -56,9 +56,9 @@ class sortedcontentqueue extends \SPLPriorityQueue {
|
||||
*
|
||||
* @param int $key1
|
||||
* @param int $key2
|
||||
* @return bool
|
||||
* @return int
|
||||
*/
|
||||
public function compare($key1 , $key2) {
|
||||
public function compare($key1 , $key2): int {
|
||||
$record1 = $this->contents[$key1];
|
||||
$record2 = $this->contents[$key2];
|
||||
|
||||
|
||||
@@ -121,6 +121,7 @@ abstract class contextlist_base implements
|
||||
*
|
||||
* @return \context
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
// It is possible that this context has been deleted and we now have subsequent calls being made with this
|
||||
// contextlist. Exceptions here will stop the further processing of this component and that is why we are
|
||||
@@ -137,7 +138,7 @@ abstract class contextlist_base implements
|
||||
$context = $this->current();
|
||||
} else {
|
||||
// There are no more context ids left.
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $context;
|
||||
@@ -148,6 +149,7 @@ abstract class contextlist_base implements
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->iteratorposition;
|
||||
}
|
||||
@@ -155,7 +157,7 @@ abstract class contextlist_base implements
|
||||
/**
|
||||
* Move to the next context in the list.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->iteratorposition;
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@ abstract class contextlist_base implements
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return isset($this->contextids[$this->iteratorposition]);
|
||||
}
|
||||
|
||||
@@ -174,14 +176,14 @@ abstract class contextlist_base implements
|
||||
* The list of contexts is uniqued during the rewind.
|
||||
* The rewind is called at the start of most iterations.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->iteratorposition = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of contexts.
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return count($this->contextids);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return \context
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
$key = $this->get_key_from_position();
|
||||
return $this->contextlists[$key];
|
||||
@@ -127,6 +128,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->get_key_from_position();
|
||||
}
|
||||
@@ -134,7 +136,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
/**
|
||||
* Move to the next context in the list.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->iteratorposition;
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return ($this->iteratorposition < count($this->contextlists));
|
||||
}
|
||||
|
||||
@@ -153,7 +155,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
* The list of contexts is uniqued during the rewind.
|
||||
* The rewind is called at the start of most iterations.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->iteratorposition = 0;
|
||||
}
|
||||
|
||||
@@ -174,7 +176,7 @@ class contextlist_collection implements \Iterator, \Countable {
|
||||
/**
|
||||
* Return the number of contexts.
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return count($this->contextlists);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ abstract class userlist_base implements
|
||||
*
|
||||
* @return \user
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
$user = \core_user::get_user($this->userids[$this->iteratorposition]);
|
||||
|
||||
@@ -160,7 +161,7 @@ abstract class userlist_base implements
|
||||
$user = $this->current();
|
||||
} else {
|
||||
// There are no more context ids left.
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +173,7 @@ abstract class userlist_base implements
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->iteratorposition;
|
||||
}
|
||||
@@ -179,7 +181,7 @@ abstract class userlist_base implements
|
||||
/**
|
||||
* Move to the next user in the list.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->iteratorposition;
|
||||
}
|
||||
|
||||
@@ -188,7 +190,7 @@ abstract class userlist_base implements
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return isset($this->userids[$this->iteratorposition]) && $this->current();
|
||||
}
|
||||
|
||||
@@ -198,14 +200,14 @@ abstract class userlist_base implements
|
||||
* The list of users is uniqued during the rewind.
|
||||
* The rewind is called at the start of most iterations.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->iteratorposition = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of users.
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return count($this->userids);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return \user
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
$key = $this->get_key_from_position();
|
||||
return $this->userlists[$key];
|
||||
@@ -124,6 +125,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->get_key_from_position();
|
||||
}
|
||||
@@ -131,7 +133,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
/**
|
||||
* Move to the next user in the list.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->iteratorposition;
|
||||
}
|
||||
|
||||
@@ -140,7 +142,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return ($this->iteratorposition < count($this->userlists));
|
||||
}
|
||||
|
||||
@@ -150,7 +152,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
* The list of users is uniqued during the rewind.
|
||||
* The rewind is called at the start of most iterations.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->iteratorposition = 0;
|
||||
}
|
||||
|
||||
@@ -171,7 +173,7 @@ class userlist_collection implements \Iterator, \Countable {
|
||||
/**
|
||||
* Return the number of users.
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return count($this->userlists);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1814,36 +1814,39 @@ class question_attempt_step_iterator implements Iterator, ArrayAccess {
|
||||
}
|
||||
|
||||
/** @return question_attempt_step */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return $this->offsetGet($this->i);
|
||||
}
|
||||
/** @return int */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->i;
|
||||
}
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->i;
|
||||
}
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->i = 0;
|
||||
}
|
||||
/** @return bool */
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return $this->offsetExists($this->i);
|
||||
}
|
||||
|
||||
/** @return bool */
|
||||
public function offsetExists($i) {
|
||||
public function offsetExists($i): bool {
|
||||
return $i >= 0 && $i < $this->qa->get_num_steps();
|
||||
}
|
||||
/** @return question_attempt_step */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($i) {
|
||||
return $this->qa->get_step($i);
|
||||
}
|
||||
public function offsetSet($offset, $value) {
|
||||
public function offsetSet($offset, $value): void {
|
||||
throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot set.');
|
||||
}
|
||||
public function offsetUnset($offset) {
|
||||
public function offsetUnset($offset): void {
|
||||
throw new coding_exception('You are only allowed read-only access to question_attempt::states through a question_attempt_step_iterator. Cannot unset.');
|
||||
}
|
||||
}
|
||||
@@ -1857,11 +1860,11 @@ class question_attempt_step_iterator implements Iterator, ArrayAccess {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_attempt_reverse_step_iterator extends question_attempt_step_iterator {
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
--$this->i;
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->i = $this->qa->get_num_steps() - 1;
|
||||
}
|
||||
}
|
||||
@@ -1933,21 +1936,23 @@ class question_attempt_steps_with_submitted_response_iterator extends question_a
|
||||
}
|
||||
|
||||
/** @return question_attempt_step */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return $this->offsetGet($this->submittedresponseno);
|
||||
}
|
||||
/** @return int */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->submittedresponseno;
|
||||
}
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
++$this->submittedresponseno;
|
||||
}
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->submittedresponseno = 1;
|
||||
}
|
||||
/** @return bool */
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return $this->submittedresponseno >= 1 && $this->submittedresponseno <= count($this->stepswithsubmittedresponses);
|
||||
}
|
||||
|
||||
@@ -1955,7 +1960,7 @@ class question_attempt_steps_with_submitted_response_iterator extends question_a
|
||||
* @param int $submittedresponseno
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($submittedresponseno) {
|
||||
public function offsetExists($submittedresponseno): bool {
|
||||
return $submittedresponseno >= 1;
|
||||
}
|
||||
|
||||
@@ -1963,6 +1968,7 @@ class question_attempt_steps_with_submitted_response_iterator extends question_a
|
||||
* @param int $submittedresponseno
|
||||
* @return question_attempt_step
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($submittedresponseno) {
|
||||
if ($submittedresponseno > count($this->stepswithsubmittedresponses)) {
|
||||
return null;
|
||||
@@ -1974,7 +1980,7 @@ class question_attempt_steps_with_submitted_response_iterator extends question_a
|
||||
/**
|
||||
* @return int the count of steps with tries.
|
||||
*/
|
||||
public function count() {
|
||||
public function count(): int {
|
||||
return count($this->stepswithsubmittedresponses);
|
||||
}
|
||||
|
||||
@@ -1993,11 +1999,11 @@ class question_attempt_steps_with_submitted_response_iterator extends question_a
|
||||
}
|
||||
}
|
||||
|
||||
public function offsetSet($offset, $value) {
|
||||
public function offsetSet($offset, $value): void {
|
||||
throw new coding_exception('You are only allowed read-only access to question_attempt::states '.
|
||||
'through a question_attempt_step_iterator. Cannot set.');
|
||||
}
|
||||
public function offsetUnset($offset) {
|
||||
public function offsetUnset($offset): void {
|
||||
throw new coding_exception('You are only allowed read-only access to question_attempt::states '.
|
||||
'through a question_attempt_step_iterator. Cannot unset.');
|
||||
}
|
||||
|
||||
@@ -1056,6 +1056,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @return question_attempt
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return $this->offsetGet(current($this->slots));
|
||||
}
|
||||
@@ -1065,6 +1066,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return current($this->slots);
|
||||
}
|
||||
@@ -1072,14 +1074,14 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
/**
|
||||
* Standard part of the Iterator interface.
|
||||
*/
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
next($this->slots);
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard part of the Iterator interface.
|
||||
*/
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
reset($this->slots);
|
||||
}
|
||||
|
||||
@@ -1088,7 +1090,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return current($this->slots) !== false;
|
||||
}
|
||||
|
||||
@@ -1098,7 +1100,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
* @param int $slot
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($slot) {
|
||||
public function offsetExists($slot): bool {
|
||||
return in_array($slot, $this->slots);
|
||||
}
|
||||
|
||||
@@ -1108,6 +1110,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
* @param int $slot
|
||||
* @return question_attempt
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($slot) {
|
||||
return $this->quba->get_question_attempt($slot);
|
||||
}
|
||||
@@ -1118,7 +1121,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
* @param int $slot
|
||||
* @param question_attempt $value
|
||||
*/
|
||||
public function offsetSet($slot, $value) {
|
||||
public function offsetSet($slot, $value): void {
|
||||
throw new coding_exception('You are only allowed read-only access to ' .
|
||||
'question_attempt::states through a question_attempt_step_iterator. Cannot set.');
|
||||
}
|
||||
@@ -1128,7 +1131,7 @@ class question_attempt_iterator implements Iterator, ArrayAccess {
|
||||
*
|
||||
* @param int $slot
|
||||
*/
|
||||
public function offsetUnset($slot) {
|
||||
public function offsetUnset($slot): void {
|
||||
throw new coding_exception('You are only allowed read-only access to ' .
|
||||
'question_attempt::states through a question_attempt_step_iterator. Cannot unset.');
|
||||
}
|
||||
|
||||
@@ -1365,10 +1365,12 @@ class question_test_recordset extends moodle_recordset {
|
||||
$this->close();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
return (object) current($this->records);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
if (is_null(key($this->records))) {
|
||||
return false;
|
||||
@@ -1377,11 +1379,11 @@ class question_test_recordset extends moodle_recordset {
|
||||
return reset($current);
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
next($this->records);
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
return !is_null(key($this->records));
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class skip_future_documents_iterator implements \Iterator {
|
||||
}
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current() {
|
||||
if (!$this->gotcurrent) {
|
||||
$this->currentdoc = $this->parent->current();
|
||||
@@ -75,16 +76,17 @@ class skip_future_documents_iterator implements \Iterator {
|
||||
return $this->currentdoc;
|
||||
}
|
||||
|
||||
public function next() {
|
||||
public function next(): void {
|
||||
$this->parent->next();
|
||||
$this->gotcurrent = false;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function key() {
|
||||
return $this->parent->key();
|
||||
}
|
||||
|
||||
public function valid() {
|
||||
public function valid(): bool {
|
||||
// Check that the parent is valid.
|
||||
if (!$this->parent->valid()) {
|
||||
return false;
|
||||
@@ -99,7 +101,7 @@ class skip_future_documents_iterator implements \Iterator {
|
||||
}
|
||||
}
|
||||
|
||||
public function rewind() {
|
||||
public function rewind(): void {
|
||||
$this->parent->rewind();
|
||||
$this->gotcurrent = false;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user