-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #3121
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |