ID: 45689
Updated by: [EMAIL PROTECTED]
Reported By: joe at calledtoconstruct dot net
-Status: Open
+Status: Wont fix
Bug Type: Feature/Change Request
Operating System: n/a
PHP Version: 5.3.0alpha1
New Comment:
We will not implement operator overloading in PHP.
Previous Comments:
------------------------------------------------------------------------
[2008-08-02 14:40:07] joe at calledtoconstruct dot net
Description:
------------
In addition to the existing __call, __set, __get, etc... it would be
Very nice to have:
__add : for code that uses the + and += operators
__subtract : for code that uses the - and -= operators
__multiply : * and *=
__divide : / and /=
and
__concat (or __concatinate) for . and .= operators
Expected result:
----------------
So that we can now write:
$objFoo = new Foo();
$objBar = new Bar();
A) $objFoo += $objBar;
or
B) $objFoo += "fooBar";
or
C) $objFoobar = $objFoo + $objBar;
which would be equivellent to writing:
A: $objFoo = $objFoo->__add($objBar);
B: $objFoo = $objFoo->__add("fooBar");
C: $objFoobar = $objFoo->__add($objBar);
In my specific case (the task I'm trying to accomplish, which brought
about this idea), I'm doing:
$objFoo->value .= "something";
which, I imagine, would perform:
$tempOne = $objFoo->__get("value");
$tempTwo = $tempOne->__concat("something");
$objFoo->__set("value", $tempTwo);
because $tempOne might be an object.
Actual result:
--------------
PHP is Awesome!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45689&edit=1