Skip to content

Implement automatic property initialization - #474

Closed
nikic wants to merge 1 commit into
php:masterfrom
nikic:autoPropertyInit
Closed

nikic wants to merge 1 commit into
php:masterfrom
nikic:autoPropertyInit

Conversation

@nikic

@nikic nikic commented Sep 26, 2013

Copy link
Copy Markdown
Member

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

This does not yet implement the syntax variant without method body.

This does not yet implement the syntax variant without method body.
@liverbool

Copy link
Copy Markdown

Where are the type-hints?
Why not just check declared property name with name of arguments and then auto assign to them?
To keep Type Hinting:

class Foo {
    public $bar;
    public function __construct(User $bar) {
        // auto matching `public $bar` with `User $bar` with the named.
        // this just one rule for user to keep in mind:
        // You MUST matching the name to auto assign by yourself.
    }
}

@nikic

nikic commented Sep 27, 2013

Copy link
Copy Markdown
Member Author

Where are the type-hints?

Typehints are where they always are. You can write __construct(User $this->user) {} for example.

Why not just check declared property name with name of arguments and then auto assign to them?

That would break backwards compatibility and would be too much implicit magic.

@MartinStepar

Copy link
Copy Markdown

Awesome, where is the "Vote for" button? =)

@JanTvrdik

Copy link
Copy Markdown

I hope this will make it to PHP 5.6.

@nikic

nikic commented Aug 18, 2014

Copy link
Copy Markdown
Member Author

Closing as the RFC was declined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants