From: [EMAIL PROTECTED]
Operating system: Windows XP
PHP version: 4.2.3
PHP Bug Type: Class/Object related
Bug description: Class without member variables gives "empty"/"null" objects
take the following example:
<?php
class MethodsOnly {
//var $dummy;
function doSomething() {
print("OBJ: doing something\n");
}
}// class
$OBJ = new MethodsOnly();
$OBJ->doSomething();
print("empty(OBJ): ".(empty($OBJ) ? "true" : "false")."\n");
print("OBJ == null: ".(($OBJ == null) ? "true" : "false")."\n");
print("OBJ === null: ".(($OBJ === null) ? "true" : "false")."\n");
?>
it gives the following output:
OBJ: doing something
empty(OBJ): true
OBJ == null: true
OBJ === null: false
now, if you uncomment the $dummy member variable:
OBJ: doing something
empty(OBJ): false
OBJ == null: false
OBJ === null: false
Sure, one should/could use "static calls" - like
MethodsOnly::doSomething() - in this case (class without member vars), but
we discovered this when migrating a project from PHP3 to PHP4
.. and, anyway, shouldn't an existing object behave the same wether it has
member variables or not? ;)
--
Edit bug report at http://bugs.php.net/?id=20932&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20932&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20932&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20932&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20932&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20932&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20932&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20932&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20932&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20932&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20932&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20932&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20932&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20932&r=isapi