Skip to content

Commit cef23ea

Browse files
committed
Fix tests
1 parent 500b7ad commit cef23ea

File tree

219 files changed

+600
-593
lines changed

Some content is hidden

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

219 files changed

+600
-593
lines changed

Zend/tests/bug21478.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #21478 (Zend/zend_alloc.c :: shutdown_memory_manager produces segfault)
33
--FILE--
44
<?php
55
class debugfilter extends php_user_filter {
6-
function filter($in, $out, &$consumed, $closing) {
6+
function filter($in, $out, &$consumed, $closing): int {
77
while ($bucket = stream_bucket_make_writeable($in)) {
88
$bucket->data = strtoupper($bucket->data);
99
stream_bucket_append($out, $bucket);

Zend/tests/bug78406.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if (!class_exists(SampleFilter::class)) {
1010
{
1111
private $data = '';
1212

13-
public function filter($in, $out, &$consumed, $closing)
13+
public function filter($in, $out, &$consumed, $closing): int
1414
{
1515
while ($bucket = stream_bucket_make_writeable($in))
1616
{

Zend/tests/enum/json_encode.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum StringFoo: string {
1818
enum CustomFoo implements JsonSerializable {
1919
case Bar;
2020

21-
public function jsonSerialize() {
21+
public function jsonSerialize(): mixed {
2222
return 'Custom ' . $this->name;
2323
}
2424
}

Zend/tests/foreach_004.phpt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,26 @@ class IT extends ArrayIterator {
1616
}
1717
}
1818

19-
function rewind() {$this->trap(__FUNCTION__); return parent::rewind();}
20-
function valid() {$this->trap(__FUNCTION__); return parent::valid();}
21-
function key() {$this->trap(__FUNCTION__); return parent::key();}
22-
function next() {$this->trap(__FUNCTION__); return parent::next();}
19+
function rewind(): void
20+
{
21+
$this->trap(__FUNCTION__);
22+
parent::rewind();
23+
}
24+
25+
function valid(): bool {
26+
$this->trap(__FUNCTION__);
27+
return parent::valid();
28+
}
29+
30+
function key(): mixed {
31+
$this->trap(__FUNCTION__);
32+
return parent::key();
33+
}
34+
35+
function next(): void {
36+
$this->trap(__FUNCTION__);
37+
parent::next();
38+
}
2339
}
2440

2541
foreach(['rewind', 'valid', 'key', 'next'] as $trap) {

Zend/tests/iterator_key_by_ref.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Iterator::key() with by-ref return
33
--FILE--
44
<?php
55
class Test extends ArrayIterator {
6-
function &key() {
6+
function &key(): mixed {
77
return $foo;
88
}
99
}

Zend/tests/ns_054.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
namespace test\ns1;
66

77
class Foo implements \SplObserver {
8-
function update(\SplSubject $x) {
8+
function update(\SplSubject $x): void {
99
echo "ok\n";
1010
}
1111
}
1212

1313
class Bar implements \SplSubject {
14-
function attach(\SplObserver $x) {
14+
function attach(\SplObserver $x): void {
1515
echo "ok\n";
1616
}
17-
function notify() {
17+
function notify(): void {
1818
}
19-
function detach(\SplObserver $x) {
19+
function detach(\SplObserver $x): void {
2020
}
2121
}
2222
$foo = new Foo();

Zend/tests/ns_056.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ namespace test\ns1;
66
use \SplObserver;
77

88
class Foo implements SplObserver {
9-
function update(\SplSubject $x) {
9+
function update(\SplSubject $x): void {
1010
echo "ok\n";
1111
}
1212
}
1313

1414
class Bar implements \SplSubject {
15-
function attach(SplObserver $x) {
15+
function attach(SplObserver $x): void {
1616
echo "ok\n";
1717
}
18-
function notify() {
18+
function notify(): void {
1919
}
20-
function detach(SplObserver $x) {
20+
function detach(SplObserver $x): void {
2121
}
2222
}
2323
$foo = new Foo();

Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ The default value is a class constant in the parent class method's signature.
44
<?php
55
class MyDateTimeZone extends DateTimeZone
66
{
7-
public static function listIdentifiers()
7+
public static function listIdentifiers(): array
88
{
99
}
1010
}
1111
?>
1212
--EXPECTF--
13-
Fatal error: Declaration of MyDateTimeZone::listIdentifiers() must be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) in %s on line %d
13+
Fatal error: Declaration of MyDateTimeZone::listIdentifiers(): array must be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array in %s on line %d

Zend/tests/parameter_default_values/internal_declaration_error_const.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ The default value is a constant in the parent class method's signature.
44
<?php
55
class MyDateTimeZone extends DateTimeZone
66
{
7-
public function getTransitions()
7+
public function getTransitions(): array|false
88
{
99
}
1010
}
1111
?>
1212
--EXPECTF--
13-
Fatal error: Declaration of MyDateTimeZone::getTransitions() must be compatible with DateTimeZone::getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX) in %s on line %d
13+
Fatal error: Declaration of MyDateTimeZone::getTransitions(): array|false must be compatible with DateTimeZone::getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false in %s on line %d

Zend/tests/parameter_default_values/internal_declaration_error_false.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ The default value is false in the parent class method's signature.
55

66
interface MyDateTimeInterface extends DateTimeInterface
77
{
8-
public function diff();
8+
public function diff(): DateInterval|false;
99
}
1010
?>
1111
--EXPECTF--
12-
Fatal error: Declaration of MyDateTimeInterface::diff() must be compatible with DateTimeInterface::diff(DateTimeInterface $targetObject, bool $absolute = false) in %s on line %d
12+
Fatal error: Declaration of MyDateTimeInterface::diff(): DateInterval|false must be compatible with DateTimeInterface::diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval|false in %s on line %d

Zend/tests/parameter_default_values/internal_declaration_error_int.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ The default value is an integer in the parent class method's signature.
44
<?php
55
class MyDateTime extends DateTime
66
{
7-
public function setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false)
7+
public function setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false): DateTime
88
{
99
}
1010
}
1111
?>
1212
--EXPECTF--
13-
Fatal error: Declaration of MyDateTime::setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false) must be compatible with DateTime::setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0) in %s on line %d
13+
Fatal error: Declaration of MyDateTime::setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false): DateTime must be compatible with DateTime::setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime in %s on line %d

Zend/tests/parameter_default_values/internal_declaration_error_null.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ The default value is null in the parent class method's signature.
44
<?php
55
class MyDateTime extends DateTime
66
{
7-
public static function createFromFormat()
7+
public static function createFromFormat(): DateTime|false
88
{
99
}
1010
}
1111
?>
1212
--EXPECTF--
13-
Fatal error: Declaration of MyDateTime::createFromFormat() must be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null) in %s on line %d
13+
Fatal error: Declaration of MyDateTime::createFromFormat(): DateTime|false must be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false in %s on line %d

ext/date/tests/DateTime_extends_basic3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ echo "*** Testing new DateTime() : with user format() method ***\n";
99

1010
class DateTimeExt extends DateTime
1111
{
12-
public function format($format = "F j, Y, g:i:s a")
12+
public function format($format = "F j, Y, g:i:s a"): string
1313
{
1414
return parent::format($format);
1515
}

ext/date/tests/bug55407.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ error_reporting=-1
66
<?php namespace melt\core;
77

88
class DateTime extends \DateTime {
9-
public static function createFromFormat($format, $time, \DateTimeZone $timezone = null) {
9+
public static function createFromFormat($format, $time, \DateTimeZone $timezone = null): DateTime|false {
1010
return new DateTime(parent::createFromFormat($format, $time, $timezone));
1111
}
1212
}

ext/date/tests/bug62852_var2.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $s2 = 'O:3:"Foo":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";
99
global $foo;
1010

1111
class Foo extends DateTime {
12-
function __wakeup() {
12+
function __wakeup(): void {
1313
global $foo;
1414
$foo = $this;
1515
parent::__wakeup();

ext/date/tests/bug62852_var3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $s2 = 'O:3:"Foo":3:{s:4:"date";s:19:"0000-00-00 00:00:00";s:13:"timezone_type";i
99
global $foo;
1010

1111
class Foo extends DateTime {
12-
function __wakeup() {
12+
function __wakeup(): void {
1313
global $foo;
1414
$foo = $this;
1515
parent::__wakeup();

ext/intl/tests/uconverter_oop_callback.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class MyConverter extends UConverter {
99
/**
1010
* Called during conversion from source encoding to internal UChar representation
1111
*/
12-
public function toUCallback($reason, $source, $codeUnits, &$error) {
12+
public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
1313
echo "toUCallback(", UConverter::reasonText($reason), ", ...)\n";
1414
return parent::toUCallback($reason, $source, $codeUnits, $error);
1515
}
1616

1717
/**
1818
* Called during conversion from internal UChar to destination encoding
1919
*/
20-
public function fromUCallback($reason, $source, $codePoint, &$error) {
20+
public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
2121
echo "fromUCallback(", UConverter::reasonText($reason), ", ...)\n";
2222
return parent::fromUCallback($reason, $source, $codePoint, $error);
2323
}

ext/intl/tests/uconverter_oop_callback2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class MyConverter extends UConverter {
99
/**
1010
* Called during conversion from source encoding to internal UChar representation
1111
*/
12-
public function toUCallback($reason, $source, $codeUnits, &$error) {
12+
public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
1313
echo "toUCallback(", UConverter::reasonText($reason), ", ...)\n";
1414
return parent::toUCallback($reason, $source, $codeUnits, $error);
1515
}
1616

1717
/**
1818
* Called during conversion from internal UChar to destination encoding
1919
*/
20-
public function fromUCallback($reason, $source, $codePoint, &$error) {
20+
public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
2121
echo "fromUCallback(", UConverter::reasonText($reason), ", ...)\n";
2222
return parent::fromUCallback($reason, $source, $codePoint, $error);
2323
}

ext/intl/tests/uconverter_oop_callback_return.phpt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,31 @@ UConverter::convert() w/ Callback Return Values
55
--FILE--
66
<?php
77
class MyConverter extends UConverter {
8-
public function toUCallback($reason, $source, $codeUnits, &$error) {
8+
public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
99
$error = U_ZERO_ERROR;
1010
switch ($codeUnits) {
1111
case "\x80": return NULL;
1212
case "\x81": return 'a';
1313
case "\x82": return ord('b');
1414
case "\x83": return array('c');
1515
}
16+
17+
return null;
1618
}
1719

1820
/**
1921
* Called during conversion from internal UChar to destination encoding
2022
*/
21-
public function fromUCallback($reason, $source, $codePoint, &$error) {
23+
public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
2224
$error = U_ZERO_ERROR;
2325
switch ($codePoint) {
2426
case 0x00F1: return "A";
2527
case 0x00F2: return ord("B");
2628
case 0x00F3: return array("C");
2729
case 0x00F4: return NULL;
2830
}
31+
32+
return null;
2933
}
3034

3135
}

ext/json/tests/bug61978.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class JsonTest2 implements JsonSerializable {
1717
public function __construct() {
1818
$this->test = '123';
1919
}
20-
public function jsonSerialize() {
20+
public function jsonSerialize(): mixed {
2121
return array(
2222
'test' => $this->test,
2323
'me' => $this

ext/json/tests/bug66025.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #66025 (Indent wrong when json_encode() called from jsonSerialize function)
44
<?php
55

66
class Foo implements JsonSerializable {
7-
public function jsonSerialize() {
7+
public function jsonSerialize(): mixed {
88
return json_encode([1], JSON_PRETTY_PRINT);
99
}
1010
}

ext/json/tests/bug68992.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
44
<?php
55

66
class MyClass implements JsonSerializable {
7-
public function jsonSerialize() {
7+
public function jsonSerialize(): mixed {
88
throw new Exception('Not implemented!');
99
}
1010
}

ext/json/tests/bug71835.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bug #71835 (json_encode sometimes incorrectly detects recursion with JsonSeriali
33
--FILE--
44
<?php
55
class SomeClass implements JsonSerializable {
6-
public function jsonSerialize() {
6+
public function jsonSerialize(): mixed {
77
return [get_object_vars($this)];
88
}
99
}
@@ -12,7 +12,7 @@ $arr = [$class];
1212
var_dump(json_encode($arr));
1313

1414
class SomeClass2 implements JsonSerializable {
15-
public function jsonSerialize() {
15+
public function jsonSerialize(): mixed {
1616
return [(array)$this];
1717
}
1818
}

ext/json/tests/bug72069.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var_dump($result);
88

99
class A implements \JsonSerializable
1010
{
11-
function jsonSerialize()
11+
function jsonSerialize(): mixed
1212
{
1313
return ['end' => json_decode('', true)];
1414
}

ext/json/tests/bug73113.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Also test that the custom exception is not wrapped by ext/json
66

77
class JsonSerializableObject implements \JsonSerializable
88
{
9-
public function jsonSerialize()
9+
public function jsonSerialize(): mixed
1010
{
1111
throw new \Exception('This error is expected');
1212
}

ext/json/tests/bug77843.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bug #77843: Use after free with json serializer
55

66
class X implements JsonSerializable {
77
public $prop = "value";
8-
public function jsonSerialize() {
8+
public function jsonSerialize(): mixed {
99
global $arr;
1010
unset($arr[0]);
1111
var_dump($this);

ext/json/tests/serialize.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ class NonSerializingTest
1717

1818
class SerializingTest extends NonSerializingTest implements JsonSerializable
1919
{
20-
public function jsonSerialize()
20+
public function jsonSerialize(): mixed
2121
{
2222
return $this->data;
2323
}
2424
}
2525

2626
class ValueSerializingTest extends SerializingTest
2727
{
28-
public function jsonSerialize()
28+
public function jsonSerialize(): mixed
2929
{
3030
return array_values(is_array($this->data) ? $this->data : get_object_vars($this->data));
3131
}
3232
}
3333

3434
class SelfSerializingTest extends SerializingTest
3535
{
36-
public function jsonSerialize()
36+
public function jsonSerialize(): mixed
3737
{
3838
return $this;
3939
}

ext/opcache/tests/bug64353.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ opcache
99
--FILE--
1010
<?php
1111
class BugLoader extends php_user_filter {
12-
public function filter($in, $out, &$consumed, $closing) {
12+
public function filter($in, $out, &$consumed, $closing): int {
1313
if (!class_exists("Test")) {
1414
eval("class Test extends ArrayObject {}");
1515
}

ext/opcache/tests/bug74596.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ file_put_contents(__DIR__ . "/bug74596_2.php", "ok\n");
3232

3333
class ufilter extends php_user_filter
3434
{
35-
function filter($in, $out, &$consumed, $closing)
35+
function filter($in, $out, &$consumed, $closing): int
3636
{
3737
include_once __DIR__ . "/bug74596_1.php";
3838
while ($bucket = stream_bucket_make_writeable($in)) {

0 commit comments

Comments
 (0)