Skip to content

set_error_handler should accept "only globally callable callback"Β #14494

@mvorisek

Description

@mvorisek

Description

see sebastianbergmann/phpunit#5844

set_error_handler (and set_exception_handler, maybe even more handlers) should accept only callables callable from any context. Accepting any callable like php does not is dangerous and unwanted, the error/exception can from any context.

I would expect php to evaluate "if the callable is callable" in global context on set phase.

repro: https://3v4l.org/mZ9E3

Resulted in this output:

...
Fatal error: Uncaught Error: Invalid callback Foo\SomeExternalDependency::logError, cannot access private
method Foo\SomeExternalDependency::logError()
...

But I expected this output instead:

Fatal error: Uncaught TypeError: set_error_handler(): Argument #1 ($callback) must be a valid globally
callable callback or null, Foo\SomeExternalDependency::logError() method is private"
...

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