therealworld / suppress-deprecations-plugin
Suppresses Symfony deprecation notices during Composer operations in legacy OXID 6 projects
Package info
bitbucket.org/therealworld/suppress-plugin
Type:composer-plugin
pkg:composer/therealworld/suppress-deprecations-plugin
Requires
- composer-plugin-api: ^2.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Deutsche Fassung: README.de.md

description
Running composer install / composer update in an OXID project with current PHP and Composer
versions floods the console with deprecation notices nobody running the command can act on:
Deprecation Notice: Since symfony/event-dispatcher 5.3: Configuring "Symfony\Component\EventDispatcher\..." is deprecated.
Deprecation Notice: Since oxid-esales/oxideshop-ce 6.5.0: The "oxid_esales.module.configuration..." service is deprecated.
This Composer plugin hides those notices (E_USER_DEPRECATED and E_DEPRECATED) while Composer
runs. All other errors and warnings are passed on to Composer unchanged. It was written for
legacy OXID 6 projects and is also pulled in by therealworld/clirun-plugin in OXID 7 projects.
- composer package:
therealworld/suppress-deprecations-plugin - composer type:
composer-plugin(no OXID module, nothing to activate in the shop) - requires:
composer-plugin-api^2.0
It only affects Composer runs - the shop itself is not touched.
installation
as a dependency of another package (recommended)
In the composer.json of a parent package (e.g. therealworld/clirun-plugin):
{
"require": {
"therealworld/suppress-deprecations-plugin": "^1.0"
}
}
allow the plugin
Composer only runs plugins the project allows. In the root composer.json of the project:
{
"config": {
"allow-plugins": {
"therealworld/suppress-deprecations-plugin": true
}
}
}
A wildcard entry covers all therealworld plugins:
{
"config": {
"allow-plugins": {
"therealworld/*": true
}
}
}
as a local path repository (for testing)
{
"repositories": [
{"type": "path", "url": "path/to/suppress-plugin"}
],
"require": {
"therealworld/suppress-deprecations-plugin": "*"
}
}
fallback for the very first run: auto_prepend_file
Before the plugin is installed it cannot do anything. For that first composer update, the
included suppress-deprecations.php can be used as a PHP prepend file:
php -d auto_prepend_file=path/to/suppress-plugin/suppress-deprecations.php composer update
The file defines Symfony's trigger_deprecation() as a no-op before Symfony's own version is
loaded, which silences the Symfony notices. From the second run onwards the plugin takes over.
limits
- "Package X is abandoned, you should avoid using it." warnings are written directly by
Composer's
InstallerviaIOInterface::writeError()and cannot be intercepted reliably from a plugin. They stay visible. - The plugin installs its handler when Composer activates it - notices raised before that moment (while Composer itself boots) are not caught; use the prepend file for those.
For developers
| File | Purpose |
|---|---|
src/SuppressDeprecationsPlugin.php | Composer plugin (TheRealWorld\Composer\SuppressDeprecationsPlugin): wraps the active error handler |
suppress-deprecations.php | fallback: no-op trigger_deprecation() for auto_prepend_file |
On activate() the plugin registers an error handler via set_error_handler() that swallows
E_USER_DEPRECATED and E_DEPRECATED and forwards every other level to the previous handler
(Composer's ErrorHandler). deactivate() restores the previous handler.
why not error_reporting?
Composer's ErrorHandler::handle() checks explicitly:
$isDeprecationNotice = $level === E_DEPRECATED || $level === E_USER_DEPRECATED;
if (!$isDeprecationNotice && !(error_reporting() & $level)) {
return true;
}
Deprecation notices bypass the error_reporting check entirely.
why not autoload.files?
Composer's AutoloadGenerator always sorts the root package to the end of the autoload file
list ($sortedPackageMap[] = $rootPackageMap). Dependencies are sorted by "importance" (number
of dependent packages); symfony/deprecation-contracts has a very high weight and is therefore
always loaded before any custom package. Overriding trigger_deprecation() via
autoload.files is not possible.