Convert the final PropSource class into an enum
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3555220. -->
Reported by: [phenaproxima](https://www.drupal.org/user/205645)
Related to !276
>>>
<h3 id="overview">Overview</h3>
<p>In what I think is a fairly modest step towards making Canvas's backend code more maintainable, I propose we turn the final <code>PropSource</code> class -- which is really just a parser/factory -- into an enum.</p>
<p>I see the following advantages to this:</p>
<ul>
<li>Prop sources are not pluggable; there's a known list of them, all of which have hard-coded prefixes, and that's that. This is precisely the kind of use case enums were invented for.</li>
<li>If you need to enumerate all possible prop source types (and there is at least one place where we do), enums have a <code>cases()</code> method for exactly that.</li>
<li>PropSourceBase can lose the <code>getSourceTypePrefix()</code> method, which was only ever a wrapper around a constant.</li>
<li>There is only a single source of truth about which prop sources exist.</li>
<li>We can keep the <code>parse()</code> method and its DX exactly as is, but move the assertions for specific prop source types into the relevant parse() methods.</li>
<li>Reduce the awkward separation between PropSource and the PropSourceBase subclasses, since really the prefix <em>defines</em> which prop source will be used. I, personally, find that cleaner but I would be curious to hear other opinions.</li>
</ul>
issue