mirror of
https://github.com/php/php-src.git
synced 2024-12-15 12:54:57 +08:00
3eeeeeb104
When adding the #[ReturnTypeWillChange] attribute in namespaced code, you also need to use ReturnTypeWillChange, otherwise it will be silently ignored and may result in confusion. Change the deprecation message to suggest #[\ReturnTypeWillChange], which will always work. Closes GH-7454.
24 lines
782 B
PHP
24 lines
782 B
PHP
--TEST--
|
|
Deprecation promoted to exception should result in fatal error during inheritance
|
|
--SKIPIF--
|
|
<?php
|
|
if (getenv('SKIP_PRELOAD')) die('skip Error handler not active during preloading');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
set_error_handler(function($code, $message) {
|
|
throw new Exception($message);
|
|
});
|
|
|
|
$class = new class extends DateTime {
|
|
public function getTimezone() {}
|
|
};
|
|
|
|
?>
|
|
--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
|
|
Stack trace:
|
|
#0 %s(%d): {closure}(8192, 'Return type of ...', '%s', 8)
|
|
#1 {main} in %s on line %d
|