Bug #67509 [NEW]: set_error_handler ignores class scope

From: Date: Wed, 25 Jun 2014 00:20:33 +0000
Subject: Bug #67509 [NEW]: set_error_handler ignores class scope
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186330@lists.php.net to get a copy of this message
From: tugrultopuz at gmail dot com Operating system: Debian 7.2 PHP version: 5.4.29 Package: Scripting Engine problem Bug Type: Bug Bug description:set_error_handler ignores class scope Description: ------------ I tried to send static method of a class as the callback. Test script: --------------- <?php namespace My; class Exception extends \Exception { protected $context; public static function setErrorHandler() { set_error_handler('static::_errorHandler'); } public static function restoreErrorHandler() { return restore_error_handler(); } protected static function _errorHandler($number, $message, $file, $line, $context) { self::restoreErrorHandler(); $exception = new static($message, $number); $exception->file = $file; $exception->line = $line; $exception->context = $context; throw $exception; } } \My\Exception::setErrorHandler(); try { trigger_error('My custom error!'); } catch (\My\Exception $ex) { echo 'Error Message:', $ex->getMessage(); } \My\Exception::restoreErrorHandler(); Expected result: ---------------- Error Message: My custom error! Actual result: -------------- Warning: Invalid callback static::_errorHandler, cannot access static:: when no class scope is active in test.php on line 17 -- Edit bug report at https://bugs.php.net/bug.php?id=67509&edit=1 --

« previous php.bugs (#186330) next »