Plugin Development: extending a vendor plugin I'm using composer to import a third-party (vendor) plugin into my own Craft plugin. But can't figure out how I extend the functionality of the imported (vendor) plugin.

For example assuming imported plugin defines a base class of XXX I can try to extend this with class YYY extends \XXX but not sure where I save this so I can access this in my code, eg I want to extend the base plugin through a class, eg

class YYY extends \XXX
{
    public function doThis($str) { return $str; }
}


I'd then want to access this in my Craft plugin with

$var = new \XXX();
$var-&gt;doThis = 'CONTENT HERE';


Obviously grossly simplified but hope you get the gist.
Just can't figure out how to achieve above or where I should save the code that is extending the vendor class?

Any thoughts?
In your example, if you do this:

$var = new \XXX();
$var-&gt;doThis = 'CONTENT HERE';


Then doThis will never exist for class \XXX because \XXX isn't where the method was defined.  It would work from your extended class, though:

$var = new YYY();
$var-&gt;doThis = 'CONTENT HERE';


Keep in mind that (usually) if the vendor plugin instantiates any instances of that class internally, it will always be of instance \XXX, not your YYY class.

Where that wouldn't be true, is if the vendor plugin supports dependency injection where they allow you to inject your extended YYY class wherever \XXX would usually be referenced.