php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #32380 type hinting - error hard to track down
Submitted: 2005-03-20 00:58 UTC Modified: 2006-11-11 02:03 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: freebsd at akruijff dot dds dot nl Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.0.3 OS: FreeBSD
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: freebsd at akruijff dot dds dot nl
New email:
PHP Version: OS:

 

 [2005-03-20 00:58 UTC] freebsd at akruijff dot dds dot nl
Description:
------------
Type hinting prevents passing NULL of non related objects as argument. An error is give on where the function is defined instead of where it is called. This make it hard to track down the bug, because it could be called a 100 times from different files, while only one is wrong.


Reproduce code:
---------------
<?php
  class X {
    public function fa() {}
  }

  class Y {
    public function fb() {}
  }

  function f(X $y) {
    $y->fa();
  }

  f(new Y());
?>


Expected result:
----------------
Would like an error on line 14 [   f(new Y()); ]

Actual result:
--------------
Give an erorr on line 11 [ function f(X $y) ].


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-11 02:03 UTC] tony2001@php.net
Error messages have been improved to contain "called in .. declared in .." long time ago.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 18:01:32 2024 UTC