Req #65656 [Opn]: Error message when type hinting is ambigious
| From: | cmb@php.net | Date: | Sun, 04 Feb 2018 21:58:41 +0000 |
| Subject: | Req #65656 [Opn]: Error message when type hinting is ambigious | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213808@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65656&edit=1
ID: 65656
Updated by: cmb@php.net
Reported by: ss23 at ss23 dot geek dot nz
Summary: Error message when type hinting is ambigious
Status: Open
Type: Feature/Change Request
-Package: *General Issues
+Package: Scripting Engine problem
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
FTR: this is in the progress of being resolved. PR 3071 has
already been accepted, and there is PR 3073 would solve the issue
wrt. to boolean.
Previous Comments:
------------------------------------------------------------------------
[2013-09-12 01:07:25] aharvey@php.net
Makes sense to me.
Pull request implementing this on master for someone with Zend karma:
https://github.com/php/php-src/pull/442
------------------------------------------------------------------------
[2013-09-12 00:29:13] ss23 at ss23 dot geek dot nz
Description:
------------
When you type hint with a name of a type PHP has, the error message is ambiguous
and confusing.
Test script:
---------------
function foo(boolean $bar) {
var_dump($bar);
}
foo(true);
Expected result:
----------------
Catchable fatal error: Argument 1 passed to foo() must be an instance of the class
boolean, non-class of type boolean given, called in /code/VhrCdK on line 11 and
defined in /code/VhrCdK on line 3
This is just my first thoughts on how to make it less confusing. Other suggestions
would be apperciated.
Actual result:
--------------
Catchable fatal error: Argument 1 passed to foo() must be an instance of boolean,
boolean given, called in /code/VhrCdK on line 11 and defined in /code/VhrCdK on
line 3
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65656&edit=1