What are the limitations of using inheritance to extend the functionality of classes like SimpleXMLElement in PHP?
Using inheritance to extend the functionality of classes like SimpleXMLElement in PHP can lead to tight coupling between classes, making the code less flexible and harder to maintain. Instead, it's recommended to use composition over inheritance to achieve the desired functionality without creating a rigid class hierarchy.
class CustomXmlParser {
private $xml;
public function __construct(SimpleXMLElement $xml) {
$this->xml = $xml;
}
public function customFunctionality() {
// Implement custom functionality here
}
}