From:             phpbugs at majiclab dot com
Operating system: Mac OSX 10.4
PHP version:      5.0.4
PHP Bug Type:     Scripting Engine problem
Bug description:  No information given for fatal error on passing invalid value 
to typed argument

Description:
------------
When passing an invalid value as a typed argument (as in !
($argument instanceof typedclass)), a Fatal Error is given, 
with the following information:

Fatal error: Argument 1 must be an object of class Foo in 
index.php on line 7

The problem is line 7 is the declaration of the function, not 
the line of code that called the function.  It makes bug 
tracing on a big project next to impossible!  Even using ZDE 
Professional has the same results: I cannot find the function 
that caused the error (and since the error is fatal, there is 
no more stack for me to look at).  The same goes for missing 
arguments.

Reproduce code:
---------------
<?php
class Foo
{
    // nothing
}

function FooTest(Foo $foo)
{
    echo "Hello!";
}

function NormalTest($a)
{
    echo "Hi!";
}

NormalTest();
FooTest();
FooTest(new Foo());
?>

Expected result:
----------------
Warning: Missing argument 1 for NormalTest() in /.../index.php 
on line 17
Hi!
Warning: Argument 1 must be an object of class Foo in /.../
index.php on line 18

Actual result:
--------------
Warning: Missing argument 1 for NormalTest() in /.../index.php 
on line 12
Hi!
Fatal error: Argument 1 must be an object of class Foo 
in /.../index.php on line 7

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

Reply via email to