Skip to content

Commit

Permalink
Add page about upgrading
Browse files Browse the repository at this point in the history
Fixes #3121
  • Loading branch information
greg0ire committed May 1, 2018
1 parent 633fa7b commit c8a5ef4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Contents:
reference/portability
reference/caching
reference/known-vendor-issues
reference/upgrading

Indices and tables
==================
Expand Down
53 changes: 53 additions & 0 deletions docs/en/reference/upgrading.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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
if ($errno === E_USER_DEPRECATED) {
// but if this is a deprecation, let us do something:
echo "Hey there was a deprecation, here is what it says: $errstr";
}
return;
}
// normal error handling here
});
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 display deprecations
after running your test suites.

0 comments on commit c8a5ef4

Please sign in to comment.