[php-src] Issue #14494: `set_error_handler` should accept "only globally callable callback"

From: Date: Fri, 07 Jun 2024 07:38:35 +0000
Subject: [php-src] Issue #14494: `set_error_handler` should accept "only globally callable callback"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247055@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/14494 Author: mvorisek ### Description see https://github.com/sebastianbergmann/phpunit/issues/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" ... ```

« previous php.bugs (#247055) next »