Edit report at https://bugs.php.net/bug.php?id=51882&edit=1
ID: 51882
Comment by: binarycleric at gmail dot com
Reported by: jacob at mediashaker dot com
Summary: Call To Member Function on Non-Object Should Throw
An Exception
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: Centos 5.3
PHP Version: 5.2.13
Block user comment: N
Private report: N
New Comment:
I disagree with changing this from being a fatal error.
Trying to call a method on an object that doesn't exist should always result in
a fatal error because you are
especially calling non-existent code. Trying to call a procedural function that
doesn't exist should result in the
same behavior. I personally wouldn't want anything other than a fatal error to
occur if I tried to call
"some_import_func($herp, $derp);" and it didn't exist, because there is really
no sane way to recover from that. We
have "function_exists" and "method_exists" for a reason.
If you are having constant problems like this with your code then that is
usually a symptom of a larger problem in
how your application is structured. There are hacks and workarounds to get
stacktrace information after a fatal
error using things like "register_shutdown_function", but your code really
shouldn't try to "recover" from a failure
that catastrophic.
I don't mean for this comment to have an "internet toughguy" additude, I'm just
trying to show you that your code
may have more serious problems then you realize. You already have a good
number
of tools in your toolbox, you just
need to learn to use them better.
Previous Comments:
------------------------------------------------------------------------
[2010-05-21 19:19:32] jacob at mediashaker dot com
Description:
------------
Call to a member function on a non-object is one of the most common reasons a
php script might crash.
Granted, there's often a whole chain of responsibility that falls apart for it
to get to this point.
The problem with this fatal error is that it provides absolutely no debugging
or traceback information when it happens. PHP blows up on fatal errors and all
you're left with is a line number and no idea how it got there.
It would be awesome if it threw an exception with it's requisite traceback
information.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=51882&edit=1