Avoid using PHPStan --debug when generating reports

Created on 21 June 2025, 3 days ago

Problem/Motivation

This is a follow-up to the discusison on #3531065-7: 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/-/job...
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 first run, when writing to the log. But when generating the output, remove that string from $_PHPSTAN_EXTRA to avoid the bad .xml output. Thanks to @fjgarlin for this idea.

Remaining tasks

📌 Task
Status

Active

Component

gitlab-ci

Created by

🇬🇧United Kingdom jonathan1055

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024