|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-04 19:46 UTC] tony2001@php.net
[2005-08-04 22:20 UTC] sniper@php.net
[2005-08-04 22:50 UTC] sniper@php.net
[2005-08-05 09:52 UTC] dmitry@php.net
[2005-08-05 11:35 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ When passing an invalid value as a typed argument (as in ! ($argument instanceof typedclass)), a Fatal Error is given, with the following information: Fatal error: Argument 1 must be an object of class Foo in index.php on line 7 The problem is line 7 is the declaration of the function, not the line of code that called the function. It makes bug tracing on a big project next to impossible! Even using ZDE Professional has the same results: I cannot find the function that caused the error (and since the error is fatal, there is no more stack for me to look at). The same goes for missing arguments. Reproduce code: --------------- <?php class Foo { // nothing } function FooTest(Foo $foo) { echo "Hello!"; } function NormalTest($a) { echo "Hi!"; } NormalTest(); FooTest(); FooTest(new Foo()); ?> Expected result: ---------------- Warning: Missing argument 1 for NormalTest() in /.../index.php on line 17 Hi! Warning: Argument 1 must be an object of class Foo in /.../ index.php on line 18 Actual result: -------------- Warning: Missing argument 1 for NormalTest() in /.../index.php on line 12 Hi! Fatal error: Argument 1 must be an object of class Foo in /.../index.php on line 7