Adopt PHPStan architecture tester: detect architecture violations + missing test #[Group(…)]
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3578710. --> Reported by: [wim leers](https://www.drupal.org/user/99777) Related to !717 >>> <h3 id="overview">Overview</h3> <p><span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3567719" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3567719</a></span> did an important refactor to make some of Canvas' innards easier to understand.</p> <p>In fact, "prop expressions" are one of the very lowest "layers" of Canvas. (Field) prop expressions power prop sources which powers <code>GeneratedFieldExplicitInputUxComponentSourceBase</code> which powers the SDC and code component source plugins which are stored in <code>Component</code> config entities and power SDC and code component instances.</p> <p>Due the organic evolution of Canvas, it's very likely that our layers are in fact more spaghetti-like than lasagna-like. We need <em>some</em> clear layers. The more matured, foundational parts of Canvas should be enforced. Code reviews ensure this happens, but we all make mistakes and are more often than not under time pressure &hellip; so what if we can automate that? &#128516;</p> <p>And what if we can use such tooling to start establishing certain minimum requirements? For example also to ensure that EVERY Canvas test has a PHPUnit group specified (see the recent <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3574687" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3574687</a></span>)?</p> <h3 id="proposed-resolution">Proposed resolution</h3> <p>That's where <a href="https://github.com/carlosas/phpat">https://github.com/carlosas/phpat</a> appears :)</p> <ol> <li>#3567719 &rarr; enforce prop expressions do not depend on any other Canvas namespaces &rarr; &#10060; <a href="https://git.drupalcode.org/project/canvas/-/jobs/8886156">some violations in HEAD</a> &rarr; see findings in <a href="https://www.drupal.org#comment-16507334">#3</a>!</li> <li>#3567719 &rarr; ensure all concrete classes are <code>final</code> &rarr; &#9989; already good!</li> <li>#3574687 &rarr; ensure all tests have a <code>#[Group(&hellip;)]</code> &rarr; &#10060; some violations in HEAD</li> </ol> <p>(more to be added later, for example for the next layer, <code>Drupal\Canvas\PropSource</code>, which should really only be used by <code>GeneratedFieldExplicitInputUxComponentSourceBase</code>, which would help <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3548297" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3548297</a></span> &mdash; but trying to start small and concrete: with one of the clearest lowest level architecture bits, plus something very practical with very direct DX impact)</p> <h3 id="ui-changes">User interface changes</h3> <p>None.</p>
issue