Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement automatic property initialization #474

Closed
wants to merge 1 commit into from

Conversation

nikic
Copy link
Member

@nikic nikic commented Sep 26, 2013

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

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
Copy link
Member Author

nikic commented Sep 27, 2013

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

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

@JanTvrdik
Copy link

I hope this will make it to PHP 5.6.

@nikic
Copy link
Member Author

nikic commented Aug 18, 2014

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