-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
I am trying to collect deprecation notices while running the PHPUnit test suite in a Symfony application.
In general, I‘d like to ignoreIndirectDeprecations="true", since there are a lot of them between 3rd party packages I don‘t want to care about right now. But that currently also suppresses deprecations when my code is being called by framework code.
For example, there might be a Controller class that lives in my src and that triggers a deprecation notice. This controller, however, is not called directly by my test or other own source code, but during functional tests.
In the case of a controller, it‘s probably Symfony‘s HttpKernel invoking the controller method. In other cases (like Symfony Console commands), it may be other Symfony components calling my code.
From looking at \PHPUnit\Runner\ErrorHandler::trigger, it seems to me that since calls are not being made directly from my own (first party) code, this is always considered the indirect deprecation case which I‘d like to suppress.
I can try to work around this by adding the HttpKernel and other relevant parts from vendor as source files in the PHPUnit config. However, that does not exactly fit all cases since I don‘t want to see the cases where the Kernel is calling 3rd party code (which would be a direct deprecation if the Kernel is considered first party code).
[Edit: Moved second group of issues to #6435, since I think the cause and potential solutions are different.]
Additional information
PHPUnit 12.4.5, PHP 8.4.15
phpunit.xml.dist:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
bootstrap="tests/bootstrap.php"
>
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true">
<deprecationTrigger>
<function>trigger_deprecation</function>
</deprecationTrigger>
<include>
<directory>src</directory>
</include>
</source>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
test/bootstrap.php:
<?php
use Symfony\Component\ErrorHandler\DebugClassLoader;
use Symfony\Component\ErrorHandler\ErrorHandler;
require_once __DIR__.'/../vendor/autoload.php';
DebugClassLoader::enable();