From 4f7b911be3c6eb46b075685f5d8b56c89436d804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 16 Jul 2021 15:34:17 +0200 Subject: [PATCH 1/5] Declare tentative return types for Zend --- Zend/tests/ArrayAccess_indirect_append.phpt | 8 +-- Zend/tests/anon/004.phpt | 8 +-- Zend/tests/anon/005.phpt | 8 +-- .../traversable_throwing_exception.phpt | 2 +- Zend/tests/argument_restriction_005.phpt | 4 +- Zend/tests/assign_coalesce_002.phpt | 16 +++--- Zend/tests/assign_coalesce_003.phpt | 8 +-- Zend/tests/bug26229.phpt | 1 + Zend/tests/bug30346.phpt | 8 +-- Zend/tests/bug30725.phpt | 2 +- Zend/tests/bug31683.phpt | 9 +-- Zend/tests/bug32252.phpt | 8 +-- Zend/tests/bug32674.phpt | 14 ++--- Zend/tests/bug32993.phpt | 8 +-- Zend/tests/bug33710.phpt | 8 +-- Zend/tests/bug39297.phpt | 8 +-- Zend/tests/bug40833.phpt | 8 +-- Zend/tests/bug41209.phpt | 8 +-- Zend/tests/bug49269.phpt | 10 ++-- Zend/tests/bug54367.phpt | 8 +-- Zend/tests/bug60161.phpt | 2 +- Zend/tests/bug62609_2.phpt | 2 +- Zend/tests/bug63217.phpt | 10 ++-- Zend/tests/bug64417.phpt | 8 +-- Zend/tests/bug68896.phpt | 8 +-- Zend/tests/bug69955.phpt | 8 +-- Zend/tests/bug70321.phpt | 8 +-- Zend/tests/bug71731.phpt | 8 +-- Zend/tests/bug75420.10.phpt | 8 +-- Zend/tests/bug75420.11.phpt | 8 +-- Zend/tests/bug75420.12.phpt | 8 +-- Zend/tests/bug75420.13.phpt | 8 +-- Zend/tests/bug75420.14.phpt | 8 +-- Zend/tests/bug75420.15.phpt | 8 +-- Zend/tests/bug75420.16.phpt | 8 +-- Zend/tests/bug75420.9.phpt | 8 +-- Zend/tests/bug78356.phpt | 8 +-- Zend/tests/dereference_005.phpt | 8 +-- Zend/tests/enum/offsetGet-in-const-expr.phpt | 8 +-- Zend/tests/foreach_003.phpt | 10 ++-- Zend/tests/foreach_empty_loop_leak.phpt | 2 +- Zend/tests/generators/bug71013.phpt | 10 ++-- Zend/tests/generators/generator_method.phpt | 2 +- .../generators/generator_method_by_ref.phpt | 2 +- .../yield_from_iterator_agregate.phpt | 2 +- .../yield_from_valid_exception.phpt | 10 ++-- Zend/tests/list/list_reference_006.phpt | 8 +-- Zend/tests/list/list_reference_007.phpt | 8 +-- ...st_destructuring_to_special_variables.phpt | 8 +-- Zend/tests/list_keyed_ArrayAccess.phpt | 9 +-- Zend/tests/list_keyed_evaluation_order.inc | 2 +- Zend/tests/object_handlers.phpt | 10 ++-- Zend/tests/objects_032.phpt | 8 +-- Zend/tests/temporary_cleaning_013.phpt | 56 +++++++++---------- Zend/tests/tentative_type_early_binding.phpt | 2 +- .../typed_properties_065.phpt | 8 +-- Zend/zend_exceptions.stub.php | 4 +- Zend/zend_exceptions_arginfo.h | 5 +- Zend/zend_interfaces.stub.php | 50 ++++++++--------- Zend/zend_interfaces_arginfo.h | 40 +++++++------ Zend/zend_weakrefs.stub.php | 4 +- Zend/zend_weakrefs_arginfo.h | 2 +- ext/opcache/tests/bug77275.phpt | 8 +-- ext/phar/tests/bug45218_SLOWTEST.phpt | 10 ++-- ext/phar/tests/phar_buildfromiterator4.phpt | 10 ++-- ext/phar/tests/phar_buildfromiterator5.phpt | 10 ++-- ext/phar/tests/phar_buildfromiterator6.phpt | 10 ++-- ext/phar/tests/phar_buildfromiterator7.phpt | 10 ++-- ext/phar/tests/phar_buildfromiterator9.phpt | 10 ++-- .../tests/tar/phar_buildfromiterator4.phpt | 10 ++-- .../tests/tar/phar_buildfromiterator5.phpt | 10 ++-- .../tests/tar/phar_buildfromiterator6.phpt | 10 ++-- .../tests/tar/phar_buildfromiterator7.phpt | 10 ++-- .../tests/tar/phar_buildfromiterator9.phpt | 10 ++-- .../tests/zip/phar_buildfromiterator4.phpt | 10 ++-- .../tests/zip/phar_buildfromiterator5.phpt | 10 ++-- .../tests/zip/phar_buildfromiterator6.phpt | 10 ++-- .../tests/zip/phar_buildfromiterator7.phpt | 10 ++-- .../tests/zip/phar_buildfromiterator9.phpt | 10 ++-- .../ReflectionClass_isIterateable_001.phpt | 12 ++-- .../ReflectionClass_isIterateable_basic.phpt | 10 ++-- ext/soap/tests/server031.phpt | 10 ++-- ...iveIteratorIterator_invalid_aggregate.phpt | 1 + ext/spl/tests/array_005.phpt | 2 +- ext/spl/tests/array_007.phpt | 2 +- ext/spl/tests/bug52238.phpt | 2 +- ext/spl/tests/bug65328.phpt | 2 +- ext/spl/tests/dualiterator.inc | 8 +-- ext/spl/tests/iterator_003.phpt | 2 +- .../tests/recursive_tree_iterator_006.phpt | 2 +- .../tests/recursive_tree_iterator_007.phpt | 2 +- ext/spl/tests/regexiterator_getpregflags.phpt | 10 ++-- ext/spl/tests/regexiterator_setpregflags.phpt | 10 ++-- tests/classes/array_access_001.phpt | 10 ++-- tests/classes/array_access_002.phpt | 10 ++-- tests/classes/array_access_003.phpt | 10 ++-- tests/classes/array_access_004.phpt | 10 ++-- tests/classes/array_access_005.phpt | 8 +-- tests/classes/array_access_006.phpt | 8 +-- tests/classes/array_access_007.phpt | 8 +-- tests/classes/array_access_008.phpt | 8 +-- tests/classes/array_access_009.phpt | 16 +++--- tests/classes/array_access_010.phpt | 16 +++--- tests/classes/array_access_011.phpt | 16 +++--- tests/classes/array_access_012.phpt | 8 +-- tests/classes/array_access_013.phpt | 8 +-- tests/classes/iterators_001.phpt | 12 ++-- tests/classes/iterators_002.phpt | 12 ++-- tests/classes/iterators_003.phpt | 12 ++-- tests/classes/iterators_004.phpt | 6 +- tests/classes/iterators_006.phpt | 12 ++-- tests/classes/iterators_007.phpt | 10 ++-- tests/classes/iterators_008.phpt | 12 ++-- tests/lang/foreachLoopIterator.001.phpt | 12 ++-- tests/lang/foreachLoopIterator.002.phpt | 10 ++-- .../foreachLoopIteratorAggregate.001.phpt | 22 ++++---- .../foreachLoopIteratorAggregate.002.phpt | 12 ++-- .../foreachLoopIteratorAggregate.003.phpt | 18 +++--- .../foreachLoopIteratorAggregate.004.phpt | 12 ++-- 119 files changed, 559 insertions(+), 540 deletions(-) diff --git a/Zend/tests/ArrayAccess_indirect_append.phpt b/Zend/tests/ArrayAccess_indirect_append.phpt index 6f3da7c46ca8b..656b4bbca9a38 100644 --- a/Zend/tests/ArrayAccess_indirect_append.phpt +++ b/Zend/tests/ArrayAccess_indirect_append.phpt @@ -5,18 +5,18 @@ Using indirect append on ArrayAccess object class AA implements ArrayAccess { private $data = []; - public function &offsetGet($name) { + public function &offsetGet($name): mixed { if (null === $name) { return $this->data[]; } else { return $this->data[$name]; } } - public function offsetSet($name, $value) { + public function offsetSet($name, $value): void { $this->data[$name] = $value; } - public function offsetUnset($name) {} - public function offsetExists($name) {} + public function offsetUnset($name): void {} + public function offsetExists($name): bool {} } $aa = new AA; diff --git a/Zend/tests/anon/004.phpt b/Zend/tests/anon/004.phpt index 8751bceb8c1e5..5987ebb47c831 100644 --- a/Zend/tests/anon/004.phpt +++ b/Zend/tests/anon/004.phpt @@ -12,10 +12,10 @@ class Outer { public function getArrayAccess() { /* create a proxy object implementing array access */ return new class($this->data) extends Outer implements ArrayAccess { - public function offsetGet($offset) { return $this->data[$offset]; } - public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); } - public function offsetUnset($offset) { unset($this->data[$offset]); } - public function offsetExists($offset) { return isset($this->data[$offset]); } + public function offsetGet($offset): mixed { return $this->data[$offset]; } + public function offsetSet($offset, $data): void { $this->data[$offset] = $data; } + public function offsetUnset($offset): void { unset($this->data[$offset]); } + public function offsetExists($offset): bool { return isset($this->data[$offset]); } }; } } diff --git a/Zend/tests/anon/005.phpt b/Zend/tests/anon/005.phpt index 215666d23e408..cd8ed5a9ef40a 100644 --- a/Zend/tests/anon/005.phpt +++ b/Zend/tests/anon/005.phpt @@ -14,10 +14,10 @@ class Outer { /* create a child object implementing array access */ /* this grants you access to protected methods and members */ return new class($this->data) implements ArrayAccess { - public function offsetGet($offset) { return $this->data[$offset]; } - public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); } - public function offsetUnset($offset) { unset($this->data[$offset]); } - public function offsetExists($offset) { return isset($this->data[$offset]); } + public function offsetGet($offset): mixed { return $this->data[$offset]; } + public function offsetSet($offset, $data): void { $this->data[$offset] = $data; } + public function offsetUnset($offset): void { unset($this->data[$offset]); } + public function offsetExists($offset): bool { return isset($this->data[$offset]); } }; } } diff --git a/Zend/tests/arg_unpack/traversable_throwing_exception.phpt b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt index abbf5375876b9..c78e491e2015a 100644 --- a/Zend/tests/arg_unpack/traversable_throwing_exception.phpt +++ b/Zend/tests/arg_unpack/traversable_throwing_exception.phpt @@ -8,7 +8,7 @@ function test(...$args) { } class Foo implements IteratorAggregate { - public function getIterator() { + public function getIterator(): Traversable { throw new Exception('getIterator'); } } diff --git a/Zend/tests/argument_restriction_005.phpt b/Zend/tests/argument_restriction_005.phpt index dc15593013d97..8374af29c58fe 100644 --- a/Zend/tests/argument_restriction_005.phpt +++ b/Zend/tests/argument_restriction_005.phpt @@ -3,9 +3,9 @@ Bug #55719 (Argument restriction should come with a more specific error message) --FILE-- --EXPECTF-- -Fatal error: Declaration of Sub::offsetSet() must be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value) in %sargument_restriction_005.php on line %d +Fatal error: Declaration of Sub::offsetSet(): void must be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void in %sargument_restriction_005.php on line %d diff --git a/Zend/tests/assign_coalesce_002.phpt b/Zend/tests/assign_coalesce_002.phpt index e49544effc0e5..0b2c5374bc7a4 100644 --- a/Zend/tests/assign_coalesce_002.phpt +++ b/Zend/tests/assign_coalesce_002.phpt @@ -26,15 +26,15 @@ try { var_dump($ary); class AA implements ArrayAccess { - public function offsetExists($k) { + public function offsetExists($k): bool { return true; } - public function &offsetGet($k) { + public function &offsetGet($k): mixed { $var = ["foo" => "bar"]; return $var; } - public function offsetSet($k,$v) {} - public function offsetUnset($k) {} + public function offsetSet($k,$v): void {} + public function offsetUnset($k): void {} } class Dtor { @@ -52,14 +52,14 @@ try { var_dump($foo); class AA2 implements ArrayAccess { - public function offsetExists($k) { + public function offsetExists($k): bool { return false; } - public function offsetGet($k) { + public function offsetGet($k): mixed { return null; } - public function offsetSet($k,$v) {} - public function offsetUnset($k) {} + public function offsetSet($k,$v): void {} + public function offsetUnset($k): void {} } $ary = ["foo" => new AA2]; diff --git a/Zend/tests/assign_coalesce_003.phpt b/Zend/tests/assign_coalesce_003.phpt index 8509aa114d94c..70d6060a5f895 100644 --- a/Zend/tests/assign_coalesce_003.phpt +++ b/Zend/tests/assign_coalesce_003.phpt @@ -13,19 +13,19 @@ class AA implements ArrayAccess { public function __construct($data = []) { $this->data = $data; } - public function &offsetGet($k) { + public function &offsetGet($k): mixed { echo "offsetGet($k)\n"; return $this->data[$k]; } - public function offsetExists($k) { + public function offsetExists($k): bool { echo "offsetExists($k)\n"; return array_key_exists($k, $this->data); } - public function offsetSet($k,$v) { + public function offsetSet($k,$v): void { echo "offsetSet($k,$v)\n"; $this->data[$k] = $v; } - public function offsetUnset($k) { } + public function offsetUnset($k): void { } } $ary = new AA(["foo" => new AA, "null" => null]); diff --git a/Zend/tests/bug26229.phpt b/Zend/tests/bug26229.phpt index ffc6995f43754..5914b977ef51a 100644 --- a/Zend/tests/bug26229.phpt +++ b/Zend/tests/bug26229.phpt @@ -4,6 +4,7 @@ Bug #26229 (getIterator() segfaults when it returns arrays or scalars) _elements); } - public function count() { + public function count(): int { return count($this->_elements); } - public function current() { + public function current(): mixed { $element = current($this->_elements); return $element; } - public function next() { + public function next(): void { $element = next($this->_elements); - return $element; + $element; } - public function key() { + public function key(): mixed { $this->_fillCollection(); $element = key($this->_elements); return $element; } - public function valid() { + public function valid(): bool { throw new Exception('shit happened'); return ($this->current() !== false); diff --git a/Zend/tests/bug32993.phpt b/Zend/tests/bug32993.phpt index 88fb0230b6bd5..fbc0eb0702415 100644 --- a/Zend/tests/bug32993.phpt +++ b/Zend/tests/bug32993.phpt @@ -6,11 +6,11 @@ class Test implements Iterator { public $arr = array(); - public function rewind() { return reset($this->arr); } - public function current() { throw new Exception(); } + public function rewind(): void { reset($this->arr); } + public function current(): mixed { throw new Exception(); } public function key() { return key($this->arr); } - public function next() { return next($this->arr); } - public function valid() { return (current($this->arr) !== false); } + public function next(): void { next($this->arr); } + public function valid(): bool { return (current($this->arr) !== false); } } $t = new Test(); diff --git a/Zend/tests/bug33710.phpt b/Zend/tests/bug33710.phpt index f731c39509a80..ddc2fa1848dd3 100644 --- a/Zend/tests/bug33710.phpt +++ b/Zend/tests/bug33710.phpt @@ -5,10 +5,10 @@ Bug #33710 (ArrayAccess objects doesn't initialize $this) class Foo implements ArrayAccess { - function offsetExists($offset) {/*...*/} - function offsetGet($offset) {/*...*/} - function offsetSet($offset, $value) {/*...*/} - function offsetUnset($offset) {/*...*/} + function offsetExists($offset): bool { return true;} + function offsetGet($offset): mixed { return null; } + function offsetSet($offset, $value): void {/*...*/} + function offsetUnset($offset): void {/*...*/} function fail() { diff --git a/Zend/tests/bug39297.phpt b/Zend/tests/bug39297.phpt index 6ea989da46f39..4c6cf02c3a14e 100644 --- a/Zend/tests/bug39297.phpt +++ b/Zend/tests/bug39297.phpt @@ -10,20 +10,20 @@ class MyTree implements ArrayAccess { public $parent; public $children = array(); - public function offsetExists($offset) { + public function offsetExists($offset): bool { } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { echo "offsetSet()\n"; $cannonicalName = strtolower($offset); $this->children[$cannonicalName] = $value; $value->parent = $this; } - public function offsetGet($offset) { + public function offsetGet($offset): mixed { echo "offsetGet()\n"; $cannonicalName = strtolower($offset); return $this->children[$cannonicalName]; diff --git a/Zend/tests/bug40833.phpt b/Zend/tests/bug40833.phpt index 6a050eed8b526..1abf580e337ac 100644 --- a/Zend/tests/bug40833.phpt +++ b/Zend/tests/bug40833.phpt @@ -35,22 +35,22 @@ Bug #40833 (Crash when using unset() on an ArrayAccess object retrieved via __ge $this->entity->whatever = null; } - function offsetUnset($offset) + function offsetUnset($offset): void { $this->clear(); // $this->entity->{$this->name} = null; } - function offsetSet($offset, $value) + function offsetSet($offset, $value): void { } - function offsetGet($offset) + function offsetGet($offset): mixed { return 'Bogus '; } - function offsetExists($offset) + function offsetExists($offset): bool { } } diff --git a/Zend/tests/bug41209.phpt b/Zend/tests/bug41209.phpt index 441a9fc0b62e3..1a7ee8aa515c0 100644 --- a/Zend/tests/bug41209.phpt +++ b/Zend/tests/bug41209.phpt @@ -20,13 +20,13 @@ class cache implements ArrayAccess { private $container = array(); - public function offsetGet($id) {} + public function offsetGet($id): mixed {} - public function offsetSet($id, $value) {} + public function offsetSet($id, $value): void {} - public function offsetUnset($id) {} + public function offsetUnset($id): void {} - public function offsetExists($id) + public function offsetExists($id): bool { return isset($this->containers[(string) $id]); } diff --git a/Zend/tests/bug49269.phpt b/Zend/tests/bug49269.phpt index 2de29d8b93dc0..056c2a451fc7a 100644 --- a/Zend/tests/bug49269.phpt +++ b/Zend/tests/bug49269.phpt @@ -5,14 +5,14 @@ Bug #49269 (Ternary operator fails on Iterator object when used inside foreach d class TestObject implements Iterator { public $n = 0; - function valid() + function valid(): bool { return ($this->n < 3); } - function current() {return $this->n;} - function next() {$this->n++;} - function key() { } - function rewind() {$this->n = 0;} + function current(): mixed {return $this->n;} + function next(): void {$this->n++;} + function key(): mixed { } + function rewind(): void {$this->n = 0;} } diff --git a/Zend/tests/bug54367.phpt b/Zend/tests/bug54367.phpt index e926b8937ee6c..427255f65b8b2 100644 --- a/Zend/tests/bug54367.phpt +++ b/Zend/tests/bug54367.phpt @@ -4,11 +4,11 @@ Bug #54367 (Use of closure causes problem in ArrayAccess) container[] = $value; } else { $this->container[$offset] = $value; } } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->container[$offset]); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->container[$offset]); } - public function &offsetGet($offset) { + public function &offsetGet($offset): mixed { $result = null; if (isset($this->container[$offset])) { $result = &$this->container[$offset]; diff --git a/Zend/tests/bug68896.phpt b/Zend/tests/bug68896.phpt index b3b62a6ed00af..c983a2468a3b7 100644 --- a/Zend/tests/bug68896.phpt +++ b/Zend/tests/bug68896.phpt @@ -4,16 +4,16 @@ Bug #68896 (Changing ArrayObject value cause Segment Fault) a[$offset]; } - function offsetSet($offset, $value) { + function offsetSet($offset, $value): void { $this->a[$offset] = $value; } - function offsetExists($offset) { + function offsetExists($offset): bool { isset($this->a[$offset]); } - function offsetUnset($offset) { + function offsetUnset($offset): void { unset($this->a[$offset]); } } diff --git a/Zend/tests/bug69955.phpt b/Zend/tests/bug69955.phpt index 1c8340af2c9d8..b066b25f62d62 100644 --- a/Zend/tests/bug69955.phpt +++ b/Zend/tests/bug69955.phpt @@ -4,19 +4,19 @@ Bug #69955 (Segfault when trying to combine [] and assign-op on ArrayAccess obje bar; return $bar; } - public function offsetSet($key, $val) { + public function offsetSet($key, $val): void { } - public function offsetUnset($key) { + public function offsetUnset($key): void { } - public function offsetExists($key) { + public function offsetExists($key): bool { } } class bar { public $onBaz = []; } diff --git a/Zend/tests/bug71731.phpt b/Zend/tests/bug71731.phpt index 46a79f1a34ca3..2726755ff812d 100644 --- a/Zend/tests/bug71731.phpt +++ b/Zend/tests/bug71731.phpt @@ -5,22 +5,22 @@ Bug #71731: Null coalescing operator and ArrayAccess class AA implements ArrayAccess { private $data = []; - public function offsetExists($name) { + public function offsetExists($name): bool { echo "offsetExists($name)\n"; return array_key_exists($name, $this->data); } - public function &offsetGet($name) { + public function &offsetGet($name): mixed { echo "offsetGet($name)\n"; if (!array_key_exists($name, $this->data)) { throw new Exception('Unknown offset'); } return $this->data[$name]; } - public function offsetSet($name, $value) { + public function offsetSet($name, $value): void { echo "offsetSet($name)\n"; $this->data[$name] = $value; } - public function offsetUnset($name) { + public function offsetUnset($name): void { echo "offsetUnset($name)\n"; unset($this->data[$name]); } diff --git a/Zend/tests/bug75420.10.phpt b/Zend/tests/bug75420.10.phpt index 224a6494c96ec..e577279c9544e 100644 --- a/Zend/tests/bug75420.10.phpt +++ b/Zend/tests/bug75420.10.phpt @@ -3,10 +3,10 @@ Bug #75420.10 (Indirect modification of magic method argument) --FILE-- diff --git a/Zend/tests/dereference_005.phpt b/Zend/tests/dereference_005.phpt index 5dba2276e9d7e..7a1a36a24811e 100644 --- a/Zend/tests/dereference_005.phpt +++ b/Zend/tests/dereference_005.phpt @@ -14,16 +14,16 @@ class obj implements arrayaccess { "three" => 3, ); } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { $this->container[$offset] = $value; } - public function offsetExists($offset) { + public function offsetExists($offset): bool { return isset($this->container[$offset]); } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { unset($this->container[$offset]); } - public function offsetGet($offset) { + public function offsetGet($offset): mixed { return isset($this->container[$offset]) ? $this->container[$offset] : null; } } diff --git a/Zend/tests/enum/offsetGet-in-const-expr.phpt b/Zend/tests/enum/offsetGet-in-const-expr.phpt index e288b9a694f17..0928235ac2e8b 100644 --- a/Zend/tests/enum/offsetGet-in-const-expr.phpt +++ b/Zend/tests/enum/offsetGet-in-const-expr.phpt @@ -6,13 +6,13 @@ Enum offsetGet in constant expression enum Foo implements ArrayAccess { case Bar; - public function offsetGet($key) { + public function offsetGet($key): mixed { return 42; } - public function offsetExists($key) {} - public function offsetSet($key, $value) {} - public function offsetUnset($key) {} + public function offsetExists($key): bool {} + public function offsetSet($key, $value): void {} + public function offsetUnset($key): void {} } class X { diff --git a/Zend/tests/foreach_003.phpt b/Zend/tests/foreach_003.phpt index 95863e71bac41..3ecb96de79512 100644 --- a/Zend/tests/foreach_003.phpt +++ b/Zend/tests/foreach_003.phpt @@ -18,11 +18,11 @@ class IT implements Iterator { } } - function rewind() {$this->trap(__FUNCTION__); $this->n = 0;} - function valid() {$this->trap(__FUNCTION__); return $this->n < $this->count;} - function key() {$this->trap(__FUNCTION__); return $this->n;} - function current() {$this->trap(__FUNCTION__); return $this->n;} - function next() {$this->trap(__FUNCTION__); $this->n++;} + function rewind(): void {$this->trap(__FUNCTION__); $this->n = 0;} + function valid(): bool {$this->trap(__FUNCTION__); return $this->n < $this->count;} + function key(): mixed {$this->trap(__FUNCTION__); return $this->n;} + function current(): mixed {$this->trap(__FUNCTION__); return $this->n;} + function next(): void {$this->trap(__FUNCTION__); $this->n++;} } foreach(['rewind', 'valid', 'key', 'current', 'next'] as $trap) { diff --git a/Zend/tests/foreach_empty_loop_leak.phpt b/Zend/tests/foreach_empty_loop_leak.phpt index 70b391181b930..18045d8a75271 100644 --- a/Zend/tests/foreach_empty_loop_leak.phpt +++ b/Zend/tests/foreach_empty_loop_leak.phpt @@ -4,7 +4,7 @@ Empty foreach loops with exception must not leak data = $data; } - public function getIterator() { + public function getIterator(): Traversable { foreach ($this->data as $value) { yield $value; } diff --git a/Zend/tests/generators/generator_method_by_ref.phpt b/Zend/tests/generators/generator_method_by_ref.phpt index cfe52fe67ff82..782980653e532 100644 --- a/Zend/tests/generators/generator_method_by_ref.phpt +++ b/Zend/tests/generators/generator_method_by_ref.phpt @@ -14,7 +14,7 @@ class Test implements IteratorAggregate { return $this->data; } - public function &getIterator() { + public function &getIterator(): Traversable { foreach ($this->data as $key => &$value) { yield $key => $value; } diff --git a/Zend/tests/generators/yield_from_iterator_agregate.phpt b/Zend/tests/generators/yield_from_iterator_agregate.phpt index 3bd61e0b5a72a..2f8e6e1133f51 100644 --- a/Zend/tests/generators/yield_from_iterator_agregate.phpt +++ b/Zend/tests/generators/yield_from_iterator_agregate.phpt @@ -4,7 +4,7 @@ yield from with an IteratorAggregate prop); yield; } diff --git a/Zend/tests/generators/yield_from_valid_exception.phpt b/Zend/tests/generators/yield_from_valid_exception.phpt index d3e054bfafb9d..0df541499cae8 100644 --- a/Zend/tests/generators/yield_from_valid_exception.phpt +++ b/Zend/tests/generators/yield_from_valid_exception.phpt @@ -4,11 +4,11 @@ Exception from valid() during yield from s = $a; } - function offsetSet ($k, $v) { $this->s[$k] = $v; } - function offsetGet ($k) { return $this->s[$k]; } - function offsetExists ($k) { return isset($this->s[$k]); } - function offsetUnset ($k) { unset($this->s[$k]); } + function offsetSet ($k, $v): void { $this->s[$k] = $v; } + function offsetGet ($k): mixed { return $this->s[$k]; } + function offsetExists ($k): bool { return isset($this->s[$k]); } + function offsetUnset ($k): void { unset($this->s[$k]); } } $a = new StorageNoRef([1, 2]); diff --git a/Zend/tests/list/list_reference_007.phpt b/Zend/tests/list/list_reference_007.phpt index 225ebff10fe25..253d204736831 100644 --- a/Zend/tests/list/list_reference_007.phpt +++ b/Zend/tests/list/list_reference_007.phpt @@ -6,10 +6,10 @@ class StorageRef implements ArrayAccess { private $s = []; function __construct(array $a) { $this->s = $a; } - function offsetSet ($k, $v) { $this->s[$k] = $v; } - function &offsetGet ($k) { return $this->s[$k]; } - function offsetExists ($k) { return isset($this->s[$k]); } - function offsetUnset ($k) { unset($this->s[$k]); } + function offsetSet ($k, $v): void { $this->s[$k] = $v; } + function &offsetGet ($k): mixed { return $this->s[$k]; } + function offsetExists ($k): bool { return isset($this->s[$k]); } + function offsetUnset ($k): void { unset($this->s[$k]); } } $a = new StorageRef([1, 2]); diff --git a/Zend/tests/list_destructuring_to_special_variables.phpt b/Zend/tests/list_destructuring_to_special_variables.phpt index 4418c967c22c6..93b0980b32b53 100644 --- a/Zend/tests/list_destructuring_to_special_variables.phpt +++ b/Zend/tests/list_destructuring_to_special_variables.phpt @@ -12,12 +12,12 @@ class Obj { class Arr implements ArrayAccess { public $values = []; - public function offsetSet($name, $value) { + public function offsetSet($name, $value): void { $this->values[$name] = $value; } - public function offsetGet($name) {} - public function offsetExists($name) {} - public function offsetUnset($name) {} + public function offsetGet($name): mixed {} + public function offsetExists($name): bool {} + public function offsetUnset($name): void {} } $str = 'ab'; diff --git a/Zend/tests/list_keyed_ArrayAccess.phpt b/Zend/tests/list_keyed_ArrayAccess.phpt index 1bb20130365d0..40f7fd0ce5ed8 100644 --- a/Zend/tests/list_keyed_ArrayAccess.phpt +++ b/Zend/tests/list_keyed_ArrayAccess.phpt @@ -25,15 +25,16 @@ echo PHP_EOL; class IndexPrinter implements ArrayAccess { - public function offsetGet($offset) { + public function offsetGet($offset): mixed { echo "GET "; var_dump($offset); + return null; } - public function offsetSet($offset, $value) { + public function offsetSet($offset, $value): void { } - public function offsetExists($offset) { + public function offsetExists($offset): bool { } - public function offsetUnset($offset) { + public function offsetUnset($offset): void { } } diff --git a/Zend/tests/list_keyed_evaluation_order.inc b/Zend/tests/list_keyed_evaluation_order.inc index 577a19a83803a..dc8e5e5e4ed04 100644 --- a/Zend/tests/list_keyed_evaluation_order.inc +++ b/Zend/tests/list_keyed_evaluation_order.inc @@ -32,7 +32,7 @@ class Indexable implements ArrayAccess echo "Offset $offset removed.", PHP_EOL; } - public function offsetGet($offset) { + public function offsetGet($offset): mixed { echo "Offset $offset retrieved.", PHP_EOL; return $this->array[$offset]; } diff --git a/Zend/tests/object_handlers.phpt b/Zend/tests/object_handlers.phpt index 5b45ac6956fb7..b344d6df5abca 100644 --- a/Zend/tests/object_handlers.phpt +++ b/Zend/tests/object_handlers.phpt @@ -19,16 +19,18 @@ class foo implements ArrayAccess { static function __callStatic($func, $args) { $GLOBALS["y"] = $func; } - function offsetGet($index) { + function offsetGet($index): mixed { $GLOBALS["y"] = $index; + return null; } - function offsetSet($index, $newval) { + function offsetSet($index, $newval): void { $GLOBALS["y"] = $index; } - function offsetExists($index) { + function offsetExists($index): bool { $GLOBALS["y"] = $index; + return true; } - function offsetUnset($index) { + function offsetUnset($index): void { $GLOBALS["y"] = $index; } } diff --git a/Zend/tests/objects_032.phpt b/Zend/tests/objects_032.phpt index b4312ac3f83fc..a6cde14e1e7c4 100644 --- a/Zend/tests/objects_032.phpt +++ b/Zend/tests/objects_032.phpt @@ -6,15 +6,15 @@ Covariant return-by-ref constraints class A implements ArrayAccess { public $foo = array(); - public function &offsetGet($n) { + public function &offsetGet($n): mixed { return $this->foo[$n]; } - public function offsetSet($n, $v) { + public function offsetSet($n, $v): void { } - public function offsetUnset($n) { + public function offsetUnset($n): void { } - public function offsetExists($n) { + public function offsetExists($n): bool { } } diff --git a/Zend/tests/temporary_cleaning_013.phpt b/Zend/tests/temporary_cleaning_013.phpt index 401edb512b97e..ce121d03e884d 100644 --- a/Zend/tests/temporary_cleaning_013.phpt +++ b/Zend/tests/temporary_cleaning_013.phpt @@ -52,10 +52,10 @@ try { try { $foo = new class implements ArrayAccess { - function offsetGet($x) { return [0]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed { return [0]; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} }; var_dump($foo[0] += [new class { function __destruct() { throw new Exception; } @@ -65,10 +65,10 @@ try { try { $foo = new class implements ArrayAccess { public $foo = [0]; - function &offsetGet($x) { return $this->foo; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function &offsetGet($x): bool { return $this->foo; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} }; var_dump($foo[0] += [new class { function __destruct() { throw new Exception; } @@ -123,20 +123,20 @@ try { try { var_dump((function() { return new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed { return [new stdClass]; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} function __destruct() { throw new Exception; } }; })()[0]++); } catch (Exception $e) { print "caught Exception 15\n"; } try { var_dump(++(function() { return new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed { return [new stdClass]; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} function __destruct() { throw new Exception; } }; })()[0]); } catch (Exception $e) { print "caught Exception 16\n"; } @@ -158,10 +158,10 @@ try { try { var_dump((new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed { return [new stdClass]; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} function __destruct() { throw new Exception; } })[0]); } catch (Exception $e) { print "caught Exception 19\n"; } @@ -183,10 +183,10 @@ try { try { var_dump(isset((new class implements ArrayAccess { - function offsetGet($x) { return [new stdClass]; } - function offsetSet($x, $y) {} - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed { return [new stdClass]; } + function offsetSet($x, $y): void {} + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} function __destruct() { throw new Exception; } })[0]->bar)); } catch (Exception $e) { print "caught Exception 22\n"; } @@ -222,10 +222,10 @@ try { try { $foo = new class implements ArrayAccess { - function offsetGet($x) {} - function offsetSet($x, $y) { throw new Exception; } - function offsetExists($x) { return true; } - function offsetUnset($x) {} + function offsetGet($x): mixed {} + function offsetSet($x, $y): void { throw new Exception; } + function offsetExists($x): bool { return true; } + function offsetUnset($x): void {} }; var_dump($foo[0] = new stdClass); } catch (Exception $e) { print "caught Exception 27\n"; } diff --git a/Zend/tests/tentative_type_early_binding.phpt b/Zend/tests/tentative_type_early_binding.phpt index cc26e7d93b71c..ca9c9646adaa1 100644 --- a/Zend/tests/tentative_type_early_binding.phpt +++ b/Zend/tests/tentative_type_early_binding.phpt @@ -3,7 +3,7 @@ Check that both warning and unresolved during early binding is handled --FILE-- diff --git a/Zend/tests/type_declarations/typed_properties_065.phpt b/Zend/tests/type_declarations/typed_properties_065.phpt index 7a1dd54894b34..a3a536da07e1c 100644 --- a/Zend/tests/type_declarations/typed_properties_065.phpt +++ b/Zend/tests/type_declarations/typed_properties_065.phpt @@ -6,10 +6,10 @@ Typed property on by-ref array dimension $a = new class implements ArrayAccess { public int $foo = 1; - function offsetExists($o) { return 1; } - function &offsetGet($o) { return $this->foo; } - function offsetSet($o, $v) { print "offsetSet($v)\n"; } - function offsetUnset($o) { print "offsetUnset() ?!?"; } + function offsetExists($o): bool { return 1; } + function &offsetGet($o): mixed { return $this->foo; } + function offsetSet($o, $v): void { print "offsetSet($v)\n"; } + function offsetUnset($o): void { print "offsetUnset() ?!?"; } }; $a[0] += 1; diff --git a/Zend/zend_exceptions.stub.php b/Zend/zend_exceptions.stub.php index be00b6b65dbea..9dce0fbe808f2 100644 --- a/Zend/zend_exceptions.stub.php +++ b/Zend/zend_exceptions.stub.php @@ -92,10 +92,10 @@ private function __clone(): void {} public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) {} /** - * @return void + * @tentative-return-type * @implementation-alias Exception::__wakeup */ - public function __wakeup() {} + public function __wakeup(): void {} /** @implementation-alias Exception::getMessage */ final public function getMessage(): string {} diff --git a/Zend/zend_exceptions_arginfo.h b/Zend/zend_exceptions_arginfo.h index 4779d698e1980..ddc80db22b5a1 100644 --- a/Zend/zend_exceptions_arginfo.h +++ b/Zend/zend_exceptions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9a9ce2975a7449a621d364beca646525fc56b294 */ + * Stub hash: e77ba21c194c4c6b47cdabc8766fb5f37179d155 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getMessage, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -62,7 +62,8 @@ ZEND_END_ARG_INFO() #define arginfo_class_Error___construct arginfo_class_Exception___construct -#define arginfo_class_Error___wakeup arginfo_class_Throwable_getCode +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Error___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() #define arginfo_class_Error_getMessage arginfo_class_Throwable_getMessage diff --git a/Zend/zend_interfaces.stub.php b/Zend/zend_interfaces.stub.php index d1bd4a5037a2d..2ed83610ef749 100644 --- a/Zend/zend_interfaces.stub.php +++ b/Zend/zend_interfaces.stub.php @@ -6,44 +6,44 @@ interface Traversable {} interface IteratorAggregate extends Traversable { - /** @return Traversable */ - public function getIterator(); + /** @tentative-return-type */ + public function getIterator(): Traversable; } interface Iterator extends Traversable { /** @return mixed */ - public function current(); + public function current(); // TODO Can't add tentative return tyoe due to DirectoryIterator::current() - /** @return void */ - public function next(); + /** @tentative-return-type */ + public function next(): void; /** @return mixed */ - public function key(); + public function key(); // TODO Can't add tentative return tyoe due to DirectoryIterator::key() - /** @return bool */ - public function valid(); + /** @tentative-return-type */ + public function valid(): bool; - /** @return void */ - public function rewind(); + /** @tentative-return-type */ + public function rewind(): void; } interface ArrayAccess { - /** @return bool */ - public function offsetExists(mixed $offset); + /** @tentative-return-type */ + public function offsetExists(mixed $offset): bool; /** * Actually this should be return by ref but atm cannot be. - * @return mixed + * @tentative-return-type */ - public function offsetGet(mixed $offset); + public function offsetGet(mixed $offset): mixed; - /** @return void */ - public function offsetSet(mixed $offset, mixed $value); + /** @tentative-return-type */ + public function offsetSet(mixed $offset, mixed $value): void; /** @return void */ - public function offsetUnset(mixed $offset); + public function offsetUnset(mixed $offset); // TODO Can't add tentative return type due to Phar::offsetUnset } interface Serializable @@ -58,7 +58,7 @@ public function unserialize(string $data); interface Countable { /** @return int */ - public function count(); + public function count(); // TODO Can't add tentatie return type due to DOMNodeList::count() and DOMNamedNodeMap::count() } interface Stringable @@ -68,17 +68,15 @@ public function __toString(): string; final class InternalIterator implements Iterator { - private function __construct(); + private function __construct() {} - /** @return mixed */ - public function current(); + public function current(): mixed {} - /** @return mixed */ - public function key(); + public function key(): mixed {} - public function next(): void; + public function next(): void {} - public function valid(): bool; + public function valid(): bool {} - public function rewind(): void; + public function rewind(): void {} } diff --git a/Zend/zend_interfaces_arginfo.h b/Zend/zend_interfaces_arginfo.h index c34f5463a0170..84812656053e1 100644 --- a/Zend/zend_interfaces_arginfo.h +++ b/Zend/zend_interfaces_arginfo.h @@ -1,48 +1,56 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 34aa50c74f10106c6abd0ed2956d41c98aae6452 */ + * Stub hash: 29ecd0161c7f7521f2f149e438182c247e658bb2 */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, 0) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, Traversable, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Iterator_current arginfo_class_IteratorAggregate_getIterator +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Iterator_current, 0, 0, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_Iterator_next arginfo_class_IteratorAggregate_getIterator +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_next, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_Iterator_key arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_Iterator_key arginfo_class_Iterator_current -#define arginfo_class_Iterator_valid arginfo_class_IteratorAggregate_getIterator +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_valid, 0, 0, _IS_BOOL, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_Iterator_rewind arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_Iterator_rewind arginfo_class_Iterator_next -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayAccess_offsetExists, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetExists, 0, 1, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0) ZEND_END_ARG_INFO() -#define arginfo_class_ArrayAccess_offsetGet arginfo_class_ArrayAccess_offsetExists +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetGet, 0, 1, IS_MIXED, 0) + ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0) +ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayAccess_offsetSet, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetSet, 0, 2, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0) ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() -#define arginfo_class_ArrayAccess_offsetUnset arginfo_class_ArrayAccess_offsetExists +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayAccess_offsetUnset, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_Serializable_serialize arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_Serializable_serialize arginfo_class_Iterator_current ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_unserialize, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Countable_count arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_Countable_count arginfo_class_Iterator_current ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Stringable___toString, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_InternalIterator___construct arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_InternalIterator___construct arginfo_class_Iterator_current -#define arginfo_class_InternalIterator_current arginfo_class_IteratorAggregate_getIterator +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_current, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_InternalIterator_key arginfo_class_IteratorAggregate_getIterator +#define arginfo_class_InternalIterator_key arginfo_class_InternalIterator_current ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_next, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() diff --git a/Zend/zend_weakrefs.stub.php b/Zend/zend_weakrefs.stub.php index e8c0c3c92d46c..85c8126a683a7 100644 --- a/Zend/zend_weakrefs.stub.php +++ b/Zend/zend_weakrefs.stub.php @@ -15,9 +15,7 @@ public function get(): ?object {} /** @strict-properties */ final class WeakMap implements ArrayAccess, Countable, IteratorAggregate { - /** - * @param object $object - */ + /** @param object $object */ public function offsetGet($object): mixed {} /** @param object $object */ diff --git a/Zend/zend_weakrefs_arginfo.h b/Zend/zend_weakrefs_arginfo.h index d737faebe5a5b..5d1fc0191f6c7 100644 --- a/Zend/zend_weakrefs_arginfo.h +++ b/Zend/zend_weakrefs_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 97fff017125955a3def85d9ed5a31746de7b808a */ + * Stub hash: c849da0cac9ed05fedacf10ef57449a4596b3c07 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_WeakReference___construct, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/opcache/tests/bug77275.phpt b/ext/opcache/tests/bug77275.phpt index 41c3a549b2fea..bef5b9e4956c7 100644 --- a/ext/opcache/tests/bug77275.phpt +++ b/ext/opcache/tests/bug77275.phpt @@ -10,10 +10,10 @@ opcache namespace Foo; class Bar { public function get() {} } class Record implements \ArrayAccess { - public function offsetSet($offset, $value) { throw new \Exception; } - public function offsetGet($offset) { var_dump($offset); } - public function offsetExists($offset) { throw new \Exception; } - public function offsetUnset($offset) { throw new \Exception; } + public function offsetSet($offset, $value): void { throw new \Exception; } + public function offsetGet($offset): mixed { var_dump($offset); } + public function offsetExists($offset): bool { throw new \Exception; } + public function offsetUnset($offset): void { throw new \Exception; } } class Baz { public function run() { diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt index 686e810a04095..d60cdf9ed97d3 100644 --- a/ext/phar/tests/bug45218_SLOWTEST.phpt +++ b/ext/phar/tests/bug45218_SLOWTEST.phpt @@ -19,22 +19,22 @@ class myIterator implements Iterator var $a; var $count = 1; - function next() { + function next(): void { return (++$this->count < 3000) ? 'f' . $this->count : false; } - function current() { + function current(): mixed { if (($this->count % 100) === 0) { echo $this->count, "\n"; } return $GLOBALS['fname2']; } - function key() { + function key(): mixed { return 'f' . $this->count; } - function valid() { + function valid(): bool { return $this->count < 3000; } - function rewind() { + function rewind(): void { $this->count = 1; return $GLOBALS['fname2']; } diff --git a/ext/phar/tests/phar_buildfromiterator4.phpt b/ext/phar/tests/phar_buildfromiterator4.phpt index 025931e07ee0b..fe4ce8dc7908b 100644 --- a/ext/phar/tests/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/phar_buildfromiterator4.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt index 041e764056750..9ea3fa1bca870 100644 --- a/ext/phar/tests/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/phar_buildfromiterator5.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt index b7ad1a22da540..6bb99c9f816ed 100644 --- a/ext/phar/tests/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/phar_buildfromiterator6.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/phar_buildfromiterator7.phpt b/ext/phar/tests/phar_buildfromiterator7.phpt index a785c8b30cfe8..4088e54837cbc 100644 --- a/ext/phar/tests/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/phar_buildfromiterator7.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/phar_buildfromiterator9.phpt b/ext/phar/tests/phar_buildfromiterator9.phpt index 488e2eabd73f2..7f1ec5e780c34 100644 --- a/ext/phar/tests/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/phar_buildfromiterator9.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/tar/phar_buildfromiterator4.phpt b/ext/phar/tests/tar/phar_buildfromiterator4.phpt index 0ad70d85947d7..35d18400ddc9b 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator4.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt index eaba2186039c0..19d79dce85960 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/tar/phar_buildfromiterator6.phpt b/ext/phar/tests/tar/phar_buildfromiterator6.phpt index 9bfb57c7cf703..cd567685af816 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator6.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/tar/phar_buildfromiterator7.phpt b/ext/phar/tests/tar/phar_buildfromiterator7.phpt index 072a719b4923a..ca864e887a8ed 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator7.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/tar/phar_buildfromiterator9.phpt b/ext/phar/tests/tar/phar_buildfromiterator9.phpt index 58d4f4f31aacc..e2f3e901b932b 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator9.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/zip/phar_buildfromiterator4.phpt b/ext/phar/tests/zip/phar_buildfromiterator4.phpt index 04982638ba34f..8dbeede3c0a2b 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator4.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt index 235517c871af8..5b73b752d62b6 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/zip/phar_buildfromiterator6.phpt b/ext/phar/tests/zip/phar_buildfromiterator6.phpt index 9587fbaa1e46e..67e3eb633c25b 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator6.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/zip/phar_buildfromiterator7.phpt b/ext/phar/tests/zip/phar_buildfromiterator7.phpt index 76eadf6eff6e7..46736603e2c82 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator7.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/phar/tests/zip/phar_buildfromiterator9.phpt b/ext/phar/tests/zip/phar_buildfromiterator9.phpt index 546caee7a2508..273c614370cdb 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator9.phpt @@ -14,23 +14,23 @@ class myIterator implements Iterator { $this->a = $a; } - function next() { + function next(): void { echo "next\n"; return next($this->a); } - function current() { + function current(): mixed { echo "current\n"; return current($this->a); } - function key() { + function key(): mixed { echo "key\n"; return key($this->a); } - function valid() { + function valid(): bool { echo "valid\n"; return current($this->a); } - function rewind() { + function rewind(): void { echo "rewind\n"; return reset($this->a); } diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt index 10fa07fc06e36..3b7341078fe15 100644 --- a/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt +++ b/ext/reflection/tests/ReflectionClass_isIterateable_001.phpt @@ -10,14 +10,14 @@ Interface ExtendsIterator extends Iterator { Interface ExtendsIteratorAggregate extends IteratorAggregate { } Class IteratorImpl implements Iterator { - public function next() {} - public function key() {} - public function rewind() {} - public function current() {} - public function valid() {} + public function next(): void {} + public function key(): mixed {} + public function rewind(): void {} + public function current(): mixed {} + public function valid(): bool {} } Class IteratorAggregateImpl implements IteratorAggregate { - public function getIterator() {} + public function getIterator(): Traversable {} } Class ExtendsIteratorImpl extends IteratorImpl { } diff --git a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt index f11433eced364..2c0991ce6457a 100644 --- a/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt +++ b/ext/reflection/tests/ReflectionClass_isIterateable_basic.phpt @@ -7,11 +7,11 @@ Felix De Vliegher , Marc Veldman a = $a; } - public function rewind() { return reset($this->a); } - public function current() { return current($this->a); } - public function key() { return key($this->a); } - public function next() { return next($this->a); } - public function valid() { return (current($this->a) !== false); } + public function rewind(): void { return reset($this->a); } + public function current(): mixed { return current($this->a); } + public function key(): mixed { return key($this->a); } + public function next(): void { return next($this->a); } + public function valid(): bool { return (current($this->a) !== false); } } class Item { diff --git a/ext/spl/tests/RecursiveIteratorIterator_invalid_aggregate.phpt b/ext/spl/tests/RecursiveIteratorIterator_invalid_aggregate.phpt index 2d29149dd4bf4..e877de6ae024b 100644 --- a/ext/spl/tests/RecursiveIteratorIterator_invalid_aggregate.phpt +++ b/ext/spl/tests/RecursiveIteratorIterator_invalid_aggregate.phpt @@ -4,6 +4,7 @@ RecursiveIteratorIterator constructor should thrown if IteratorAggregate does no students->getIterator(); } } diff --git a/ext/spl/tests/array_007.phpt b/ext/spl/tests/array_007.phpt index 13d841792c91c..dc8a9a5bad73c 100644 --- a/ext/spl/tests/array_007.phpt +++ b/ext/spl/tests/array_007.phpt @@ -18,7 +18,7 @@ class test implements IteratorAggregate $this->imp = "implicit"; } - function getIterator() + function getIterator(): Traversable { $it = new ArrayObject($this); return $it->getIterator(); diff --git a/ext/spl/tests/bug52238.phpt b/ext/spl/tests/bug52238.phpt index 53e53e9729631..e940df0e757ff 100644 --- a/ext/spl/tests/bug52238.phpt +++ b/ext/spl/tests/bug52238.phpt @@ -8,7 +8,7 @@ class Foo implements IteratorAggregate throw new Exception; } - public function getIterator() { + public function getIterator(): Traversable { return new ArrayIterator($this->bar()); } } diff --git a/ext/spl/tests/bug65328.phpt b/ext/spl/tests/bug65328.phpt index 5d2499c1144ad..518418654f4b8 100644 --- a/ext/spl/tests/bug65328.phpt +++ b/ext/spl/tests/bug65328.phpt @@ -65,7 +65,7 @@ class Tree /** * @return \RecursiveIteratorIterator */ - public function getIterator() + public function getIterator(): Traversable { return new \RecursiveIteratorIterator( $this->head->getChildren(), diff --git a/ext/spl/tests/dualiterator.inc b/ext/spl/tests/dualiterator.inc index a2c55b8bdda11..ca11f89cc88b4 100644 --- a/ext/spl/tests/dualiterator.inc +++ b/ext/spl/tests/dualiterator.inc @@ -83,14 +83,14 @@ class DualIterator implements Iterator /** @return whether both inner iterators are valid */ - function valid() + function valid(): bool { return $this->lhs->valid() && $this->rhs->valid(); } /** @return current value depending on CURRENT_* flags */ - function current() + function current(): mixed { switch($this->flags & 0x0F) { @@ -108,7 +108,7 @@ class DualIterator implements Iterator /** @return key value depending on KEY_* flags */ - function key() + function key(): mixed { switch($this->flags & 0xF0) { @@ -124,7 +124,7 @@ class DualIterator implements Iterator /** move both inner iterators forward */ - function next() + function next(): void { $this->lhs->next(); $this->rhs->next(); diff --git a/ext/spl/tests/iterator_003.phpt b/ext/spl/tests/iterator_003.phpt index dfb44b94f9b5d..d8437257e1b55 100644 --- a/ext/spl/tests/iterator_003.phpt +++ b/ext/spl/tests/iterator_003.phpt @@ -69,7 +69,7 @@ class StudentList implements IteratorAggregate return false; } - public function getIterator() { + public function getIterator(): Traversable { return new CachingIterator($this->students->getIterator(), true); } } diff --git a/ext/spl/tests/recursive_tree_iterator_006.phpt b/ext/spl/tests/recursive_tree_iterator_006.phpt index ba71586396076..e7af6e7ff7b87 100644 --- a/ext/spl/tests/recursive_tree_iterator_006.phpt +++ b/ext/spl/tests/recursive_tree_iterator_006.phpt @@ -27,7 +27,7 @@ class RecursiveArrayIteratorAggregated implements IteratorAggregate { function __construct($it) { $this->it = new RecursiveArrayIterator($it); } - function getIterator() { + function getIterator(): Traversable { return $this->it; } } diff --git a/ext/spl/tests/recursive_tree_iterator_007.phpt b/ext/spl/tests/recursive_tree_iterator_007.phpt index 196f6a1d90d13..2907f39f26575 100644 --- a/ext/spl/tests/recursive_tree_iterator_007.phpt +++ b/ext/spl/tests/recursive_tree_iterator_007.phpt @@ -12,7 +12,7 @@ class RecursiveArrayIteratorAggregated implements IteratorAggregate { function __construct($it) { $this->it = new RecursiveArrayIterator($it); } - function getIterator() { + function getIterator(): Traversable { return $this->it; } } diff --git a/ext/spl/tests/regexiterator_getpregflags.phpt b/ext/spl/tests/regexiterator_getpregflags.phpt index 6dd7c068c7961..2fe492aebeb90 100644 --- a/ext/spl/tests/regexiterator_getpregflags.phpt +++ b/ext/spl/tests/regexiterator_getpregflags.phpt @@ -8,11 +8,11 @@ Lance Kesson jac_kesson@hotmail.com class myIterator implements Iterator { -function current (){} -function key ( ){} -function next ( ){} -function rewind ( ){} -function valid ( ){} +function current (): mixed { return null; } +function key ( ): mixed { return ""; } +function next ( ): void {} +function rewind ( ): void {} +function valid ( ): bool {} } diff --git a/ext/spl/tests/regexiterator_setpregflags.phpt b/ext/spl/tests/regexiterator_setpregflags.phpt index 7db7a63973e03..5b4d47ff91843 100644 --- a/ext/spl/tests/regexiterator_setpregflags.phpt +++ b/ext/spl/tests/regexiterator_setpregflags.phpt @@ -8,11 +8,11 @@ Lance Kesson jac_kesson@hotmail.com class myIterator implements Iterator { -function current (){} -function key ( ){} -function next ( ){} -function rewind ( ){} -function valid ( ){} +function current (): mixed{ return null;} +function key ( ): mixed{ return "";} +function next ( ): void{} +function rewind ( ): void{} +function valid ( ): bool{} } diff --git a/tests/classes/array_access_001.phpt b/tests/classes/array_access_001.phpt index 8e70b87f675e1..9498d3ce5576d 100644 --- a/tests/classes/array_access_001.phpt +++ b/tests/classes/array_access_001.phpt @@ -6,19 +6,19 @@ class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($index)\n"; return array_key_exists($index, $this->a); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($index)\n"; return $this->a[$index]; } - function offsetSet($index, $newval) { + function offsetSet($index, $newval): void { echo __METHOD__ . "($index,$newval)\n"; - return $this->a[$index] = $newval; + $this->a[$index] = $newval; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($index)\n"; unset($this->a[$index]); } diff --git a/tests/classes/array_access_002.phpt b/tests/classes/array_access_002.phpt index 7217eaf8ba100..6e6adacdc68ba 100644 --- a/tests/classes/array_access_002.phpt +++ b/tests/classes/array_access_002.phpt @@ -6,19 +6,19 @@ class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($index)\n"; return array_key_exists($index, $this->a); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($index)\n"; return $this->a[$index]; } - function offsetSet($index, $newval) { + function offsetSet($index, $newval): void { echo __METHOD__ . "($index,$newval)\n"; - /*return*/ $this->a[$index] = $newval; + $this->a[$index] = $newval; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($index)\n"; unset($this->a[$index]); } diff --git a/tests/classes/array_access_003.phpt b/tests/classes/array_access_003.phpt index b88707b5e8bfe..a4a44c295746f 100644 --- a/tests/classes/array_access_003.phpt +++ b/tests/classes/array_access_003.phpt @@ -8,11 +8,11 @@ class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($index)\n"; return array_key_exists($index, $this->a); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($index)\n"; switch($index) { case 1: @@ -24,14 +24,14 @@ class ObjectOne implements ArrayAccess { } return $this->a[$index]; } - function offsetSet($index, $newval) { + function offsetSet($index, $newval): void { echo __METHOD__ . "($index,$newval)\n"; if ($index==3) { $this->cnt = $newval; } - return $this->a[$index] = $newval; + $this->a[$index] = $newval; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($index)\n"; unset($this->a[$index]); } diff --git a/tests/classes/array_access_004.phpt b/tests/classes/array_access_004.phpt index ea67544c045a8..0e48e3e97fad8 100644 --- a/tests/classes/array_access_004.phpt +++ b/tests/classes/array_access_004.phpt @@ -6,11 +6,11 @@ class ObjectOne implements ArrayAccess { public $a = array('1st', 1, 2=>'3rd', '4th'=>4); - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($index)\n"; return array_key_exists($index, $this->a); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($index)\n"; switch($index) { case 1: @@ -22,14 +22,14 @@ class ObjectOne implements ArrayAccess { } return $this->a[$index]; } - function offsetSet($index, $newval) { + function offsetSet($index, $newval): void { echo __METHOD__ . "($index,$newval)\n"; if ($index==3) { $this->cnt = $newval; } - return $this->a[$index] = $newval; + $this->a[$index] = $newval; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($index)\n"; unset($this->a[$index]); } diff --git a/tests/classes/array_access_005.phpt b/tests/classes/array_access_005.phpt index 7db50f2cb9a4c..c32eb4e891e62 100644 --- a/tests/classes/array_access_005.phpt +++ b/tests/classes/array_access_005.phpt @@ -10,19 +10,19 @@ class Peoples implements ArrayAccess { $this->person = array(array('name'=>'Joe')); } - function offsetExists($index) { + function offsetExists($index): bool { return array_key_exists($this->person, $index); } - function offsetGet($index) { + function offsetGet($index): mixed { return $this->person[$index]; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { $this->person[$index] = $value; } - function offsetUnset($index) { + function offsetUnset($index): void { unset($this->person[$index]); } } diff --git a/tests/classes/array_access_006.phpt b/tests/classes/array_access_006.phpt index 7891d2aca470f..7bfdc642e2ae1 100644 --- a/tests/classes/array_access_006.phpt +++ b/tests/classes/array_access_006.phpt @@ -10,19 +10,19 @@ class OverloadedArray implements ArrayAccess { $this->realArray = array(1,2,3); } - function offsetExists($index) { + function offsetExists($index): bool { return array_key_exists($this->realArray, $index); } - function offsetGet($index) { + function offsetGet($index): mixed { return $this->realArray[$index]; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { $this->realArray[$index] = $value; } - function offsetUnset($index) { + function offsetUnset($index): void { unset($this->realArray[$index]); } } diff --git a/tests/classes/array_access_007.phpt b/tests/classes/array_access_007.phpt index 37a3255d6f822..7f2ae10ad6f6f 100644 --- a/tests/classes/array_access_007.phpt +++ b/tests/classes/array_access_007.phpt @@ -10,15 +10,15 @@ class OverloadedArray implements ArrayAccess { $this->realArray = array(); } - function offsetExists($index) { + function offsetExists($index): bool { return array_key_exists($this->realArray, $index); } - function offsetGet($index) { + function offsetGet($index): mixed { return $this->realArray[$index]; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { if (is_null($index)) { $this->realArray[] = $value; } else { @@ -26,7 +26,7 @@ class OverloadedArray implements ArrayAccess { } } - function offsetUnset($index) { + function offsetUnset($index): void { unset($this->realArray[$index]); } diff --git a/tests/classes/array_access_008.phpt b/tests/classes/array_access_008.phpt index a6f485eb79038..97f717fe08b7d 100644 --- a/tests/classes/array_access_008.phpt +++ b/tests/classes/array_access_008.phpt @@ -10,19 +10,19 @@ class Peoples implements ArrayAccess { $this->person = array(array('name'=>'Foo')); } - function offsetExists($index) { + function offsetExists($index): bool { return array_key_exists($this->person, $index); } - function offsetGet($index) { + function offsetGet($index): mixed { return $this->person[$index]; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { $this->person[$index] = $value; } - function offsetUnset($index) { + function offsetUnset($index): void { unset($this->person[$index]); } } diff --git a/tests/classes/array_access_009.phpt b/tests/classes/array_access_009.phpt index a4aeaea56a090..94d2ea60357dd 100644 --- a/tests/classes/array_access_009.phpt +++ b/tests/classes/array_access_009.phpt @@ -28,23 +28,23 @@ class ArrayProxy implements ArrayAccess $this->element = $element; } - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($this->element, $index)\n"; return array_key_exists($index, $this->object->proxyGet($this->element)); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($this->element, $index)\n"; $tmp = $this->object->proxyGet($this->element); return isset($tmp[$index]) ? $tmp[$index] : NULL; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { echo __METHOD__ . "($this->element, $index, $value)\n"; $this->object->proxySet($this->element, $index, $value); } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($this->element, $index)\n"; $this->object->proxyUnset($this->element, $index); } @@ -59,22 +59,22 @@ class Peoples implements ArrayProxyAccess $this->person = array(array('name'=>'Foo')); } - function offsetExists($index) + function offsetExists($index): bool { return array_key_exists($index, $this->person); } - function offsetGet($index) + function offsetGet($index): mixed { return new ArrayProxy($this, $index); } - function offsetSet($index, $value) + function offsetSet($index, $value): void { $this->person[$index] = $value; } - function offsetUnset($index) + function offsetUnset($index): void { unset($this->person[$index]); } diff --git a/tests/classes/array_access_010.phpt b/tests/classes/array_access_010.phpt index f91096c713cac..a4dde98e7431f 100644 --- a/tests/classes/array_access_010.phpt +++ b/tests/classes/array_access_010.phpt @@ -17,22 +17,22 @@ class ArrayReferenceProxy implements ArrayAccess $this->element = &$element; } - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($this->element, $index)\n"; return array_key_exists($index, $this->element); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "(Array, $index)\n"; return isset($this->element[$index]) ? $this->element[$index] : NULL; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { echo __METHOD__ . "(Array, $index, $value)\n"; $this->element[$index] = $value; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "(Array, $index)\n"; unset($this->element[$index]); } @@ -47,22 +47,22 @@ class Peoples implements ArrayAccess $this->person = array(array('name'=>'Foo')); } - function offsetExists($index) + function offsetExists($index): bool { return array_key_exists($index, $this->person); } - function offsetGet($index) + function offsetGet($index): mixed { return new ArrayReferenceProxy($this, $this->person[$index]); } - function offsetSet($index, $value) + function offsetSet($index, $value): void { $this->person[$index] = $value; } - function offsetUnset($index) + function offsetUnset($index): void { unset($this->person[$index]); } diff --git a/tests/classes/array_access_011.phpt b/tests/classes/array_access_011.phpt index 3250d64deb2e3..ca0bbd9f1d8b7 100644 --- a/tests/classes/array_access_011.phpt +++ b/tests/classes/array_access_011.phpt @@ -19,22 +19,22 @@ class ArrayAccessReferenceProxy implements ArrayAccess $this->element = $element; } - function offsetExists($index) { + function offsetExists($index): bool { echo __METHOD__ . "($this->element, $index)\n"; return array_key_exists($index, $this->oarray[$this->element]); } - function offsetGet($index) { + function offsetGet($index): mixed { echo __METHOD__ . "($this->element, $index)\n"; return isset($this->oarray[$this->element][$index]) ? $this->oarray[$this->element][$index] : NULL; } - function offsetSet($index, $value) { + function offsetSet($index, $value): void { echo __METHOD__ . "($this->element, $index, $value)\n"; $this->oarray[$this->element][$index] = $value; } - function offsetUnset($index) { + function offsetUnset($index): void { echo __METHOD__ . "($this->element, $index)\n"; unset($this->oarray[$this->element][$index]); } @@ -49,12 +49,12 @@ class Peoples implements ArrayAccess $this->person = array(array('name'=>'Foo')); } - function offsetExists($index) + function offsetExists($index): bool { return array_key_exists($index, $this->person); } - function offsetGet($index) + function offsetGet($index): mixed { if (is_array($this->person[$index])) { @@ -66,12 +66,12 @@ class Peoples implements ArrayAccess } } - function offsetSet($index, $value) + function offsetSet($index, $value): void { $this->person[$index] = $value; } - function offsetUnset($index) + function offsetUnset($index): void { unset($this->person[$index]); } diff --git a/tests/classes/array_access_012.phpt b/tests/classes/array_access_012.phpt index e2fba54781c23..c8788ae3e538c 100644 --- a/tests/classes/array_access_012.phpt +++ b/tests/classes/array_access_012.phpt @@ -6,17 +6,17 @@ ZE2 ArrayAccess cannot assign by reference class ArrayAccessImpl implements ArrayAccess { private $data = array(); - public function offsetUnset($index) {} + public function offsetUnset($index): void {} - public function offsetSet($index, $value) { + public function offsetSet($index, $value): void { $this->data[$index] = $value; } - public function offsetGet($index) { + public function offsetGet($index): mixed { return $this->data[$index]; } - public function offsetExists($index) { + public function offsetExists($index): bool { return isset($this->data[$index]); } } diff --git a/tests/classes/array_access_013.phpt b/tests/classes/array_access_013.phpt index bcb6a5e00bb5e..22e1cb2d3fa3a 100644 --- a/tests/classes/array_access_013.phpt +++ b/tests/classes/array_access_013.phpt @@ -5,10 +5,10 @@ ZE2 ArrayAccess and exceptions class Test implements ArrayAccess { - public function offsetExists($offset) { throw new Exception(__METHOD__); return false; } - public function offsetGet($offset) { throw new Exception(__METHOD__); return $offset; } - public function offsetSet($offset, $data ) { throw new Exception(__METHOD__); } - public function offsetUnset($offset) { throw new Exception(__METHOD__); } + public function offsetExists($offset): bool { throw new Exception(__METHOD__); return false; } + public function offsetGet($offset): mixed { throw new Exception(__METHOD__); return $offset; } + public function offsetSet($offset, $data ): void { throw new Exception(__METHOD__); } + public function offsetUnset($offset): void { throw new Exception(__METHOD__); } } $t = new Test; diff --git a/tests/classes/iterators_001.phpt b/tests/classes/iterators_001.phpt index 17588bc8cdc5f..c51434d0fc3e5 100644 --- a/tests/classes/iterators_001.phpt +++ b/tests/classes/iterators_001.phpt @@ -12,22 +12,22 @@ class c_iter implements Iterator { $this->num = 0; $this->obj = $obj; } - function rewind() { + function rewind(): void { } - function valid() { + function valid(): bool { $more = $this->num < $this->obj->max; echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; return $more; } - function current() { + function current(): mixed { echo __METHOD__ . "\n"; return $this->num; } - function next() { + function next(): void { echo __METHOD__ . "\n"; $this->num++; } - function key() { + function key(): mixed { echo __METHOD__ . "\n"; switch($this->num) { case 0: return "1st"; @@ -42,7 +42,7 @@ class c implements IteratorAggregate { public $max = 3; - function getIterator() { + function getIterator(): Traversable { echo __METHOD__ . "\n"; return new c_iter($this); } diff --git a/tests/classes/iterators_002.phpt b/tests/classes/iterators_002.phpt index 4035f7c4f40b2..71f252dc0edea 100644 --- a/tests/classes/iterators_002.phpt +++ b/tests/classes/iterators_002.phpt @@ -11,24 +11,24 @@ class c_iter implements Iterator { echo __METHOD__ . "\n"; $this->obj = $obj; } - function rewind() { + function rewind(): void { echo __METHOD__ . "\n"; $this->num = 0; } - function valid() { + function valid(): bool { $more = $this->num < $this->obj->max; echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; return $more; } - function current() { + function current(): mixed { echo __METHOD__ . "\n"; return $this->num; } - function next() { + function next(): void { echo __METHOD__ . "\n"; $this->num++; } - function key() { + function key(): mixed { echo __METHOD__ . "\n"; switch($this->num) { case 0: return "1st"; @@ -46,7 +46,7 @@ class c implements IteratorAggregate { public $max = 3; - function getIterator() { + function getIterator(): Traversable { echo __METHOD__ . "\n"; return new c_iter($this); } diff --git a/tests/classes/iterators_003.phpt b/tests/classes/iterators_003.phpt index 5557402d8dbc5..3a60785b09b53 100644 --- a/tests/classes/iterators_003.phpt +++ b/tests/classes/iterators_003.phpt @@ -11,23 +11,23 @@ class c_iter implements Iterator { echo __METHOD__ . "\n"; $this->obj = $obj; } - function rewind() { + function rewind(): void { echo __METHOD__ . "\n"; } - function valid() { + function valid(): bool { $more = $this->num < $this->obj->max; echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; return $more; } - function current() { + function current(): mixed { echo __METHOD__ . "\n"; return $this->num; } - function next() { + function next(): void { echo __METHOD__ . "\n"; $this->num++; } - function key() { + function key(): mixed { return $this->num; } } @@ -36,7 +36,7 @@ class c implements IteratorAggregate { public $max = 4; - function getIterator() { + function getIterator(): Traversable { echo __METHOD__ . "\n"; return new c_iter($this); } diff --git a/tests/classes/iterators_004.phpt b/tests/classes/iterators_004.phpt index 77d036a07506e..aa9584cb8925d 100644 --- a/tests/classes/iterators_004.phpt +++ b/tests/classes/iterators_004.phpt @@ -24,15 +24,15 @@ class c2 { echo __METHOD__ . "\n"; return $this->num; } - function next() { + function next(): void { echo __METHOD__ . "\n"; $this->num++; } - function valid() { + function valid(): bool { echo __METHOD__ . "\n"; return $this->num < $this->max; } - function key() { + function key(): mixed { echo __METHOD__ . "\n"; switch($this->num) { case 0: return "1st"; diff --git a/tests/classes/iterators_006.phpt b/tests/classes/iterators_006.phpt index 8bc85167230ec..86c2481b50abd 100644 --- a/tests/classes/iterators_006.phpt +++ b/tests/classes/iterators_006.phpt @@ -11,24 +11,24 @@ class ai implements Iterator { $this->array = array('foo', 'bar', 'baz'); } - function rewind() { + function rewind(): void { reset($this->array); $this->next(); } - function valid() { + function valid(): bool { return $this->key !== NULL; } - function key() { + function key(): mixed { return $this->key; } - function current() { + function current(): mixed { return $this->current; } - function next() { + function next(): void { $this->key = key($this->array); $this->current = current($this->array); next($this->array); @@ -37,7 +37,7 @@ class ai implements Iterator { class a implements IteratorAggregate { - public function getIterator() { + public function getIterator(): Traversable { return new ai(); } } diff --git a/tests/classes/iterators_007.phpt b/tests/classes/iterators_007.phpt index db1c868e0dfe4..808fc58636dd3 100644 --- a/tests/classes/iterators_007.phpt +++ b/tests/classes/iterators_007.phpt @@ -7,11 +7,11 @@ class Test implements Iterator public $arr = array(1, 2, 3); public $x = 0; - public function rewind() { if ($this->x == 0) throw new Exception(__METHOD__); reset($this->arr); } - public function current() { if ($this->x == 1) throw new Exception(__METHOD__); return current($this->arr); } - public function key() { if ($this->x == 2) throw new Exception(__METHOD__); return key($this->arr); } - public function next() { if ($this->x == 3) throw new Exception(__METHOD__); next($this->arr); } - public function valid() { if ($this->x == 4) throw new Exception(__METHOD__); return (key($this->arr) !== NULL); } + public function rewind(): void { if ($this->x == 0) throw new Exception(__METHOD__); reset($this->arr); } + public function current(): mixed { if ($this->x == 1) throw new Exception(__METHOD__); return current($this->arr); } + public function key(): mixed { if ($this->x == 2) throw new Exception(__METHOD__); return key($this->arr); } + public function next(): void { if ($this->x == 3) throw new Exception(__METHOD__); next($this->arr); } + public function valid(): bool { if ($this->x == 4) throw new Exception(__METHOD__); return (key($this->arr) !== NULL); } } $t = new Test(); diff --git a/tests/classes/iterators_008.phpt b/tests/classes/iterators_008.phpt index 26c8e0170493c..679bcc384b291 100644 --- a/tests/classes/iterators_008.phpt +++ b/tests/classes/iterators_008.phpt @@ -8,26 +8,28 @@ class D extends C implements Iterator { private $counter = 2; - public function valid() { + public function valid(): bool { echo __METHOD__ . "($this->counter)\n"; return $this->counter; } - public function next() { + public function next(): void { $this->counter--; echo __METHOD__ . "($this->counter)\n"; } - public function rewind() { + public function rewind(): void { echo __METHOD__ . "($this->counter)\n"; } - public function current() { + public function current(): mixed { echo __METHOD__ . "($this->counter)\n"; + return null; } - public function key() { + public function key(): mixed { echo __METHOD__ . "($this->counter)\n"; + return ""; } } diff --git a/tests/lang/foreachLoopIterator.001.phpt b/tests/lang/foreachLoopIterator.001.phpt index ec84980524bbc..c6ecb78ed5aed 100644 --- a/tests/lang/foreachLoopIterator.001.phpt +++ b/tests/lang/foreachLoopIterator.001.phpt @@ -7,31 +7,31 @@ class MealIterator implements Iterator { private $pos=0; private $myContent=array("breakfast", "lunch", "dinner"); - public function valid() { + public function valid(): bool { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->pos<3; } - public function next() { + public function next(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; - return $this->myContent[$this->pos++]; + $this->myContent[$this->pos++]; } - public function rewind() { + public function rewind(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos=0; } - public function current() { + public function current(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->myContent[$this->pos]; } - public function key() { + public function key(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return "meal " . $this->pos; diff --git a/tests/lang/foreachLoopIterator.002.phpt b/tests/lang/foreachLoopIterator.002.phpt index dc0533be05641..5cb3d6bd43a89 100644 --- a/tests/lang/foreachLoopIterator.002.phpt +++ b/tests/lang/foreachLoopIterator.002.phpt @@ -4,11 +4,11 @@ foreach with iterator and &$value reference " . __METHOD__ . " ($this->pos)\n"; return $this->pos < count($this->myContent); } - public function next() { + public function next(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos++; } - public function rewind() { + public function rewind(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos=0; } - public function current() { + public function current(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->myContent[$this->pos]; } - public function key() { + public function key(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return "meal " . $this->pos; @@ -42,31 +42,31 @@ class FrenchMealIterator implements Iterator { private $pos=0; private $myContent=array("petit dejeuner", "dejeuner", "gouter", "dinner"); - public function valid() { + public function valid(): bool { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->pos < count($this->myContent); } - public function next() { + public function next(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos++; } - public function rewind() { + public function rewind(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos=0; } - public function current() { + public function current(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->myContent[$this->pos]; } - public function key() { + public function key(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return "meal " . $this->pos; @@ -85,7 +85,7 @@ Class EuropeanMeals implements IteratorAggregate { $this->storedFrenchMealIterator = new FrenchMealIterator; } - public function getIterator() { + public function getIterator(): Traversable { global $indent; echo "$indent--> " . __METHOD__ . "\n"; diff --git a/tests/lang/foreachLoopIteratorAggregate.002.phpt b/tests/lang/foreachLoopIteratorAggregate.002.phpt index 382adbe2d5635..bb5089e74b94b 100644 --- a/tests/lang/foreachLoopIteratorAggregate.002.phpt +++ b/tests/lang/foreachLoopIteratorAggregate.002.phpt @@ -4,24 +4,28 @@ IteratorAggregate::getIterator bad return type --EXPECT-- -30: Objects returned by bad1::getIterator() must be traversable or implement interface Iterator -30: Objects returned by bad2::getIterator() must be traversable or implement interface Iterator -30: Objects returned by bad3::getIterator() must be traversable or implement interface Iterator -30: Objects returned by bad4::getIterator() must be traversable or implement interface Iterator +34: Objects returned by bad1::getIterator() must be traversable or implement interface Iterator +34: Objects returned by bad2::getIterator() must be traversable or implement interface Iterator +34: Objects returned by bad3::getIterator() must be traversable or implement interface Iterator +34: Objects returned by bad4::getIterator() must be traversable or implement interface Iterator diff --git a/tests/lang/foreachLoopIteratorAggregate.003.phpt b/tests/lang/foreachLoopIteratorAggregate.003.phpt index cf9d2f73f4408..44067482e4b99 100644 --- a/tests/lang/foreachLoopIteratorAggregate.003.phpt +++ b/tests/lang/foreachLoopIteratorAggregate.003.phpt @@ -6,31 +6,31 @@ class EnglishMealIterator implements Iterator { private $pos=0; private $myContent=array("breakfast", "dinner", "tea"); - public function valid() { + public function valid(): bool { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->pos<3; } - public function next() { + public function next(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; - return $this->myContent[$this->pos++]; + $this->myContent[$this->pos++]; } - public function rewind() { + public function rewind(): void { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; $this->pos=0; } - public function current() { + public function current(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return $this->myContent[$this->pos]; } - public function key() { + public function key(): mixed { global $indent; echo "$indent--> " . __METHOD__ . " ($this->pos)\n"; return "meal " . $this->pos; @@ -39,19 +39,19 @@ class EnglishMealIterator implements Iterator { } class A1 implements IteratorAggregate { - function getIterator() { + function getIterator(): Traversable { return new EnglishMealIterator; } } class A2 implements IteratorAggregate { - function getIterator() { + function getIterator(): Traversable { return new A1; } } class A3 implements IteratorAggregate { - function getIterator() { + function getIterator(): Traversable { return new A2; } } diff --git a/tests/lang/foreachLoopIteratorAggregate.004.phpt b/tests/lang/foreachLoopIteratorAggregate.004.phpt index 0e46fec7f06a1..bfb2d1bd4b9a8 100644 --- a/tests/lang/foreachLoopIteratorAggregate.004.phpt +++ b/tests/lang/foreachLoopIteratorAggregate.004.phpt @@ -11,24 +11,24 @@ class c_iter implements Iterator { echo __METHOD__ . "\n"; $this->obj = $obj; } - function rewind() { + function rewind(): void { echo __METHOD__ . "\n"; $this->num = 0; } - function valid() { + function valid(): bool { $more = $this->num < $this->obj->max; echo __METHOD__ . ' = ' .($more ? 'true' : 'false') . "\n"; return $more; } - function current() { + function current(): mixed { echo __METHOD__ . "\n"; return $this->num; } - function next() { + function next(): void { echo __METHOD__ . "\n"; $this->num++; } - function key() { + function key(): mixed { echo __METHOD__ . "\n"; switch($this->num) { case 0: return "1st"; @@ -45,7 +45,7 @@ class c implements IteratorAggregate { public $max = 3; - function getIterator() { + function getIterator(): Traversable { echo __METHOD__ . "\n"; return new c_iter($this); } From 083d4157be30d7b3ee3ebdb178b401c15a393179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 16 Jul 2021 16:49:38 +0200 Subject: [PATCH 2/5] Test fixes --- Zend/tests/bug32993.phpt | 2 +- Zend/tests/tentative_type_early_binding.phpt | 2 +- Zend/zend_exceptions.stub.php | 4 ++-- Zend/zend_exceptions_arginfo.h | 8 ++++---- Zend/zend_interfaces.stub.php | 11 +++++------ Zend/zend_interfaces_arginfo.h | 19 ++++++++++--------- ext/phar/tests/bug45218_SLOWTEST.phpt | 6 ++++-- ext/phar/tests/phar_buildfromiterator4.phpt | 4 ++-- ext/phar/tests/phar_buildfromiterator5.phpt | 6 +++--- ext/phar/tests/phar_buildfromiterator6.phpt | 4 ++-- ext/phar/tests/phar_buildfromiterator7.phpt | 4 ++-- ext/phar/tests/phar_buildfromiterator9.phpt | 6 +++--- .../tests/tar/phar_buildfromiterator4.phpt | 4 ++-- .../tests/tar/phar_buildfromiterator5.phpt | 6 +++--- .../tests/tar/phar_buildfromiterator6.phpt | 4 ++-- .../tests/tar/phar_buildfromiterator7.phpt | 4 ++-- .../tests/tar/phar_buildfromiterator9.phpt | 6 +++--- .../tests/zip/phar_buildfromiterator4.phpt | 4 ++-- .../tests/zip/phar_buildfromiterator5.phpt | 6 +++--- .../tests/zip/phar_buildfromiterator6.phpt | 4 ++-- .../tests/zip/phar_buildfromiterator7.phpt | 4 ++-- .../tests/zip/phar_buildfromiterator9.phpt | 6 +++--- ext/soap/tests/server031.phpt | 4 ++-- ext/spl/spl_directory.stub.php | 4 ++-- ext/spl/spl_directory_arginfo.h | 4 ++-- 25 files changed, 69 insertions(+), 67 deletions(-) diff --git a/Zend/tests/bug32993.phpt b/Zend/tests/bug32993.phpt index fbc0eb0702415..8a911f922c34b 100644 --- a/Zend/tests/bug32993.phpt +++ b/Zend/tests/bug32993.phpt @@ -8,7 +8,7 @@ class Test implements Iterator { public function rewind(): void { reset($this->arr); } public function current(): mixed { throw new Exception(); } - public function key() { return key($this->arr); } + public function key(): mixed { return key($this->arr); } public function next(): void { next($this->arr); } public function valid(): bool { return (current($this->arr) !== false); } } diff --git a/Zend/tests/tentative_type_early_binding.phpt b/Zend/tests/tentative_type_early_binding.phpt index ca9c9646adaa1..cc26e7d93b71c 100644 --- a/Zend/tests/tentative_type_early_binding.phpt +++ b/Zend/tests/tentative_type_early_binding.phpt @@ -3,7 +3,7 @@ Check that both warning and unresolved during early binding is handled --FILE-- diff --git a/Zend/zend_exceptions.stub.php b/Zend/zend_exceptions.stub.php index 9dce0fbe808f2..f0f13eaac7a62 100644 --- a/Zend/zend_exceptions.stub.php +++ b/Zend/zend_exceptions.stub.php @@ -36,8 +36,8 @@ private function __clone(): void {} public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null) {} - /** @return void */ - public function __wakeup() {} + /** @tentative-return-type */ + public function __wakeup(): void {} final public function getMessage(): string {} diff --git a/Zend/zend_exceptions_arginfo.h b/Zend/zend_exceptions_arginfo.h index ddc80db22b5a1..c27de25cf70e1 100644 --- a/Zend/zend_exceptions_arginfo.h +++ b/Zend/zend_exceptions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: e77ba21c194c4c6b47cdabc8766fb5f37179d155 */ + * Stub hash: 48d8444730a0e1fbc5d81965733deb3d3c11e122 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Throwable_getMessage, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() @@ -29,7 +29,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Exception___construct, 0, 0, 0) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, previous, Throwable, 1, "null") ZEND_END_ARG_INFO() -#define arginfo_class_Exception___wakeup arginfo_class_Throwable_getCode +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Exception___wakeup, 0, 0, IS_VOID, 0) +ZEND_END_ARG_INFO() #define arginfo_class_Exception_getMessage arginfo_class_Throwable_getMessage @@ -62,8 +63,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_Error___construct arginfo_class_Exception___construct -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Error___wakeup, 0, 0, IS_VOID, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_Error___wakeup arginfo_class_Exception___wakeup #define arginfo_class_Error_getMessage arginfo_class_Throwable_getMessage diff --git a/Zend/zend_interfaces.stub.php b/Zend/zend_interfaces.stub.php index 2ed83610ef749..870c09a95b9a6 100644 --- a/Zend/zend_interfaces.stub.php +++ b/Zend/zend_interfaces.stub.php @@ -13,13 +13,13 @@ public function getIterator(): Traversable; interface Iterator extends Traversable { /** @return mixed */ - public function current(); // TODO Can't add tentative return tyoe due to DirectoryIterator::current() + public function current(): mixed; /** @tentative-return-type */ public function next(): void; /** @return mixed */ - public function key(); // TODO Can't add tentative return tyoe due to DirectoryIterator::key() + public function key(): mixed; /** @tentative-return-type */ public function valid(): bool; @@ -42,8 +42,8 @@ public function offsetGet(mixed $offset): mixed; /** @tentative-return-type */ public function offsetSet(mixed $offset, mixed $value): void; - /** @return void */ - public function offsetUnset(mixed $offset); // TODO Can't add tentative return type due to Phar::offsetUnset + /** @tentative-return-type */ + public function offsetUnset(mixed $offset): void; } interface Serializable @@ -57,8 +57,7 @@ public function unserialize(string $data); interface Countable { - /** @return int */ - public function count(); // TODO Can't add tentatie return type due to DOMNodeList::count() and DOMNamedNodeMap::count() + public function count(): int; } interface Stringable diff --git a/Zend/zend_interfaces_arginfo.h b/Zend/zend_interfaces_arginfo.h index 84812656053e1..bbe220cbe22db 100644 --- a/Zend/zend_interfaces_arginfo.h +++ b/Zend/zend_interfaces_arginfo.h @@ -1,10 +1,10 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 29ecd0161c7f7521f2f149e438182c247e658bb2 */ + * Stub hash: b43f6527e45ee22732e3227e933a8950a641a8b5 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, Traversable, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Iterator_current, 0, 0, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_current, 0, 0, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_next, 0, 0, IS_VOID, 0) @@ -30,27 +30,28 @@ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offs ZEND_ARG_TYPE_INFO(0, value, IS_MIXED, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_ArrayAccess_offsetUnset, 0, 0, 1) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_ArrayAccess_offsetUnset, 0, 1, IS_VOID, 0) ZEND_ARG_TYPE_INFO(0, offset, IS_MIXED, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Serializable_serialize arginfo_class_Iterator_current +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_serialize, 0, 0, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_unserialize, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_Countable_count arginfo_class_Iterator_current +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Countable_count, 0, 0, IS_LONG, 0) +ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Stringable___toString, 0, 0, IS_STRING, 0) ZEND_END_ARG_INFO() -#define arginfo_class_InternalIterator___construct arginfo_class_Iterator_current +#define arginfo_class_InternalIterator___construct arginfo_class_Serializable_serialize -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_current, 0, 0, IS_MIXED, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_InternalIterator_current arginfo_class_Iterator_current -#define arginfo_class_InternalIterator_key arginfo_class_InternalIterator_current +#define arginfo_class_InternalIterator_key arginfo_class_Iterator_current ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_next, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt index d60cdf9ed97d3..074dced3862eb 100644 --- a/ext/phar/tests/bug45218_SLOWTEST.phpt +++ b/ext/phar/tests/bug45218_SLOWTEST.phpt @@ -19,7 +19,8 @@ class myIterator implements Iterator var $a; var $count = 1; - function next(): void { + #[ReturnTypeWillChange] + function next() { return (++$this->count < 3000) ? 'f' . $this->count : false; } function current(): mixed { @@ -34,7 +35,8 @@ class myIterator implements Iterator function valid(): bool { return $this->count < 3000; } - function rewind(): void { + #[ReturnTypeWillChange] + function rewind() { $this->count = 1; return $GLOBALS['fname2']; } diff --git a/ext/phar/tests/phar_buildfromiterator4.phpt b/ext/phar/tests/phar_buildfromiterator4.phpt index fe4ce8dc7908b..e7bccc27c956e 100644 --- a/ext/phar/tests/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/phar_buildfromiterator4.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/phar_buildfromiterator5.phpt b/ext/phar/tests/phar_buildfromiterator5.phpt index 9ea3fa1bca870..147fb26875a1a 100644 --- a/ext/phar/tests/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/phar_buildfromiterator5.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return is_object(current($this->a)); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/phar_buildfromiterator6.phpt b/ext/phar/tests/phar_buildfromiterator6.phpt index 6bb99c9f816ed..59a5b6ef1c7c4 100644 --- a/ext/phar/tests/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/phar_buildfromiterator6.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/phar_buildfromiterator7.phpt b/ext/phar/tests/phar_buildfromiterator7.phpt index 4088e54837cbc..94a192c3dfb1c 100644 --- a/ext/phar/tests/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/phar_buildfromiterator7.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/phar_buildfromiterator9.phpt b/ext/phar/tests/phar_buildfromiterator9.phpt index 7f1ec5e780c34..a2cb24d8cc7fe 100644 --- a/ext/phar/tests/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/phar_buildfromiterator9.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return (bool) current($this->a); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/tar/phar_buildfromiterator4.phpt b/ext/phar/tests/tar/phar_buildfromiterator4.phpt index 35d18400ddc9b..36ea9cac60827 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator4.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/tar/phar_buildfromiterator5.phpt b/ext/phar/tests/tar/phar_buildfromiterator5.phpt index 19d79dce85960..bcfbc0715ea40 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator5.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return (bool) current($this->a); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/tar/phar_buildfromiterator6.phpt b/ext/phar/tests/tar/phar_buildfromiterator6.phpt index cd567685af816..addacc26f1ab4 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator6.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/tar/phar_buildfromiterator7.phpt b/ext/phar/tests/tar/phar_buildfromiterator7.phpt index ca864e887a8ed..6eee23929d08e 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator7.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/tar/phar_buildfromiterator9.phpt b/ext/phar/tests/tar/phar_buildfromiterator9.phpt index e2f3e901b932b..d67997afa91b9 100644 --- a/ext/phar/tests/tar/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/tar/phar_buildfromiterator9.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return (bool) current($this->a); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/zip/phar_buildfromiterator4.phpt b/ext/phar/tests/zip/phar_buildfromiterator4.phpt index 8dbeede3c0a2b..6d44e2f8d7e04 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator4.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator4.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/zip/phar_buildfromiterator5.phpt b/ext/phar/tests/zip/phar_buildfromiterator5.phpt index 5b73b752d62b6..dafd6ceda765c 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator5.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator5.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return is_object(current($this->a)); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/zip/phar_buildfromiterator6.phpt b/ext/phar/tests/zip/phar_buildfromiterator6.phpt index 67e3eb633c25b..491fada954870 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator6.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator6.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/zip/phar_buildfromiterator7.phpt b/ext/phar/tests/zip/phar_buildfromiterator7.phpt index 46736603e2c82..4129c6b232505 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator7.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator7.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -32,7 +32,7 @@ class myIterator implements Iterator } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/phar/tests/zip/phar_buildfromiterator9.phpt b/ext/phar/tests/zip/phar_buildfromiterator9.phpt index 273c614370cdb..9d290a73a2388 100644 --- a/ext/phar/tests/zip/phar_buildfromiterator9.phpt +++ b/ext/phar/tests/zip/phar_buildfromiterator9.phpt @@ -16,7 +16,7 @@ class myIterator implements Iterator } function next(): void { echo "next\n"; - return next($this->a); + next($this->a); } function current(): mixed { echo "current\n"; @@ -28,11 +28,11 @@ class myIterator implements Iterator } function valid(): bool { echo "valid\n"; - return current($this->a); + return is_resource(current($this->a)); } function rewind(): void { echo "rewind\n"; - return reset($this->a); + reset($this->a); } } try { diff --git a/ext/soap/tests/server031.phpt b/ext/soap/tests/server031.phpt index fcb4d42d9cfab..cec8cca0537b4 100644 --- a/ext/soap/tests/server031.phpt +++ b/ext/soap/tests/server031.phpt @@ -13,10 +13,10 @@ class ItemArray implements Iterator { $this->a = $a; } - public function rewind(): void { return reset($this->a); } + public function rewind(): void { reset($this->a); } public function current(): mixed { return current($this->a); } public function key(): mixed { return key($this->a); } - public function next(): void { return next($this->a); } + public function next(): void { next($this->a); } public function valid(): bool { return (current($this->a) !== false); } } diff --git a/ext/spl/spl_directory.stub.php b/ext/spl/spl_directory.stub.php index ef3cc9f68a4e2..62b05127ae6cf 100644 --- a/ext/spl/spl_directory.stub.php +++ b/ext/spl/spl_directory.stub.php @@ -123,10 +123,10 @@ public function rewind(): void {} public function valid(): bool {} /** @return int */ - public function key() {} // TODO change return type to string + public function key(): mixed {} // TODO change return type to string /** @return DirectoryIterator */ - public function current() {} // TODO fix return type so that FilesystemIterator::current() remains compatible + public function current(): mixed {} // TODO narrow return type /** @tentative-return-type */ public function next(): void {} diff --git a/ext/spl/spl_directory_arginfo.h b/ext/spl/spl_directory_arginfo.h index 7a7261d4ffdf5..9bd271fd668fb 100644 --- a/ext/spl/spl_directory_arginfo.h +++ b/ext/spl/spl_directory_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fcfc6e8120dff87ab81d9b5491f27e695b3790f4 */ + * Stub hash: 7c64c21963df5a11e902298eb5957b868c4b48cf */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -102,7 +102,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_DirectoryIterator_valid arginfo_class_SplFileInfo_isWritable -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, 0) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_DirectoryIterator_key, 0, 0, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_DirectoryIterator_current arginfo_class_DirectoryIterator_key From 920fee8669c7534cdc3549624887a2eab8d2ced7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 16 Jul 2021 17:57:07 +0200 Subject: [PATCH 3/5] Even more test fixes --- Zend/zend_interfaces.stub.php | 5 +++-- Zend/zend_interfaces_arginfo.h | 11 ++++++----- ext/reflection/tests/intersection_types.phpt | 2 +- ext/spl/tests/countable_class_basic1.phpt | 1 + ext/spl/tests/countable_count_variation1.phpt | 7 ++++++- ext/spl/tests/observer_002.phpt | 2 +- ext/spl/tests/spl_002.phpt | 2 +- ext/standard/tests/array/bug43505.phpt | 1 + ext/standard/tests/array/count_recursive.phpt | 2 +- ext/standard/tests/array/sizeof_object1.phpt | 2 +- .../general_functions/is_countable_with_classes.phpt | 2 +- sapi/cli/tests/005.phpt | 3 ++- 12 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Zend/zend_interfaces.stub.php b/Zend/zend_interfaces.stub.php index 870c09a95b9a6..0b58c94049f98 100644 --- a/Zend/zend_interfaces.stub.php +++ b/Zend/zend_interfaces.stub.php @@ -12,13 +12,13 @@ public function getIterator(): Traversable; interface Iterator extends Traversable { - /** @return mixed */ + /** @tentative-return-type */ public function current(): mixed; /** @tentative-return-type */ public function next(): void; - /** @return mixed */ + /** @tentative-return-type */ public function key(): mixed; /** @tentative-return-type */ @@ -57,6 +57,7 @@ public function unserialize(string $data); interface Countable { + /** @tentative-return-type */ public function count(): int; } diff --git a/Zend/zend_interfaces_arginfo.h b/Zend/zend_interfaces_arginfo.h index bbe220cbe22db..69c3853af723b 100644 --- a/Zend/zend_interfaces_arginfo.h +++ b/Zend/zend_interfaces_arginfo.h @@ -1,10 +1,10 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b43f6527e45ee22732e3227e933a8950a641a8b5 */ + * Stub hash: 339e326a82a7fd1e2ae419c8c86095e29028fbd6 */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_IteratorAggregate_getIterator, 0, 0, Traversable, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_current, 0, 0, IS_MIXED, 0) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_current, 0, 0, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Iterator_next, 0, 0, IS_VOID, 0) @@ -41,7 +41,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Serializable_unserialize, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Countable_count, 0, 0, IS_LONG, 0) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Countable_count, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Stringable___toString, 0, 0, IS_STRING, 0) @@ -49,9 +49,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_InternalIterator___construct arginfo_class_Serializable_serialize -#define arginfo_class_InternalIterator_current arginfo_class_Iterator_current +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_current, 0, 0, IS_MIXED, 0) +ZEND_END_ARG_INFO() -#define arginfo_class_InternalIterator_key arginfo_class_Iterator_current +#define arginfo_class_InternalIterator_key arginfo_class_InternalIterator_current ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_InternalIterator_next, 0, 0, IS_VOID, 0) ZEND_END_ARG_INFO() diff --git a/ext/reflection/tests/intersection_types.phpt b/ext/reflection/tests/intersection_types.phpt index 9f091a8bc93fc..2504d3ca72590 100644 --- a/ext/reflection/tests/intersection_types.phpt +++ b/ext/reflection/tests/intersection_types.phpt @@ -29,7 +29,7 @@ dumpType($rp->getType()); interface y {} class x implements Y, Countable { - public function count() {} + public function count(): int { return 0; } } $test = new Test; $test->prop = new x; diff --git a/ext/spl/tests/countable_class_basic1.phpt b/ext/spl/tests/countable_class_basic1.phpt index ede42e960ffc1..d6b6c3634fb67 100644 --- a/ext/spl/tests/countable_class_basic1.phpt +++ b/ext/spl/tests/countable_class_basic1.phpt @@ -24,6 +24,7 @@ Interface [ interface Countable ] { - Parameters [0] { } + - Tentative return [ int ] } } } diff --git a/ext/spl/tests/countable_count_variation1.phpt b/ext/spl/tests/countable_count_variation1.phpt index 0e17eccbe68ab..b4b382bea35cb 100644 --- a/ext/spl/tests/countable_count_variation1.phpt +++ b/ext/spl/tests/countable_count_variation1.phpt @@ -4,29 +4,34 @@ SPL: Countable::count() with wrong return types and exception. observers->detach($observer); } - function count() + function count(): int { return $this->observers->count(); } diff --git a/ext/spl/tests/spl_002.phpt b/ext/spl/tests/spl_002.phpt index 5442b1991d77d..4f3835c51eb9c 100644 --- a/ext/spl/tests/spl_002.phpt +++ b/ext/spl/tests/spl_002.phpt @@ -5,7 +5,7 @@ SPL: Countable class Test implements Countable { - function count() + function count(): int { return 4; } diff --git a/ext/standard/tests/array/bug43505.phpt b/ext/standard/tests/array/bug43505.phpt index 802534dfecbbb..ae300aa1b9ccd 100644 --- a/ext/standard/tests/array/bug43505.phpt +++ b/ext/standard/tests/array/bug43505.phpt @@ -5,6 +5,7 @@ error_reporting=0 --FILE-- class stdClass ] { } " -string(2201) "Class [ class Exception implements Throwable, Stringable ] { +string(2235) "Class [ class Exception implements Throwable, Stringable ] { - Constants [0] { } @@ -79,6 +79,7 @@ string(2201) "Class [ class Exception implements Throwable, Stri - Parameters [0] { } + - Tentative return [ void ] } Method [ final public method getMessage ] { From 22a8a086c970d34c6255865d7d5cfdad83136dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Fri, 16 Jul 2021 18:27:07 +0200 Subject: [PATCH 4/5] Fix test --- ext/opcache/tests/bug77275.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/tests/bug77275.phpt b/ext/opcache/tests/bug77275.phpt index bef5b9e4956c7..b68f2ba9c7432 100644 --- a/ext/opcache/tests/bug77275.phpt +++ b/ext/opcache/tests/bug77275.phpt @@ -11,7 +11,7 @@ namespace Foo; class Bar { public function get() {} } class Record implements \ArrayAccess { public function offsetSet($offset, $value): void { throw new \Exception; } - public function offsetGet($offset): mixed { var_dump($offset); } + public function offsetGet($offset): mixed { var_dump($offset); return null; } public function offsetExists($offset): bool { throw new \Exception; } public function offsetUnset($offset): void { throw new \Exception; } } From 3091b167b58387fa7e7bcd375fdf31c167370ba1 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 19 Jul 2021 10:58:37 +0200 Subject: [PATCH 5/5] Make method void --- ext/phar/tests/bug45218_SLOWTEST.phpt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ext/phar/tests/bug45218_SLOWTEST.phpt b/ext/phar/tests/bug45218_SLOWTEST.phpt index 074dced3862eb..a0ac5922b840c 100644 --- a/ext/phar/tests/bug45218_SLOWTEST.phpt +++ b/ext/phar/tests/bug45218_SLOWTEST.phpt @@ -19,9 +19,8 @@ class myIterator implements Iterator var $a; var $count = 1; - #[ReturnTypeWillChange] - function next() { - return (++$this->count < 3000) ? 'f' . $this->count : false; + function next(): void { + ++$this->count; } function current(): mixed { if (($this->count % 100) === 0) {