Avoid using PHPStan --debug when generating reports
Problem/Motivation
This is a follow-up to the discusison on #3531065: Add coverage for @group and @dataprovider, use matrix #7-12 where using the --debug flag in PHPStan causes a badly-formatted junit.xml to be produced. The debug output (the names of the files being checked) are written at the top of the .xml making it unparsable.
This sounds like a bug in PHPStan.
Steps to reproduce
Run a job with _PHPSTAN_EXTRA: --debug
Here is an exampe https://project.pages.drupalcode.org/-/gitlab_templates_downstream/-/jobs/5608662/artifacts/junit.xml
The actual file contains
tests/src/FunctionalJavascript/GitlabTemplatesDownstreamThreeTest.php
tests/src/Functional/GitlabTemplatesDownstreamTwoTest.php
tests/src/Functional/GitlabTemplatesDownstreamOneTest.php
src/form.inc
gitlab_templates_downstream.module
<?xml version="1.0" encoding="UTF-8"?><testsuite failures="0" name="phpstan" tests="1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/junit-team/junit5/r5.5.1/platform-tests/src/test/resources/jenkins-junit.xsd"><testcase name="phpstan"></testcase></testsuite>
Proposed resolution
Leave the --debug setting in place on the run that writes to the log. But in all other runs remove that string from $_PHPSTAN_EXTRA to avoid the bad .xml output. Thanks to @fjgarlin for this idea.
Remaining tasks
Related issue: Issue #3531065