From:             pornel at despammed dot com
Operating system: any
PHP version:      5.0.3
PHP Bug Type:     Feature/Change Request
Bug description:  Type hinting still a useless feature

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 bug report at http://bugs.php.net/?id=32505&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32505&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32505&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32505&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32505&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32505&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32505&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32505&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32505&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32505&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32505&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32505&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32505&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32505&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32505&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32505&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32505&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32505&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32505&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32505&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32505&r=mysqlcfg

Reply via email to