ID: 29930
Updated by: [email]bjoriphp.net[/email]
Reported By: reiersol at online dot no
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: any
PHP Version: 5.0.1
New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
[url]http://snaps.php.net/[/url].

Thank you for the report, and for helping us make PHP better.

Catchable fatal error: Argument 1 passed to Foo::process()
must be an instance of Bar, instance of Baz given, called
in...


Previous Comments:
------------------------------------------------------------------------

[2004-09-01 13:56:35] reiersol at online dot no

Description:
------------
When you have a type-hint error, the error message reports only the
class the object should be, not the type it actually is:

Argument 1 must be an instance of Bar in hints.php on line 3

My experience so far indicates it would be tremendously helpful in
debugging to know what class the object actually belongs to. As it is,
I have to to *remove* the type hint and add a test inside the method to
get that information. (I typically throw an exception to get a full
stack trace.)


Reproduce code:
---------------
class Foo {
public function process(Bar $bar) {}
}
class Bar {}
class Baz {}
$foo = new Foo;
$foo->process(new Baz);


Expected result:
----------------
Desired result:

Argument 1 is an instance of Baz, must be an instance of Bar in
hints.php on line 3

Actual result:
--------------
Argument 1 must be an instance of Bar in hints.php on line 3


------------------------------------------------------------------------


--
Edit this bug report at [url]http://bugs.php.net/?id=29930&edit=1[/url]