From: Operating system: Doesn't matter PHP version: Irrelevant Package: SPL related Bug Type: Feature/Change Request Bug description:Method name conflict
Description: ------------ Could you please solve the method name conflict between SplObjectStorage ans SplSubject? Since SplObjectStorage is the closest available thing to an object map, it is a prior candidate to being a subject in an observer design pattern. Since both, the interface and the class itself use the method names attach and detach, this constellation isn't really feasible at the moment. Please take a look at the example below. Neither attach(), nor detach() are really necessary for SplObjectStorage. Both their behavior could be implemented using offsetSet() and offsetUnset(). If they are necessary at all, could you please call them append() and remove() for example? Or could you maybe add a suffix "Observer(s)" to the methods of SplSubject? Both would enable us to implement the observer design pattern on SplObjectStorage in derived classes. Test script: --------------- class MyObjectMap extends SplObjectStorage implements SplSubject { public function offsetSet($key,$value) { // check types of $key and $value and call parent method } public function offsetGet($key,$value) { // check existance of $key and return result of public method } public function attach(SplObserver o) // fails with a naming conflict { // store observer for later notification } } class MyObjectMapHandler implements SplObserver { // implements update method and reacts to changes of MyObjectMap } Expected result: ---------------- A possibility to have observable lists, as it is possible with classes derived from ArrayObject, SplHeap, and so on Actual result: -------------- Probably: An error message because of the name clash. -- Edit bug report at http://bugs.php.net/bug.php?id=52139&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52139&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52139&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52139&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52139&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52139&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52139&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52139&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52139&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52139&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52139&r=support Expected behavior: http://bugs.php.net/fix.php?id=52139&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52139&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52139&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52139&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52139&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52139&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52139&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52139&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52139&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52139&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52139&r=mysqlcfg