Ask a Question related to PHP Bugs, Design and Development.
-
rod at pu-gh dot com #1
#40721 [NEW]: Overload Comparison Problem
From: rod at pu-gh dot com
Operating system: Linux
PHP version: 4.4.6
PHP Bug Type: Scripting Engine problem
Bug description: Overload Comparison Problem
Description:
------------
When overloading a class in php, and then comparing an overloaded property
to the return value of a function call, the result is not what I expected.
If comparing against string literals, or if the result of each is first
assigned to a variable then it's fine.
I tested this with latest CVS of PHP 4.4.7.
Reproduce code:
---------------
<?
class Foo {
function __get( $name, &$value ) {
$value = 'foo';
return true;
}
}
overload( 'Foo' );
class Bar {
function foo() {
return 'bar';
}
}
$foo = new Foo();
$bar = new Bar();
echo 'Test: ' . ( $foo->bar == $bar->foo() ? 'BAD' : 'GOOD' ) . "\n";
?>
Expected result:
----------------
Expected (meaning the comparsion failed):
Test: GOOD
Actual result:
--------------
Actual (meaning the comparsion 'foo' == 'bar' succeeded):
Test: BAD
--
Edit bug report at [url]http://bugs.php.net/?id=40721&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40721&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40721&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40721&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40721&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40721&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40721&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40721&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40721&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40721&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40721&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40721&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40721&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40721&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40721&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40721&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40721&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40721&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40721&r=mysqlcfg[/url]
rod at pu-gh dot com Guest
-
PhP, Access/SQL, Data comparison problem. (I'm new to PhP)
Hi All! I'm fairly new to PhP and basicly trying to learn right now. Now I have a problem - I have a fairly large collection of movies which people... -
a problem on overload
I have a problem on overload, The following is my sample code, class A { draw() { ... //a lot of code } } -
Access SQL- Date comparison problem
I use an Access-database where one column stores a date originating from this code: Indate = FormatDateTime(date(),vbgeneraldate) I then want... -
SqlDataAdapter Problem Overload
This code: <%@ Page Language="vb" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.Odbc" %> <%@ import... -
Overload
came across a doubt or better with something that I am not getting understand. I have a system rotating in a Supermarket, Fiscal Printer and it... -
tony2001@php.net #2
#40721 [Opn->WFx]: Overload Comparison Problem
ID: 40721
Updated by: [email]tony2001@php.net[/email]
Reported By: rod at pu-gh dot com
-Status: Open
+Status: Wont fix
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.4.6
New Comment:
You'll have to upgrade to PHP5.
Previous Comments:
------------------------------------------------------------------------
[2007-03-05 03:00:52] rod at pu-gh dot com
Description:
------------
When overloading a class in php, and then comparing an overloaded
property to the return value of a function call, the result is not what
I expected. If comparing against string literals, or if the result of
each is first assigned to a variable then it's fine.
I tested this with latest CVS of PHP 4.4.7.
Reproduce code:
---------------
<?
class Foo {
function __get( $name, &$value ) {
$value = 'foo';
return true;
}
}
overload( 'Foo' );
class Bar {
function foo() {
return 'bar';
}
}
$foo = new Foo();
$bar = new Bar();
echo 'Test: ' . ( $foo->bar == $bar->foo() ? 'BAD' : 'GOOD' ) . "\n";
?>
Expected result:
----------------
Expected (meaning the comparsion failed):
Test: GOOD
Actual result:
--------------
Actual (meaning the comparsion 'foo' == 'bar' succeeded):
Test: BAD
------------------------------------------------------------------------
--
Edit this bug report at [url]http://bugs.php.net/?id=40721&edit=1[/url]
tony2001@php.net Guest



Reply With Quote

