Skip to content

Assertion failure when calling static method of trait with __callStatic() with throwing error handler #17728

Closed
@TimWolla

Description

@TimWolla

Description

The following code:

<?php

set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
    if (!(error_reporting() & $errno)) {
        // This error code is not included in error_reporting.
        return;
    }

    throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});

trait Foo {
    public static function __callStatic($method, $args) {
        var_dump($method);
    }
}

Foo::bar();

Resulted in this output:

Fatal error: Uncaught ErrorException: Calling static trait method Foo::bar is deprecated, it should only be called on a class using the trait in php-src/test5.php:18
Stack trace:
#0 php-src/test5.php(18): {closure}(8192, 'Calling static ...', '...', 18)
#1 {main}
  thrown in php-src/test5.php on line 18
php: php-src/Zend/zend_execute_API.c:489: void shutdown_executor(void): Assertion `(executor_globals.trampoline).common.function_name == ((void*)0) || (compiler_globals.unclean_shutdown)' failed.
fish: Job 1, 'sapi/cli/php test5.php' terminated by signal SIGABRT (Abort)

But I expected this output instead:

Fatal error: Uncaught ErrorException: Calling static trait method Foo::bar is deprecated, it should only be called on a class using the trait in php-src/test5.php:18
Stack trace:
#0 php-src/test5.php(18): {closure}(8192, 'Calling static ...', '...', 18)
#1 {main}
  thrown in php-src/test5.php on line 18

PHP Version

git PHP-8.3

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions