PHPStan: convert PHPCS `Canvas.Tests.KernelTestBase.RequireAssertEntityIsValid` rule to a PHPStan rule
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3584511. --> Reported by: [wim leers](https://www.drupal.org/user/99777) Related to !908 >>> <h3 id="overview">Overview</h3> <p>In <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582966" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582966</a></span>, I finished what @shubham.prakash did (there were a high number of false positives being surfaced by his PHPCS rule) and landed it.</p> <p>However, the end result is a PHPCS rule that has grown unwieldy.</p> <p><strong>None of us are PHPCS or PHPStan developers, so we're still working to establish a rule of thumb of when to use which.</strong></p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>Per Opus 4.6 at <a href="https://git.drupalcode.org/project/canvas/-/merge_requests/888#note_747376">https://git.drupalcode.org/project/canvas/-/merge_requests/888#note_747376</a> this could and probably should be refactored to a PHPStan rule.</p> <p>Bonuses:</p> <ol> <li>the conversion to a PHPStan rule appears to have surfaced 2 false negatives!</li> <li>no more ignores: all <code>// @phpcs:ignore Canvas.Tests.KernelTestBase.RequireAssertEntityIsValid</code> occurrences are gone, and no PHPStan equivalents are needed</li> </ol> <p><strong>Suggested rule of thumb: as soon as we go beyond simple syntax and about understanding types, convert from PHPCS to PHPStan.</strong> In this case, that's exactly the shift that <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3582966" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3582966</a></span> made.</p> <h3 id="ui-changes">User interface changes</h3> <p>None.</p>
issue