Skip to content

added support for property promotion#310

Open
i582 wants to merge 5 commits intomasterfrom
pmakhnev/property_promotion
Open

added support for property promotion#310
i582 wants to merge 5 commits intomasterfrom
pmakhnev/property_promotion

Conversation

@i582
Copy link
Contributor

@i582 i582 commented Sep 13, 2021

RFC: https://wiki.php.net/rfc/constructor_promotion

Declaring class properties in constructor parameters is syntactic sugar, so it matches very well with the code that we are compiling now.
In fact, the following conversion process is currently taking place:

From:

class Test {
    public function __construct(public Type $prop = DEFAULT) {}
}

To:

class Test {
    public Type $prop;
 
    public function __construct(Type $prop = DEFAULT) {
        $this->prop = $prop;
    }
}

#290

@i582 i582 added the PHP8 PHP8 feature label Sep 13, 2021
@i582 i582 changed the title WIP: added support for property promotion added support for property promotion Sep 13, 2021
@Tsygankov-Slava Tsygankov-Slava mentioned this pull request Jul 3, 2023
44 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHP8 PHP8 feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant