From:             packard_bell_nec at hotmail dot com
Operating system: windows server 2003 r2
PHP version:      5.2.5
PHP Bug Type:     Variables related
Bug description:  converting null variable to object type will make the 
variable non empty

Description:
------------
When I write the codes concerning type conversion, I found the entitled
"bug". Then, I check the documentation, and I found the statement "an
object with zero member variables (PHP 4 only) is considered FALSE" in~ 
http://php.net/manual/en/language.types.boolean.php
However, I am NOT going to ask for reopening the above "feature". Instead,
I am going to ask for correcting the "bug" so that "an object with class
stdClass and zero member variables is considered FALSE". The behavior of
empty() should also be changed accordingly. 

The extensions that I used: 
[PHP_GD2]
extension=php_gd2.dll
[PHP_MBSTRING]
extension=php_mbstring.dll
[PHP_MCRYPT]
extension=php_mcrypt.dll
[PHP_MYSQL]
extension=php_mysql.dll
[PHP_MYSQLI]
extension=php_mysqli.dll
[Zend]
zend_extension_ts="C:\Program Files\PHP\lib\ZendExtensionManager.dll"
zend_extension_manager.optimizer_ts="C:\Program
Files\PHP\lib\Optimizer-3.3.0"
zend_extension_manager.debug_server_ts="C:\Program
Files\PHP\lib\Debugger-5.2.10"

Reproduce code:
---------------
$foo = null; settype($foo, 'object');
$cv_foo = get_class_vars(get_class($foo)); $ov_foo =
get_object_vars($foo);
echo gettype($foo).'<br/>'.get_class($foo).'<br/>'.var_export($cv_foo,
true).'<br/>'.var_export($ov_foo,
true).'<br/>'.isset($foo).'<br/>'.!empty($foo).'<br/>'.var_export($foo,
true).'<br/><br/>';
$goo = null; settype($goo, 'array');
echo
gettype($goo).'<br/>'.isset($goo).'<br/>'.!empty($goo).'<br/>'.var_export($goo,
true).'<br/><br/>';
$hoo = false; settype($hoo, 'object');
$cv_hoo = get_class_vars(get_class($hoo)); $ov_hoo =
get_object_vars($hoo);
echo gettype($hoo).'<br/>'.get_class($hoo).'<br/>'.var_export($cv_hoo,
true).'<br/>'.var_export($ov_hoo,
true).'<br/>'.isset($hoo).'<br/>'.!empty($hoo).'<br/>'.var_export($hoo,
true).'<br/><br/>';
$joo = false; settype($joo, 'array');
echo
gettype($joo).'<br/>'.isset($joo).'<br/>'.!empty($joo).'<br/>'.var_export($joo,
true).'<br/><br/>';

Expected result:
----------------
object
stdClass
array (
)
array (
)
1

stdClass::__set_state(array(
))

array
1

array (
)

object
stdClass
array (
)
array (
  'scalar' => false,
)
1
1
stdClass::__set_state(array(
   'scalar' => false,
))

array
1
1
array (
  0 => false,
)

Actual result:
--------------
object
stdClass
array (
)
array (
)
1
1
stdClass::__set_state(array(
))

array
1

array (
)

object
stdClass
array (
)
array (
  'scalar' => false,
)
1
1
stdClass::__set_state(array(
   'scalar' => false,
))

array
1
1
array (
  0 => false,
)

-- 
Edit bug report at http://bugs.php.net/?id=43697&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43697&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43697&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43697&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43697&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43697&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43697&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43697&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43697&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43697&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43697&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43697&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43697&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43697&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43697&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43697&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43697&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43697&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43697&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43697&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43697&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43697&r=mysqlcfg

Reply via email to