AnnotationToAttributeRector doesn't handle optional properties properly
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3499247. --> Reported by: [joachim](https://www.drupal.org/user/107701) >>> <h2>Drupal version</h2> <p>11.0.6</p> <h2>Drupal Rector version</h2> <p>0.20.3</p> <h2>Problem / Motivation</h2> <p>In my annotation class, I had this:</p> <pre>&nbsp; /**<br>&nbsp;&nbsp; * The directions for the plugin's links.<br>&nbsp;&nbsp; *<br>&nbsp;&nbsp; * Array keys are machine names, array values are labels.<br>&nbsp;&nbsp; *<br>&nbsp;&nbsp; * @var array<br>&nbsp;&nbsp; */<br>&nbsp; public $directions = [];</pre><p>The rector rule produces this in the attribute class:</p> <pre>&nbsp;&nbsp;&nbsp; public readonly array $directions,</pre><p>This should have the same default value as in the annotation, so it's an optional attribute property.</p>
issue