ID: 36675
User updated by: iain at iaindooley dot com
Reported By: iain at iaindooley dot com
-Status: Bogus
+Status: Open
Bug Type: Feature/Change Request
Operating System: FreeBSD 6.0
PHP Version: 5.1.3RC3-dev
New Comment:
Yes, I had already stated that I could not recreate a simple test case,
please read the entire bug report. I've also provided a hacked patch
which stops the notice from appearing, although I'm informed by TML in
##php that what I have done is wrong, and doesn't actually 'fix'
anything.
I've updated most of my code to use is_object instead of boolean
comparisons to get around this, but it pops up from time to time.
Previous Comments:
------------------------------------------------------------------------
[2006-11-11 01:09:16] [EMAIL PROTECTED]
<?php
class test {
}
$var = new test;
var_dump($var == "");
var_dump($var == "non-empty");
?>
works perfectly fine.
------------------------------------------------------------------------
[2006-04-10 23:45:15] iain at iaindooley dot com
this hasn't been assigned yet and it will be a real inconvenience if
this is not fixed in the next major release.
as i've stated in the bug report, using the same behaviour in
zend_operators.c for function:
ZEND_API void convert_to_long_base(zval *op, int base)
for compatibility mode fixes this problem. the title of this bug report
is "Cannot use an object with boolean expression", not "Cannot compare
object to empty string".
so far i don't think this issue has received the attention it requires.
------------------------------------------------------------------------
[2006-04-07 09:29:15] iain at iaindooley dot com
Yes, the line:
if($this->top_reference == $ref)
also causes the error, and changing the code in zend_operators.c as i
posted fixed the problem.
doing:
$var = FALSE;
if($some_other_var)
$var = new SomeObject();
if($var)
echo('we got here');
makes perfect sense, this is a bug.
------------------------------------------------------------------------
[2006-04-07 09:21:28] [EMAIL PROTECTED]
>this same notice is also caused by:
>if($obj1 == $obj2)
Did you try it? Please try and see.
>please do not dismiss a bug without properly understanding
> what is going on.
Please don't claim anything if you didn't check it out yourself.
>if this is sensless then why doesn't it fail with the
>simple test case i provided?
Because you're comparing objects to '', which is autoconverted to
FALSE.
Try to compare objects to non-empty strings and you'll the expected
warning.
It MAY change in the future, but this is not a bug, because comparing
circles to squares doesn't make any sense.
------------------------------------------------------------------------
[2006-04-07 08:48:57] iain at iaindooley dot com
haha i just notice that you (tony2001) were the one who stated:
Dmitry, I guess we need to return at least objects index in this
case.
Or maybe use the same way we use when compatibility_mode is on.
What do you think?
which is clearly what my patch does, which has somehow been undone in
later versions.
why would you dismiss such a thourough bug report as being senseless??
you could at least have the decency to forward it on to someone else.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/36675
--
Edit this bug report at http://bugs.php.net/?id=36675&edit=1