php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28001 More informative class hinting errors
Submitted: 2004-04-14 23:05 UTC Modified: 2004-04-15 03:28 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: jevon at jevon dot org Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.0.0RC1 OS: XP SP1
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: jevon at jevon dot org
New email:
PHP Version: OS:

 

 [2004-04-14 23:05 UTC] jevon at jevon dot org
Description:
------------
It would be nice for the object type hinting mechanism in PHP5 to, instead of failing with the expected class and line number of the definition, but failing with the expected and actual classes, and the line numbers of the definition AND the call.

Reproduce code:
---------------
<?php

class Foo {
  function zod(Bar $f) { ... }
}

class Bar { }
class Baz { }

$f = new Foo();
$f->zod(new Baz());

?>

Expected result:
----------------
Fatal error: Argument 1 must be an object of class Bar (not Baz) in file.php on line 4, called in Foo::zod() by file.php on line 11

Actual result:
--------------
Fatal error: Argument 1 must be an object of class Bar in file.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-15 03:28 UTC] derick@php.net
If you want this, write your own error handler and use debug_get_backtrace().
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 23:01:28 2025 UTC