Skip to content

Add fixture for CommandConfigureToAttributeRector regression - #1054

Closed
Jean85 wants to merge 1 commit into
rectorphp:mainfrom
Jean85:patch-1
Closed

Jean85 wants to merge 1 commit into
rectorphp:mainfrom
Jean85:patch-1

Conversation

@Jean85

@Jean85 Jean85 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

CommandConfigureToAttributeRector should not run if the promoted value is a non-constant value, since it cannot be included as an attribute argument

CommandConfigureToAttributeRector  should not run if the promoted value is a non-constant value, since it cannot be included as an attribute argument
@TomasVotruba

Copy link
Copy Markdown
Member

Thanks for the report and fixture! Confirmed the rule emitted invalid PHP (#[AsCommand(description: $this->description)]). Fixed in #1057 — the rule now skips non-constant setX() values and leaves them in configure(). Credited you as co-author.

TomasVotruba added a commit that referenced this pull request Aug 25, 2026
…nfigure() values

Attribute arguments must be constant expressions, so a runtime value like
$this->setDescription($this->description) cannot be inlined into #[AsCommand].
Leave such setX() calls in configure() instead of producing invalid code.

Also return null when nothing could be extracted, so the rule no longer
reports a no-op change.

Reported in #1054.

Co-authored-by: Alessandro Lai <alessandro.lai85@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants