php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34452 __set type hinting does not provide enough information
Submitted: 2005-09-10 09:11 UTC Modified: 2005-09-12 11:35 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: stochnagara at hotmail dot com Assigned: dmitry (profile)
Status: Wont fix Package: Class/Object related
PHP Version: 5CVS-2005-09-10 (snap) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 + 12 = ?
Subscribe to this entry?

 
 [2005-09-10 09:11 UTC] stochnagara at hotmail dot com
Description:
------------
This problem is about the error message shown when a type hinting parameter is incorrect and fatal error occurs.

There was a recent changed which enhanced the error message to show the caller of the function/methos which caused a fatal error and debugging became much easier since then.

But there is one case where the additional information is not provided - when __set method is called magically. See example below.

As you may see, the 'defined in ...' statement is missing.

Reproduce code:
---------------
<?
class foo {}

class demo {
	function __set ($name, foo $abc) {}
	function set ($name, foo $abc) {}
}

$demo = new demo;

/* CASE 1 */
$demo->set ('abc', null);

/* CASE 2 */
$demo->__set ('abc', null);

/* CASE 3 */
$demo->abc = null;


Expected result:
----------------
in case 1:

Fatal error: Argument 2 must not be null, called in ...\test.php on line 10 and defined in ...\test.php on line 6

in case 2:

Fatal error: Argument 2 must not be null, called in ...\test.php on line 11 and defined in ...\test.php on line 5

in case 3:

Fatal error: Argument 2 must not be null, called in ...\test.php on line 12 and defined in ...\test.php on line 5



Actual result:
--------------
in case 1:

Fatal error: Argument 2 must not be null, called in ...\test.php on line 10 and defined in ...\test.php on line 6

in case 2:

Fatal error: Argument 2 must not be null, called in ...\test.php on line 11 and defined in ...\test.php on line 5

in case 3:

Fatal error: Argument 2 must not be null in ...\test.php on line 5


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-10 23:27 UTC] sniper@php.net
Dmitry, can you fix this?

 [2005-09-12 11:35 UTC] dmitry@php.net
We should live with current behavior, because __set() is called implicity. There is no call and second parameter in "$demo->abc = null;".

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 00:01:32 2024 UTC