Skip to content

Allow limiting deprecation warnings in console-command debug:container --deprecations like in phpunit-bridge #46951

Closed
@heiglandreas

Description

@heiglandreas

Description

Currently it is possible to reduce deprecation warning s in the phpunit-bridge by setting the SYMFONY_DEPRECATIONS_HELPER environment variable.

That allows one to ignore different deprecations mainly based on in which code-parts they appear. That provides for example a way to ignore dependencies that are not based on ones own code but that occur in dependencies. The details are described in the phpunit-bridge docs.

It would be great to have the same possibilities when calling the debug:container --deprecations command to be able to easier see whether there are deprecations in my own code or only in my dependencies. This would specifically allow one to fail or pass CI pipelines based on where deprecations are found.

An alternative would be to unify the reading of the *Deprecations.log-file in one place (instead of having that coded into each Descriptor separately) and allow adding custom filters for the result. That way one could parse the deprecation-log array and remove files based on a custom logic.

Example

An example would be to use this command to see only deprecations within my own code, not within external dependencies:

export SYMFONY_DEPRECATIONS_HELPER="max[self]=0"; php bin/console debug:container --deprecations

An example for an EventHandler for a newly to define DeprecationLogFilter-event might look like this:

<?php

class RemoveVendorFolderFromDeprecationLog
{
    public function handle(DeprecationLogFilter $event, string $name, EventDispatcherInterface $dispatcher): void
    {
		$newList = [];
        foreach ($event->getDeprecationLog() as $logEntry) {
            if (! str_starts_with($logEntry['file'], (string) realpath(__DIR__ . '/../../../vendor'))) {
                continue;
            }

            $newList[] = $logEntry;
        }
        $event->setDeprecationLog($newList);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions