From: reiersol at online dot no
Operating system: any
PHP version: 5.0.1
PHP Bug Type: Feature/Change Request
Bug description: Type hint error message should reveal both class names
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 bug report at http://bugs.php.net/?id=29930&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=29930&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=29930&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=29930&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=29930&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=29930&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=29930&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=29930&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=29930&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=29930&r=support
Expected behavior: http://bugs.php.net/fix.php?id=29930&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=29930&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=29930&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=29930&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29930&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=29930&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=29930&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=29930&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29930&r=float