php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65656 Error message when type hinting is ambigious
Submitted: 2013-09-12 00:29 UTC Modified: 2018-02-05 12:14 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ss23 at ss23 dot geek dot nz Assigned: cmb (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ss23 at ss23 dot geek dot nz
New email:
PHP Version: OS:

 

 [2013-09-12 00:29 UTC] 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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-12 01:07 UTC] 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
 [2018-02-04 21:58 UTC] cmb@php.net
-Package: *General Issues +Package: Scripting Engine problem
 [2018-02-04 21:58 UTC] cmb@php.net
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.
 [2018-02-05 12:14 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2018-02-05 12:14 UTC] cmb@php.net
Since PR 3073 has also been accepted, I'm closing this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 26 04:01:31 2024 UTC