Skip to content
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

Could not catch deprecation notice from IntlDateFormatter() #8115

Closed
xmav opened this issue Feb 18, 2022 · 1 comment
Closed

Could not catch deprecation notice from IntlDateFormatter() #8115

xmav opened this issue Feb 18, 2022 · 1 comment

Comments

@xmav
Copy link

xmav commented Feb 18, 2022

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

@iluuu1994
Copy link
Member

iluuu1994 commented Feb 18, 2022

The problem occurs here:

zend_replace_error_handling(EH_THROW, IntlException_ce_ptr, &error_handling);
/* return_value param is being changed, therefore we will always return
* NULL here */
return_value = ZEND_THIS;
if (datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU) == FAILURE) {

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.

iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 18, 2022
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 18, 2022
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 18, 2022
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@iluuu1994 @xmav and others