Skip to content

Could not catch deprecation notice from IntlDateFormatter() #8115

Closed

Description

@xmav

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

Activity

  1. iluuu1994 commented on Feb 18, 2022

    @iluuu1994
    Member

    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.

  2. added a commit that references this issue on Mar 3, 2022
    925a309
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions