<?php
class Test implements Iterator
{
public function current()
{
return "value";
}
public function key()
{
return new stdClass;
}
public function next()
{
}
public function rewind()
{
}
public function valid()
{
return true;
}
}
$test = new Test;
foreach ($test as $key => $value) {
var_dump($key, $value);
break;
}
Deprecated: Return type of Test::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 5
Deprecated: Return type of Test::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 15
Deprecated: Return type of Test::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 10
Deprecated: Return type of Test::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 25
Deprecated: Return type of Test::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 20
object(stdClass)#3 (0) {
}
string(5) "value"
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Deprecated: Return type of Test::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 5
Deprecated: Return type of Test::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 15
Deprecated: Return type of Test::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 10
Deprecated: Return type of Test::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 25
Deprecated: Return type of Test::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/VU5Df on line 20
object(stdClass)#3 (0) {
}
string(5) "value"