Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PHP NEWS
initialization). (Arnaud)
. Enabled the TAILCALL VM on Windows when compiling with Clang >= 19 x86_64.
(henderkes)
. Deprecate specifying a nullable return type for __debugInfo(). (timwolla)

- BCMath:
. Added NUL-byte validation to BCMath functions. (jorgsowa)
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ PHP 8.6 UPGRADE NOTES
4. Deprecated Functionality
========================================

- Core:
. Specifying a return type of array|null / ?array for __debugInfo() is now
deprecated. Specify array instead.

- GMP
. The shift (<<, >>) and exponentiation (**) operators on GMP objects now
emit a deprecation warning when converting a float right operand to int
Expand Down
7 changes: 7 additions & 0 deletions Zend/tests/debug_info/debug_info.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@ class Bar {
}
}

class Baz {
public function __debugInfo(): ?array {
return null;
}
}

$f = new Foo;
var_dump($f);

$b = new Bar;
var_dump($b);
?>
--EXPECTF--
Deprecated: Returning null from Baz::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead in %s on line %d
object(Foo)#%d (3) {
["a"]=>
int(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ class WidenedArgumentType extends NarrowedReturnType {

echo 'No problems!';
?>
--EXPECT--
--EXPECTF--
Deprecated: Returning null from ValidMagicMethods::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead in %s on line %d
No problems!
7 changes: 6 additions & 1 deletion Zend/tests/return_types/042.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ class JustAnArray {

echo 'No problems!';
?>
--EXPECT--
--EXPECTF--
Deprecated: Returning null from UnionType::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead in %s on line %d

Deprecated: Returning null from UnionType2::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead in %s on line %d

Deprecated: Returning null from UnionTypeOldStyle::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead in %s on line %d
No problems!
4 changes: 4 additions & 0 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -2825,6 +2825,10 @@ ZEND_API void zend_check_magic_method_implementation(const zend_class_entry *ce,
zend_check_magic_method_non_static(ce, fptr, error_type);
zend_check_magic_method_public(ce, fptr);
zend_check_magic_method_return_type(ce, fptr, error_type, (MAY_BE_ARRAY | MAY_BE_NULL));
if ((fptr->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && ZEND_TYPE_PURE_MASK(fptr->common.arg_info[-1].type) & MAY_BE_NULL) {
zend_error(E_DEPRECATED, "Returning null from %s::__debugInfo() is deprecated, make the return type non-nullable and return an empty array instead",
ZSTR_VAL(ce->name));
}
} else if (zend_string_equals_literal(lcname, "__serialize")) {
zend_check_magic_method_args(0, ce, fptr, error_type);
zend_check_magic_method_non_static(ce, fptr, error_type);
Expand Down
2 changes: 1 addition & 1 deletion ext/simplexml/simplexml.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getName(): string {}

public function __toString(): string {}

public function __debugInfo(): ?array {}
public function __debugInfo(): array {}

/** @tentative-return-type */
public function count(): int {}
Expand Down
4 changes: 2 additions & 2 deletions ext/simplexml/simplexml_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading