ID: 33996
User updated by: phpbugs at majiclab dot com
Reported By: phpbugs at majiclab dot com
Status: Assigned
Bug Type: Scripting Engine problem
Operating System: Mac OSX 10.4
PHP Version: 5.0.4
Assigned To: dmitry
New Comment:
I think it's been like this for as long as I can remember
using PHP, just never thought to submit a bug report for it.
On a side note this should maybe be submitted as a separate
bug report it would nice if these kinds of errors (invalid
type, missing arguments) could throw exceptions instead of
raising an error? Maybe that could even be a compile option/
phpini setting or something to keep the current behavior
standard.
Previous Comments:
------------------------------------------------------------------------
[2005-08-04 19:46:03] [EMAIL PROTECTED]
Dmitry, could you plz look at it?
I can reproduce it with 5.1 too.
------------------------------------------------------------------------
[2005-08-04 17:43:45] phpbugs at majiclab dot com
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 this bug report at http://bugs.php.net/?id=33996&edit=1