php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75082 Add interface for SplObjectStorage and use that instead bounding to the class
Submitted: 2017-08-17 08:02 UTC Modified: 2017-11-05 04:22 UTC
From: adaliszk at gmail dot com Assigned:
Status: No Feedback Package: SPL related
PHP Version: 7.1.8 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: adaliszk at gmail dot com
New email:
PHP Version: OS:

 

 [2017-08-17 08:02 UTC] adaliszk at gmail dot com
Description:
------------
So basically if I build my datastructures using SplObjectStorage logic I cannot define properly an interface for my each collection and force usage of a subtype for each of the attach/detach and add/remove methods.

For example I want to build a ProductCollection which expect working with only the same type when adding and removing and also has a boundary to only accept ProductEntity I cannot define the interface properly since the SplObjectStorage is bound to itself not to an interface.

Sure you can do it with abstract classes and define this boundaries but then each of your collection abstractions would be separated from your other interfaces and you loose polymorphic dependencies or you need to drop your architecture and care this differently.

This change should not provide any BC issues, since it's just add interface around the ObjectStorage but it will allow polymorphic interfaces and more tools to design your architecture without implementing code.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-10-19 21:40 UTC] nikic@php.net
-Status: Open +Status: Feedback
 [2017-10-19 21:40 UTC] nikic@php.net
This description is very confusing to me, because I don't understand how having an interface for SplObjectStorage will help you with a ProductCollection based on SplObjectStorage. The ProductCollection will still have to satisfy that interface, which is not possible if you restrict the types of accepted objects and our LSP checks will prohibit it. Something akin to this is only possible using generics. Am I misunderstand this request?
 [2017-11-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC