Unverified Commit a6b7bb81 authored by Jonathan H. Wage's avatar Jonathan H. Wage Committed by GitHub

Merge pull request #3123 from greg0ire/opt-in_deprecations

Opt in deprecations docs
parents 50038474 041a7697
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -30,6 +30,7 @@ Contents: ...@@ -30,6 +30,7 @@ Contents:
reference/portability reference/portability
reference/caching reference/caching
reference/known-vendor-issues reference/known-vendor-issues
reference/upgrading
Indices and tables Indices and tables
================== ==================
......
Upgrading
=========
New versions of Doctrine come with an upgrade guide named UPGRADE.md.
This guide documents BC-breaks and deprecations.
Deprecations
------------
Deprecations are signaled by emitting a silenced ``E_USER_DEPRECATED``
error, like this:
.. code-block:: php
<?php
@trigger_error(
'QuantumDefraculator::__invoke() is deprecated.',
E_USER_DEPRECATED
);
Since this error is silenced, it will not produce any effect unless you
opt-in by setting up an error handler designed to ignore the silence
operator in that case. Such an error handler could look like this:
.. code-block:: php
<?php
set_error_handler(function (
int $errno,
string $errstr,
string $errfile,
int $errline,
array $errcontext
) : void {
if (error_reporting() === 0) {
/* "normal" error handlers would return in this case, but
this one will not */
}
echo "Hey there was a deprecation, here is what it says: $errstr";
}, E_USER_DEPRECATED);
This is of course overly simplified, and if you are looking for such an
error handler, consider the ``symfony/debug``, error handler that will
log deprecations. You may also be interested by the
``symfony/phpunit-bridge`` error handler that will catch deprecations
and nicely display them after running your test suites, and can even
make your build fail in that kind of case if you want to be strict about
that.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment