0

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?

Andrei Herford
  • 17,570
  • 19
  • 91
  • 225
  • You could probably just set up a deprecations log file with monolog and filter that with grep if there's no straight forward way to filter this in the toolbar. – Bananaapple Jan 11 '19 at 08:41
  • you will need a custom monolog handler where you will write your logic to suppress messages based on keywords/messages – Dan Dumitriu Jan 11 '19 at 10:36

2 Answers2

0

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.

jkucharovic
  • 4,214
  • 1
  • 31
  • 46
-2

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

/**
 * Function
 * @deprecated it is deprecated.  <- remove
 */
function a() {
  return 'hi';
}
Nick Wang
  • 624
  • 3
  • 6
  • editing third party code is not a viable solution as the edits would be lost every time composer is run – Bananaapple Jan 11 '19 at 11:29
  • On the other hand, I did run into one very annoying bundle that no longer appeared to be maintained. I forked it, removed the deprecated annotations and went on my way until I could replace the functionality completely. By this time at least, you would expect most maintained projects to support 3.4. – Cerad Jan 11 '19 at 13:36