#44660 [Asn->Csd]: Indexed and reference assignment to propery of non-object don't trigger warning
| From: | dmitry@php.net | Date: | Sat, 26 Jul 2008 18:00:51 +0000 |
| Subject: | #44660 [Asn->Csd]: 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-127287@lists.php.net to get a copy of this message | ||
ID: 44660
Updated by: dmitry@php.net
Reported By: robin_fernandes at uk dot ibm dot com
-Status: Assigned
+Status: Closed
Bug Type: Scripting Engine problem
PHP Version: 5.3CVS-2008-04-07 (snap)
Assigned To: dmitry
New Comment:
Fixed in CVS HEAD and PHP_5_3.
Previous Comments:
------------------------------------------------------------------------
[2008-07-21 12:15:15] pajoye@php.net
Not Os specific. Bug still present in 5.3/HEAD.
------------------------------------------------------------------------
[2008-04-07 13:24:08] robin_fernandes at uk dot ibm dot com
Expected & actual result should be the other way around: the warnings
for reference and indexed assignments are currently missing.
Sorry!
------------------------------------------------------------------------
[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