#44313 [NEW]: inconsistencies in property assignation on scalar variables
| From: | johann dot queuniet at gmail dot com | Date: | Sun, 02 Mar 2008 18:19:19 +0000 |
| Subject: | #44313 [NEW]: inconsistencies in property assignation on scalar variables | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-122844@lists.php.net to get a copy of this message | ||
From: johann dot queuniet at gmail dot com
Operating system: All
PHP version: 5.2.5
PHP Bug Type: Class/Object related
Bug description: inconsistencies in property assignation on scalar variables
Description:
------------
The way PHP handles property assignation on scalar variables evaluating
as false is inconsistent.
Reproduce code:
---------------
<?php
$var1->test = true;
$var2 = null;
$var2->test = true;
$var3 = false;
$var3->test = true;
$var3 = '';
$var3->test = true;
$var4 = 0;
$var4->test = true;
$var5 = '0';
$var5->test = true;
$var6 = array();
$var6->test = true;
?>
Expected result:
----------------
PHP should handle every case the same way, with a "Warning: Attempt to
assign property of non-object". The first line should also trigger a
notice since the $var1 variable is undeclared.
Actual result:
--------------
PHP behaves as with arrays and only triggers a warning for the last
three. The other lines create an stdClass object with the test property
set.
--
Edit bug report at http://bugs.php.net/?id=44313&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44313&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44313&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44313&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44313&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44313&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44313&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44313&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44313&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44313&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44313&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44313&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44313&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44313&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44313&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44313&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44313&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44313&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44313&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44313&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44313&r=mysqlcfg