ID: 32505
Updated by: [EMAIL PROTECTED]
Reported By: pornel at despammed dot com
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: any
PHP Version: 5.0.3
New Comment:
Fixed long time ago:
.. called in <file> on line 7 and defined in <file> on line 3
Previous Comments:
------------------------------------------------------------------------
[2005-03-30 17:19:16] pornel at despammed dot com
Description:
------------
Fatal error: Argument $n must (not be null|be an object of class $c) in
$location_of_called_function
These errros point to location of called function, but not to location
*where it was called from*.
In most cases fault is in calling code, not function declaration, so
given file/line is irrelevant.
The problem is that it is not possible to figure out where from the
function has been called and actually makes type hinting more harmful
than useful.
Previous WONTFIX bug is wrong (#28001), because it's not possible to
use debug_backtrace() it this situation.
WONTFIX bug #31578, concludes that debug_backtrace() doesn't work here
by design.
One similar bug says it has been fixed long time ago (#27290), but
actually the original problem is not yet fixed (see testcase).
The solution is to make type hint error non-fatal (so handler and
debug_backtrace can be used) or report location of calling function
(back up one level on stack).
Reproduce code:
---------------
<?php
function Foo(Bar $x) // definition, line 3
{
}
Foo(NULL); // call, line 7
Expected result:
----------------
Fatal error: Argument 1 must not be null in test.php on line 7
Actual result:
--------------
Fatal error: Argument 1 must not be null in test.php on line 3
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32505&edit=1