php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40721 Overload Comparison Problem
Submitted: 2007-03-05 03:00 UTC Modified: 2007-03-05 10:09 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: rod at pu-gh dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 4.4.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rod at pu-gh dot com
New email:
PHP Version: OS:

 

 [2007-03-05 03:00 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-05 10:09 UTC] tony2001@php.net
You'll have to upgrade to PHP5.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC