There is a library with these classes:
- ExternalLibrary/DefaultObject
- ExternalLibrary/ObjectConsumer
- ExternalLibrary/ObjectEater
- ExternalLibrary/ObjectCuddler
- ExternalLibrary/ObjectF**ker
Where
namespace ExternalLibrary;
class DefaultObject {}
class ObjectConsumer {
    protected $object;
    // the oter Object<...> classes have all the same constructor
    public function __construct()
    {
        $this->object = new DefaultObject;
    }
    public function compareWith(DefaultObject $comparand)
    {
        // just a method in order to have another dependency in the type-hinting
    }
}
And there is my library that wants to extend the concepts and functionalities of the external library:
- MyLibrary/DefaultObject
Where
namespace ExternalLibrary;
use ExternalLibrary\DefaultObject as BaseDefaultObject;
class DefaultObject extends BaseDefaultObject {
    // marvelous additional concepts on top of the base concepts
}
Given that I don't want to wrap/extend/override/redefine all the classes that potentially use DefaultObject:
- What options do I have, in PHP, in order to have my custom object to be used everywhere in my library when relying on the external-library?
(e.g. ObjectEater relying on MyLibrary/DefaultObject)
- And what about other languages? Would that be easier?
- And what in the case I were the owner of the external library and could change its code?
 
     
    