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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 19:01:33 2024 UTC