Skip to content

6.x: encourage constructor property promotion#19328

Open
LordSimal wants to merge 3 commits into6.xfrom
6.x-constructor-property-promotion
Open

6.x: encourage constructor property promotion#19328
LordSimal wants to merge 3 commits into6.xfrom
6.x-constructor-property-promotion

Conversation

@LordSimal
Copy link
Copy Markdown
Contributor

This gets rid if

  • duplicate PHPDocs as there were sometimes/often differing property and constructor arg PHPDocs
  • unneeded property assignments in constructors
  • property definitions above the constructor

@LordSimal LordSimal added this to the 6.0 milestone Mar 14, 2026
@LordSimal
Copy link
Copy Markdown
Contributor Author

LordSimal commented Mar 14, 2026

The test broke because the constructor-promotion refactor changed the internal property order of ConsoleInputOption, and ConsoleOptionParser was implicitly relying on that order via asort().

Before the refactor, ConsoleInputOptiondeclared its properties in the order: name, short, help, boolean, default, ... When ConsoleOptionParser.php did:

$this->options[$name] = $option;
asort($this->options);

PHP compared the ConsoleInputOption objects by their properties, so it effectively sorted by name first. That gave the old alphabetical order: connection, help, test.

After the property-promotion change, ConsoleInputOption now has default declared first, and the promoted properties come after it.

@LordSimal LordSimal force-pushed the 6.x-constructor-property-promotion branch from 129eb2d to 7ccb686 Compare March 14, 2026 09:25
@LordSimal LordSimal force-pushed the 6.x-constructor-property-promotion branch from 7ccb686 to 951195f Compare March 25, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant