php-src
php-src copied to clipboard
Could not catch deprecation notice from IntlDateFormatter()
Description
The following code:
error_reporting(E_ALL);
set_error_handler(function ($errNo, $errStr) {echo 'Handle ' . $errStr;});
str_contains("test", null);
new \IntlDateFormatter('en_US', 0, null);
<?php
Resulted in this output:
Handle str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated
PHP Deprecated: IntlDateFormatter::__construct(): Passing null to parameter #3 ($timeType) of type int is deprecated in dep.php on line 5
Deprecated: IntlDateFormatter::__construct(): Passing null to parameter #3 ($timeType) of type int is deprecated in dep.php on line 5
But I expected this output instead:
Handle str_contains(): Passing null to parameter #2 ($needle) of type string is deprecated
Handle IntlDateFormatter::__construct(): Passing null to parameter #3 ($timeType) of type int is deprecated in dep.php on line 5
PHP Version
PHP 8.1.0
Operating System
No response
The problem occurs here:
https://github.com/php/php-src/blob/90e4d5456b393a692d4de751561b349d4a9e7b88/ext/intl/dateformat/dateformat_create.cpp#L204-L208
Arguments are parsed in datefmt_ctor but zend_replace_error_handling replaces the error handler before that. Usually zend_replace_error_handling is only called after arguments are already parsed.