Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable deprecated warning in Symfony 2(.7)

Since my Symfony 2 update to 2.7. I get a lot of deprecated erors in PHPUnit and console (message is clear by now).

ProjectX\ApiBundle\Tests\Controller\SectionsControllerTest::testPostDebug() The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead. 

Any idea how to disable them for now?

like image 724
Roel Veldhuizen Avatar asked Mar 04 '15 09:03

Roel Veldhuizen


2 Answers

AppKernel's inherited Kernel::init() function is depreciated itself so changing it is not a viable long term solution.

You can easily override the error reporting by changing the call to Debug::enable(); in both app/console and web/app_dev.php like so.

Change

Debug::enable(); 

to

Debug::enable(E_RECOVERABLE_ERROR & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED, false); 

This will leave all other error reporting in tact while suppressing depreciated warnings. And you don't need to mess with the Kernel at all.

like image 115
James Grundner Avatar answered Sep 19 '22 19:09

James Grundner


In my case, i couldn't hide deprecated warning without using SYMFONY_DEPRECATIONS_HELPERenvironnment variable.

Change your phpunit.xml with

<phpunit>     <!-- ... -->      <php>         <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>     </php> </phpunit> 

Then, you'll just have one message like "Remaining deprecation notices (x)" which is not considered as a test failure.

Hope this will help.

like image 45
j-guyon Avatar answered Sep 18 '22 19:09

j-guyon