#44660 [Opn]: Indexed and reference assignment to propery of non-object don't trigger warning
| From: | robin_fernandes at uk dot ibm dot com | Date: | Mon, 07 Apr 2008 13:24:08 +0000 |
| Subject: | #44660 [Opn]: Indexed and reference assignment to propery of non-object don't trigger warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124046@lists.php.net to get a copy of this message | ||
ID: 44660
User updated by: robin_fernandes at uk dot ibm dot com
Reported By: robin_fernandes at uk dot ibm dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Windows
PHP Version: 5.3CVS-2008-04-07 (snap)
New Comment:
Expected & actual result should be the other way around: the warnings
for reference and indexed assignments are currently missing.
Sorry!
Previous Comments:
------------------------------------------------------------------------
[2008-04-07 13:22:01] robin_fernandes at uk dot ibm dot com
Description:
------------
Attempting to read or write to a property of a (non-empty) non-object
usually results in a notice or a warning.
However, no warning or notice is raised when performing an indexed or
reference assignment. Consequently, the assignment fails silently.
Confirmed on 5_2, 5_3 and HEAD snaps.
Reproduce code:
---------------
<?php
$s = "hello";
$a = true;
echo "--> read access: ";
echo $a->p;
echo "\n--> direct assignment: ";
$a->p = $s;
echo "\n--> increment: ";
$a->p++;
echo "\n--> reference assignment:";
$a->p =& $s;
echo "\n--> indexed assignment:";
$a->p[0] = $s;
echo "\n\n\n--> Confirm assignments have had no impact:";
var_dump($a, $a->p);
?>
Expected result:
----------------
--> read access:
Notice: Trying to get property of non-object in %s on line 6
--> direct assignment:
Warning: Attempt to assign property of non-object in %s on line 9
--> increment:
Warning: Attempt to increment/decrement property of non-object in %s on
line 12
--> reference assignment:
--> indexed assignment:
--> Confirm assignments have had no impact:
Notice: Trying to get property of non-object in %s on line 21
bool(true)
NULL
Actual result:
--------------
--> read access:
Notice: Trying to get property of non-object in %s on line 6
--> direct assignment:
Warning: Attempt to assign property of non-object in %s on line 9
--> increment:
Warning: Attempt to increment/decrement property of non-object in %s on
line 12
--> reference assignment:
Warning: Attempt to assign property of non-object in %s on line 15
--> indexed assignment:
Warning: Attempt to assign property of non-object in %s on line 18
--> Confirm assignments have had no impact:
Notice: Trying to get property of non-object in %s on line 21
bool(true)
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44660&edit=1