Interesting post ! Sadly I don't think it is possible to trigger a deprecation in a straightforward way in the case you present. Furthermore I'm not sure this chunk of code will work in all cases:
<?phpif(!class_exists(ShinyNewFoo::class,false)){@trigger_error('LegacyFoo is deprecated!',E_USER_DEPRECATED);}
If ShinyNewFoo is used in your user's code before LegacyFoo, I'm not sure that the deprecation will be triggered.
Interesting post ! Sadly I don't think it is possible to trigger a deprecation in a straightforward way in the case you present. Furthermore I'm not sure this chunk of code will work in all cases:
If
ShinyNewFoo
is used in your user's code beforeLegacyFoo
, I'm not sure that the deprecation will be triggered.You're correct, that's why I labelled this a best effort, it's really not ideal, but I'm afraid it's all we have.