jeudi 19 mars 2015

Cast Object to Subclass in PHP

I'm trying to extend the SimpleXMLElement class to provide a mechanism to merge sub xml string or other SimpleXMLElement into my SimpleXMLElement, code for that is based on http://ift.tt/1BZp2TG


For now I'm adding only a addXml function in subclass (should work analog to the built in addChild by returning the newly created element) but I guess that every function call will return a SimpleXMLElement and not my newly created subclass. Is there a way to downcast in PHP comparable to Java?


edit as someone thought to downvote without any reason: I'm no Java Developer and normally I would't mind even with this kind of problem but SimpleXMLElement is a PHP class so I can't easily wrap it without writing lots of code. Maybe some kind of reflection magic making this possible?






Aucun commentaire:

Enregistrer un commentaire