Skip to content

Commit c693213

Browse files
committed
Declare tentative return types for Zend
1 parent a733b1a commit c693213

File tree

119 files changed

+559
-540
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+559
-540
lines changed

Zend/tests/ArrayAccess_indirect_append.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ Using indirect append on ArrayAccess object
55

66
class AA implements ArrayAccess {
77
private $data = [];
8-
public function &offsetGet($name) {
8+
public function &offsetGet($name): mixed {
99
if (null === $name) {
1010
return $this->data[];
1111
} else {
1212
return $this->data[$name];
1313
}
1414
}
15-
public function offsetSet($name, $value) {
15+
public function offsetSet($name, $value): void {
1616
$this->data[$name] = $value;
1717
}
18-
public function offsetUnset($name) {}
19-
public function offsetExists($name) {}
18+
public function offsetUnset($name): void {}
19+
public function offsetExists($name): bool {}
2020
}
2121

2222
$aa = new AA;

Zend/tests/anon/004.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ class Outer {
1212
public function getArrayAccess() {
1313
/* create a proxy object implementing array access */
1414
return new class($this->data) extends Outer implements ArrayAccess {
15-
public function offsetGet($offset) { return $this->data[$offset]; }
16-
public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); }
17-
public function offsetUnset($offset) { unset($this->data[$offset]); }
18-
public function offsetExists($offset) { return isset($this->data[$offset]); }
15+
public function offsetGet($offset): mixed { return $this->data[$offset]; }
16+
public function offsetSet($offset, $data): void { $this->data[$offset] = $data; }
17+
public function offsetUnset($offset): void { unset($this->data[$offset]); }
18+
public function offsetExists($offset): bool { return isset($this->data[$offset]); }
1919
};
2020
}
2121
}

Zend/tests/anon/005.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class Outer {
1414
/* create a child object implementing array access */
1515
/* this grants you access to protected methods and members */
1616
return new class($this->data) implements ArrayAccess {
17-
public function offsetGet($offset) { return $this->data[$offset]; }
18-
public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); }
19-
public function offsetUnset($offset) { unset($this->data[$offset]); }
20-
public function offsetExists($offset) { return isset($this->data[$offset]); }
17+
public function offsetGet($offset): mixed { return $this->data[$offset]; }
18+
public function offsetSet($offset, $data): void { $this->data[$offset] = $data; }
19+
public function offsetUnset($offset): void { unset($this->data[$offset]); }
20+
public function offsetExists($offset): bool { return isset($this->data[$offset]); }
2121
};
2222
}
2323
}

Zend/tests/arg_unpack/traversable_throwing_exception.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function test(...$args) {
88
}
99

1010
class Foo implements IteratorAggregate {
11-
public function getIterator() {
11+
public function getIterator(): Traversable {
1212
throw new Exception('getIterator');
1313
}
1414
}

Zend/tests/argument_restriction_005.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Bug #55719 (Argument restriction should come with a more specific error message)
33
--FILE--
44
<?php
55
class Sub implements ArrayAccess {
6-
public function offsetSet() {
6+
public function offsetSet(): void {
77
}
88
}
99
?>
1010
--EXPECTF--
11-
Fatal error: Declaration of Sub::offsetSet() must be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value) in %sargument_restriction_005.php on line %d
11+
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

Zend/tests/assign_coalesce_002.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ try {
2626
var_dump($ary);
2727

2828
class AA implements ArrayAccess {
29-
public function offsetExists($k) {
29+
public function offsetExists($k): bool {
3030
return true;
3131
}
32-
public function &offsetGet($k) {
32+
public function &offsetGet($k): mixed {
3333
$var = ["foo" => "bar"];
3434
return $var;
3535
}
36-
public function offsetSet($k,$v) {}
37-
public function offsetUnset($k) {}
36+
public function offsetSet($k,$v): void {}
37+
public function offsetUnset($k): void {}
3838
}
3939

4040
class Dtor {
@@ -52,14 +52,14 @@ try {
5252
var_dump($foo);
5353

5454
class AA2 implements ArrayAccess {
55-
public function offsetExists($k) {
55+
public function offsetExists($k): bool {
5656
return false;
5757
}
58-
public function offsetGet($k) {
58+
public function offsetGet($k): mixed {
5959
return null;
6060
}
61-
public function offsetSet($k,$v) {}
62-
public function offsetUnset($k) {}
61+
public function offsetSet($k,$v): void {}
62+
public function offsetUnset($k): void {}
6363
}
6464

6565
$ary = ["foo" => new AA2];

Zend/tests/assign_coalesce_003.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ class AA implements ArrayAccess {
1313
public function __construct($data = []) {
1414
$this->data = $data;
1515
}
16-
public function &offsetGet($k) {
16+
public function &offsetGet($k): mixed {
1717
echo "offsetGet($k)\n";
1818
return $this->data[$k];
1919
}
20-
public function offsetExists($k) {
20+
public function offsetExists($k): bool {
2121
echo "offsetExists($k)\n";
2222
return array_key_exists($k, $this->data);
2323
}
24-
public function offsetSet($k,$v) {
24+
public function offsetSet($k,$v): void {
2525
echo "offsetSet($k,$v)\n";
2626
$this->data[$k] = $v;
2727
}
28-
public function offsetUnset($k) { }
28+
public function offsetUnset($k): void { }
2929
}
3030

3131
$ary = new AA(["foo" => new AA, "null" => null]);

Zend/tests/bug26229.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Bug #26229 (getIterator() segfaults when it returns arrays or scalars)
44
<?php
55

66
class array_iterator implements IteratorAggregate {
7+
#[ReturnTypeWillChange]
78
public function getIterator() {
89
return array('foo', 'bar');
910
}

Zend/tests/bug30346.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Bug #30346 (arrayAccess and using $this)
66
class Test implements ArrayAccess
77
{
88
public function __construct() { }
9-
public function offsetExists( $offset ) { return false; }
10-
public function offsetGet( $offset ) { return $offset; }
11-
public function offsetSet( $offset, $data ) { }
12-
public function offsetUnset( $offset ) { }
9+
public function offsetExists( $offset ): bool { return false; }
10+
public function offsetGet( $offset ): mixed { return $offset; }
11+
public function offsetSet( $offset, $data ): void { }
12+
public function offsetUnset( $offset ): void { }
1313
}
1414

1515
$post = new Test;

Zend/tests/bug30725.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bug #30725 (PHP segfaults when an exception is thrown in getIterator() within fo
55

66
class Test implements IteratorAggregate
77
{
8-
function getIterator()
8+
function getIterator(): Traversable
99
{
1010
throw new Exception();
1111
}

0 commit comments

Comments
 (0)