Incorrect code being generated by drupal-rector for automated upgrade bot
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3439865. -->
Reported by: [fgm](https://www.drupal.org/user/27985)
>>>
<h2>Drupal version</h2>
<p>11.x-dev SHA-1: 922c101dbbcc1785263854d8bb0747f10fb89f7d</p>
<h2>Drupal Rector version</h2>
<ul>
<li>drupal/upgrade_status: 4.1.0</li>
<li>mglaman/phpstan-drupal: 1.2.10</li>
<li>palantirnet/drupal-rector: 0.20.1</li>
</ul>
<h2>Problem / Motivation</h2>
<p>While preparing G2 glossary for D11, I got nonsensical code generated by the automated project bot apparently using rector, flagged as such on gitlab (<em>Major: Undefined variable: $this</em>) See <a href="https://git.drupalcode.org/project/g2/-/merge_requests/12/diffs">https://git.drupalcode.org/project/g2/-/merge_requests/12/diffs</a> : the bot generates <code>$this-></code> references in a <code>public static create</code> method. </p>
issue