Plugin Development: extending a vendor plugin
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.