Syntax error (unexpected 'bool', expecting function or const) when running the process command
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3444632. --> Reported by: [francescoq](https://www.drupal.org/user/1977720) >>> <h2>Drupal version</h2> <p>8.9.20 (PHP 7.3)</p> <h2>Drupal Rector version</h2> <p>0.20.1</p> <h2>Problem / Motivation</h2> <p>I installed drupal rector as per docs with composer, I copied the rector.php file and if I run i.e.</p> <p><code>vendor/bin/rector process web/modules/custom/[some_custom_module] --dry-run</code></p> <p>I get this error</p> <pre>[ERROR] syntax error, unexpected 'bool' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </pre><p> If I don't copy the rector.php file, rector create its own and it works (but obviously it doesn't contain the Drupal stuff, it only adds the <code>void</code> return type for functions/method that doesn't return anything, that's not even mentioned in upgrade_status as an issue)</p> <p>I debugged a bit with and it seems to fail when trying to set the setlists </p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp; $rectorConfig</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">sets</span><span style="color: #007700">([<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">Drupal8SetList</span><span style="color: #007700">::</span><span style="color: #0000BB">DRUPAL_8</span><span style="color: #007700">,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">Drupal9SetList</span><span style="color: #007700">::</span><span style="color: #0000BB">DRUPAL_9</span><span style="color: #007700">,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #0000BB">Drupal10SetList</span><span style="color: #007700">::</span><span style="color: #0000BB">DRUPAL_10</span><span style="color: #007700">,<br>&nbsp;&nbsp;&nbsp; ]);<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>specifically it seems to fail when it does (for any of the set list i tried)</p> <div class="codeblock"> <pre><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br>&nbsp;&nbsp;&nbsp; $rectorConfig</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">singleton</span><span style="color: #007700">(</span><span style="color: #0000BB">AddCommentService</span><span style="color: #007700">::class, function () {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new </span><span style="color: #0000BB">AddCommentService</span><span style="color: #007700">();<br>&nbsp;&nbsp;&nbsp; });<br></span><span style="color: #0000BB">?&gt;</span></span></pre></div> <p>after that i'm getting a bit lost on why/what's happening honestly... Does anybody experienced something similar?</p>
issue