|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69841 Feature: Catchable "call to a member function of a non-object" is not working
Submitted: 2015-06-15 16:41 UTC Modified: 2015-06-15 16:50 UTC
From: davelhs03 at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.0alpha1 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: davelhs03 at yahoo dot com
New email:
PHP Version: OS:


 [2015-06-15 16:41 UTC] davelhs03 at yahoo dot com
In the RFC ( set_error_handler was suppose to catch calls to methods on a non-object.  I'm not experiencing that when I use PHP7 Alpha1 ( on Windows 7.  I tried it on the command line and via the built in web server.  I can catch the exception if I do a try and catch (EngineException $e) block, but not with the error handler.

//This Works:
$x= null;
catch (EngineException $e)
echo 'caught the exception';

Test script:
set_error_handler(function($code, $message) {
  var_dump($code, $message);
$x= null;
echo "Alive\n";

Expected result:
string(50) "Call to a member function method() on a non-object"

Actual result:
Fatal error: Uncaught EngineException: Call to a member function method() on nul
l in C:\PHP7\scripts\test.php:6
Stack trace:
#0 {main}
  thrown in C:\PHP7\scripts\test.php on line 6


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-15 16:50 UTC]
-Status: Open +Status: Not a bug
 [2015-06-15 16:50 UTC]
The linked RFC has been superseded by, which does not allow handling these using set_error_handler. You must either catch the exception or use set_exception_handler.
 [2015-06-15 16:57 UTC] davelhs03 at yahoo dot com

Thanks for the quick reply and answer!

Anyway you can put that comment in the wiki so others don't fall into looking at out-dated documentation.
 [2015-06-15 17:11 UTC]
@dacelhs03: Sure, I've added a note at the top.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 02:05:53 2022 UTC