drd:pi:sync Drush command not working anymore
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3479925. -->
Reported by: [szeidler](https://www.drupal.org/user/767652)
Related to !26
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>I noticed, that the Drush command <code>drd:pi:sync</code> is not registered anymore, since the transition from drush.services.yml to autoloading was done.</p>
<p>I debugged the issue and figured that it has to do with the Drush Command discovery. Drush only takes commands into account that are <a href="https://github.com/drush-ops/drush/blob/13.x/src/Runtime/ServiceManager.php#L187">direct subclasses of the DrushCommands class</a></p>
<p>In <code>DrdPiCommands</code> we extend <code>DrdCommands</code> and that makes the following drush condition not matching.</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br>$reflectionClass</span><span style="color: #007700">-></span><span style="color: #0000BB">isSubclassOf</span><span style="color: #007700">(</span><span style="color: #0000BB">DrushCommands</span><span style="color: #007700">::class)<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>See <a href="https://www.php.net/manual/en/reflectionclass.issubclassof.php">https://www.php.net/manual/en/reflectionclass.issubclassof.php</a> . It is only true if it is a direct subclass. So it behaves differently to <code>instanceof</code> which would take the whole class tree into account.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>I'm not sure if that problem actually should be filed as a Drush issue. For DRD there are currently two different approaches possible.</p>
<ol>
<li>Add a drush.services.yml as long as it is supported by Drush (< Drush 14)</li>
<li>Make DrdPiCommands extend DrushCommands and copy&paste some of the pieces from DrdCommands that are required for it to run
</li></ol>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<h3 id="summary-ui-changes">User interface changes</h3>
<h3 id="summary-api-changes">API changes</h3>
<h3 id="summary-data-model-changes">Data model changes</h3>
issue