From: joe at calledtoconstruct dot net Operating system: n/a PHP version: 5.3.0alpha1 PHP Bug Type: Feature/Change Request Bug description: Additional magic methods
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 bug report at http://bugs.php.net/?id=45689&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45689&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45689&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45689&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45689&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45689&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45689&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45689&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45689&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45689&r=support Expected behavior: http://bugs.php.net/fix.php?id=45689&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45689&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45689&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45689&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45689&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45689&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45689&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45689&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45689&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45689&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45689&r=mysqlcfg