Mention ReturnTypeWillChange attribute in the error message (#7183)

This commit is contained in:
Máté Kocsis 2021-06-28 14:56:21 +02:00 committed by GitHub
parent edc87a5c26
commit 773e9ba5d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View file

@ -13,7 +13,7 @@ $class = new class extends DateTime {
?> ?>
--EXPECTF-- --EXPECTF--
Fatal error: During inheritance of DateTime: Uncaught Exception: Declaration of DateTime@anonymous::getTimezone() should be compatible with DateTime::getTimezone(): DateTimeZone|false 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: Stack trace:
#0 %s(%d): {closure}(8192, 'Declaration of ...', '%s', 8) #0 %s(%d): {closure}(8192, 'Return type of ...', '%s', 8)
#1 {main} in %s on line %d #1 {main} in %s on line %d

View file

@ -13,5 +13,5 @@ class MyDateTimeZone extends DateTimeZone
var_dump(MyDateTimeZone::listIdentifiers()); var_dump(MyDateTimeZone::listIdentifiers());
?> ?>
--EXPECTF-- --EXPECTF--
Deprecated: Declaration of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): string should be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array 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) "" string(0) ""

View file

@ -10,4 +10,4 @@ class MyDateTimeZone extends DateTimeZone
} }
?> ?>
--EXPECTF-- --EXPECTF--
Deprecated: Declaration of MyDateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) should be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array 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

View file

@ -875,7 +875,8 @@ static void ZEND_COLD emit_incompatible_method_error(
if (!return_type_will_change_attribute) { if (!return_type_will_change_attribute) {
zend_error_at(E_DEPRECATED, NULL, func_lineno(child), zend_error_at(E_DEPRECATED, NULL, func_lineno(child),
"Declaration of %s should be compatible with %s", "Return type of %s should either be compatible with %s, "
"or the #[ReturnTypeWillChange] attribute should be used to temporarily suppress the notice",
ZSTR_VAL(child_prototype), ZSTR_VAL(parent_prototype)); ZSTR_VAL(child_prototype), ZSTR_VAL(parent_prototype));
if (EG(exception)) { if (EG(exception)) {
zend_exception_uncaught_error( zend_exception_uncaught_error(