#29930 [Opn->Csd]: Type hint error message should reveal both class names
| From: | bjori@php.net | Date: | Mon, 18 Sep 2006 15:02:39 +0000 |
| Subject: | #29930 [Opn->Csd]: Type hint error message should reveal both class names | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102333@lists.php.net to get a copy of this message | ||
ID: 29930
Updated by: bjori@php.net
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
http://snaps.php.net/.
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 http://bugs.php.net/?id=29930&edit=1