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
 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 19:01:36 2025 UTC