Bug #69841 [Com]: Feature: Catchable "call to a member function of a non-object" is not working

From: Date: Mon, 15 Jun 2015 16:57:17 +0000
Subject: Bug #69841 [Com]: Feature: Catchable "call to a member function of a non-object" is not working
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193520@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69841&edit=1 ID: 69841 Comment by: davelhs03 at yahoo dot com Reported by: davelhs03 at yahoo dot com Summary: Feature: Catchable "call to a member function of a non-object" is not working Status: Not a bug Type: Bug Package: Scripting Engine problem Operating System: Windows 7 PHP Version: 7.0.0alpha1 Block user comment: N Private report: N New Comment: nikic, 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. https://wiki.php.net/rfc/catchable-call-to-member-of-non-object Previous Comments: ------------------------------------------------------------------------ [2015-06-15 16:50:18] nikic@php.net The linked RFC has been superseded by https://wiki.php.net/rfc/engine_exceptions_for_php7, 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:41:57] davelhs03 at yahoo dot com Description: ------------ In the RFC (https://wiki.php.net/rfc/catchable-call-to-member-of-non-object) set_error_handler was suppose to catch calls to methods on a non-object. I'm not experiencing that when I use PHP7 Alpha1 (http://windows.php.net/downloads/qa/php-7.0.0alpha1-nts-Win32-VC14-x86.zip) 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; try{ var_dump($x->method()); } catch (EngineException $e) { echo 'caught the exception'; } Test script: --------------- set_error_handler(function($code, $message) { var_dump($code, $message); }); $x= null; var_dump($x->method()); echo "Alive\n"; Expected result: ---------------- int(4096) string(50) "Call to a member function method() on a non-object" NULL Alive 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69841&edit=1

« previous php.bugs (#193520) next »