|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-02 15:09 UTC] derick@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 20:00:01 2025 UTC |
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!