Skip to content

Fully qualify ReturnTypeWillChange in deprecation message #7454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $class = new class extends DateTime {

?>
--EXPECTF--
Fatal error: During inheritance of DateTime: Uncaught Exception: Return type of DateTime@anonymous::getTimezone() should either be compatible with DateTime::getTimezone(): DateTimeZone|false, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s:%d
Fatal error: During inheritance of DateTime: Uncaught Exception: Return type of DateTime@anonymous::getTimezone() should either be compatible with DateTime::getTimezone(): DateTimeZone|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s:%d
Stack trace:
#0 %s(%d): {closure}(8192, 'Return type of ...', '%s', 8)
#1 {main} in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/tentative_type_early_binding.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ class Test extends SplObjectStorage {
}
?>
--EXPECTF--
Deprecated: Return type of Test::valid() should either be compatible with SplObjectStorage::valid(): bool, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d
Deprecated: Return type of Test::valid() should either be compatible with SplObjectStorage::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d

Fatal error: Could not check compatibility between Test::current(): Unknown and SplObjectStorage::current(): object, because class Unknown is not available in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class MyDateTimeZone extends DateTimeZone
var_dump(MyDateTimeZone::listIdentifiers());
?>
--EXPECTF--
Deprecated: Return type of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): string should either be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d
Deprecated: Return type of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): string should either be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d
string(0) ""
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class MyDateTimeZone extends DateTimeZone
}
?>
--EXPECTF--
Deprecated: Return type of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) should either be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array, or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d
Deprecated: Return type of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) should either be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in %s on line %d
2 changes: 1 addition & 1 deletion Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ static void ZEND_COLD emit_incompatible_method_error(
if (!return_type_will_change_attribute) {
zend_error_at(E_DEPRECATED, func_filename(child), func_lineno(child),
"Return type of %s should either be compatible with %s, "
"or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice",
"or the #[\\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice",
ZSTR_VAL(child_prototype), ZSTR_VAL(parent_prototype));
if (EG(exception)) {
zend_exception_uncaught_error(
Expand Down