Allow contrib modules to run PHPStan via GitLab CI
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3395419. --> Reported by: [simonbaese](https://www.drupal.org/user/3686593) Related to !67 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>Including PHPStan as a validation job would help improve the quality of contrib modules with the suggestions given.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>Use a PHPStan job with the Gitlab contrib template. For example:</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>phpstan</span><span style="color: #007700">:<br>&nbsp; </span><span style="color: #0000BB">stage</span><span style="color: #007700">: </span><span style="color: #0000BB">validate<br>&nbsp; needs</span><span style="color: #007700">:<br>&nbsp;&nbsp;&nbsp; - </span><span style="color: #0000BB">composer<br>&nbsp; script</span><span style="color: #007700">:<br>&nbsp;&nbsp;&nbsp; - </span><span style="color: #0000BB">php vendor</span><span style="color: #007700">/</span><span style="color: #0000BB">bin</span><span style="color: #007700">/</span><span style="color: #0000BB">phpstan analyze $_WEB_ROOT</span><span style="color: #007700">/</span><span style="color: #0000BB">modules</span><span style="color: #007700">/</span><span style="color: #0000BB">custom </span><span style="color: #007700">--</span><span style="color: #0000BB">configuration</span><span style="color: #007700">=</span><span style="color: #0000BB">$_WEB_ROOT</span><span style="color: #007700">/</span><span style="color: #0000BB">modules</span><span style="color: #007700">/</span><span style="color: #0000BB">custom</span><span style="color: #007700">/</span><span style="color: #0000BB">$CI_PROJECT_NAME</span><span style="color: #007700">/</span><span style="color: #0000BB">phpstan</span><span style="color: #007700">.</span><span style="color: #0000BB">neon </span><span style="color: #007700">--</span><span style="color: #0000BB">error</span><span style="color: #007700">-</span><span style="color: #0000BB">format</span><span style="color: #007700">=</span><span style="color: #0000BB">gitlab </span><span style="color: #007700">&gt; </span><span style="color: #0000BB">phpstan</span><span style="color: #007700">-</span><span style="color: #0000BB">quality</span><span style="color: #007700">-</span><span style="color: #0000BB">report</span><span style="color: #007700">.</span><span style="color: #0000BB">json<br>&nbsp; allow_failure</span><span style="color: #007700">: </span><span style="color: #0000BB">false<br>&nbsp; artifacts</span><span style="color: #007700">:<br>&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">reports</span><span style="color: #007700">:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">codequality</span><span style="color: #007700">: </span><span style="color: #0000BB">phpstan</span><span style="color: #007700">-</span><span style="color: #0000BB">quality</span><span style="color: #007700">-</span><span style="color: #0000BB">report</span><span style="color: #007700">.</span><span style="color: #0000BB">json<br>?&gt;</span></span></pre></div> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>Run phpstan job by default and use the configuration file of each module if present, otherwise use defaults.</p> > Related issue: [Issue #3395530](https://www.drupal.org/node/3395530) > Related issue: [Issue #3397162](https://www.drupal.org/node/3397162)
issue