re: How to deprecate a type in php VIEW POST

VIEW FULL DISCUSSION
 

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:

<?php

if (!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.

 

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.

code of conduct - report abuse