Possible to disable specific deprecation warnings in Symfony 3.4?

48
January 12, 2019, at 12:10 PM

I am working on migrating an existing Symfony 2.8 project to Symfony 3.4. While testing the 3.4 project in dev mode the Symfony toolbar is a great help.

However the Symfony / the toolbar always logs/shows all warnings and notices, no matter if they are relevant to me or not.

For example I know that third party bundle XY is not ready for Symfony 4 and thus includes some deprecated methods. I cannot change this and for the moment it does not matter.

However, I still would like to know if my own code uses deprecated methods to fix this now, since I am refactoring the code anyway.

I found different threads about this question, but the only solution was to disable warnings in general (e.g. here).

This would work to see no deprecation warnings at all, but as described I would like to remove / silence specific warnings only.

Is it somehow possible to silence warnings form BundleA or ClassB while still seeing warnings from CodeC?

I know that PHP it self cannot do this, but maybe there is some way to configure the dev toolbar to do this?

Answer 1

It's not possible, because deprecation warnings in Symfony are called as trigger_error('Deprecation message', E_USER_DEPRECATED).

For example, see this Twig DebugCommand.

Answer 2

A temporary solution, update the description of the methods should be ok.

/**
 * Function
 * @deprecated it is deprecated.  <- remove
 */
function a() {
  return 'hi';
}
READ ALSO
Getting 4004 SQL Server error after execution of stored procedure with JSON input using PHP code

Getting 4004 SQL Server error after execution of stored procedure with JSON input using PHP code

We created a stored procedure in SQL server which takes input parameter as JSONProcedure is giving us results in JSON in the studio management

29
Integrate NTLM Authentication on ubuntu18.04 apache2.4

Integrate NTLM Authentication on ubuntu18.04 apache2.4

what are the things needs to be done to integrate Apache2::AuthenNTLM in apache2 on ubuntu 1804 with php7

47
htaccess query string wildcard rewrite

htaccess query string wildcard rewrite

I've tried some suggestions from other posts on similar subject but were not able to solve this exact issue

21
Duplicate words in PHP [on hold]

Duplicate words in PHP [on hold]

I have probably information about whether it is available in PHP to detect a duplicate and a book about not removing it and adding it to -1, -2, -3

29