php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33996 No information given for fatal error on passing invalid value to typed argument
Submitted: 2005-08-04 17:43 UTC Modified: 2005-08-05 11:35 UTC
From: phpbugs at majiclab dot com Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-08-4 OS: *
Private report: No CVE-ID: None
 [2005-08-04 17:43 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-04 19:46 UTC] tony2001@php.net
Dmitry, could you plz look at it?
I can reproduce it with 5.1 too.
 [2005-08-04 22:20 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

I can NOT reproduce this with latest CVS..
 [2005-08-04 22:50 UTC] sniper@php.net
Nevermind that. I get the same result. (I propably should have eyeglasses or something :)

 [2005-08-05 09:52 UTC] dmitry@php.net
I think this is not a BUG and it shouldn't be fixed.
 [2005-08-05 11:35 UTC] dmitry@php.net
Fixed in CVS HEAD.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC