I have seen in many Symfony bundles (and also in other codes) this line :
@trigger_error('The class is deprecated', E_USER_DEPRECATED);
According to the documentation, the @
(at) operator is used to silence the errors (http://php.net/manual/en/language.operators.errorcontrol.php).
So, what is the purpose of throwing a silenced error?
Adding to what other people said, according to the docs this entire scheme boils down to the following example:
Otherwise put, a silenced deprecation notice still can be heard from a custom error handler, if needed, not polluting the usual logs in the same time.
As stated in the Symfony coding conventions:
Comment from author about the relevant PR:
Just speculating, but this could be used to be handled by a custom error handler.
Example:
Therefore the error can be logged (or otherwise handled) even if it is suppressed.
You can't know exactly why this is done unless there's documentation about it. It's up to the developers to explain why they do this.