dimanche 22 février 2015

PHP extended class method requires same signature including object class requirement?


Not sure exactly how to phrase the question succinctly for the title.


I have a collection class that extends another collection class.


The parent collection-class has a method addMember(someClass $obj) that adds an object to the collection.


The child collection-class groups objects of the child class of someclass, someClassChild. I thought that a child class's method's signature would pass muster as long as the signature was the same or required children of the classes the parent required.


E.g. addMember(someClassChild $obj)


But I tried it and I'm getting a warning about strict standards.


So then, how to I implement a collection class as a child of another collection class to provide functionality for parent/child base objects?





Aucun commentaire:

Enregistrer un commentaire