Skip to content

Instantly share code, notes, and snippets.

@javiereguiluz
Last active May 3, 2017 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save javiereguiluz/a5514ec6cde2a63be441 to your computer and use it in GitHub Desktop.
Save javiereguiluz/a5514ec6cde2a63be441 to your computer and use it in GitHub Desktop.
How to add a deprecation note about Symfony features

In order to generate and log a warning message about a deprecated Symfony feature, use the trigger_error() function as follows:

trigger_error('The enctype method of the form helper was removed. You should use the new method start instead.', E_USER_DEPRECATED);

Please, be as explicit as possible in the deprecation message and always explain the alternative way to use that feature, property, method or class.

@mmoreram
Copy link

@javiereguiluz Could you please add a link of an example in the Symfony code please?

@snoek09
Copy link

snoek09 commented Nov 29, 2014

\Symfony\Component\HttpKernel\Tests\Logger has several:

    /**
     * @deprecated
     */
    public function crit($message, array $context = array())
    {
        trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED);

        $this->log('critical', $message, $context);
    }

@xabbuh
Copy link

xabbuh commented Nov 29, 2014

@CalinBolea noticed that we also have a part about deprecations in the contribution docs: http://symfony.com/doc/current/contributing/code/conventions.html#deprecations

@h4cc
Copy link

h4cc commented Nov 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment