php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52139 Method name conflict
Submitted: 2010-06-22 11:01 UTC Modified: 2010-08-07 01:57 UTC
Votes:4
Avg. Score:4.2 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: juwe at clasennet dot de Assigned:
Status: Wont fix Package: SPL related
PHP Version: Irrelevant OS: Doesn't matter
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juwe at clasennet dot de
New email:
PHP Version: OS:

 

 [2010-06-22 11:01 UTC] juwe at clasennet dot de
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-07 01:57 UTC] johannes@php.net
-Status: Open +Status: Wont fix
 [2010-08-07 01:57 UTC] johannes@php.net
We can't "simply" rename them unfortunately.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC