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

Support new in initializers #6746

Closed
wants to merge 6 commits into from
Closed

Conversation

nikic
Copy link
Member

@nikic nikic commented Mar 2, 2021

This allows writing code like public Vec $prop = new Vec();.

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

@Illuminat
Copy link

Illuminat commented Mar 4, 2021

Hello @nikic. Good RFC. What about using closure inside and default variables?
Something like this
class Test {
private $url = 'https://some.com';
private $key = 'some-api-key';
private $client = new Client($this->url, $this->key);
private $lazyClient = static function () { return new Client()}; }

//or we can use anonymous class for this
public $lazyClient = new class { function __invoke() { return new Client()}; }

}

@nikic nikic force-pushed the objects-in-constexpr branch 2 times, most recently from f2708dd to 5698766 Compare March 4, 2021 15:52
thekid added a commit to xp-framework/compiler that referenced this pull request Mar 6, 2021
@zlianon
Copy link

zlianon commented Apr 14, 2021

@nikic any chance of getting this in PHP 8.1? when does feature freeze start?

@nikic
Copy link
Member Author

nikic commented Apr 14, 2021

@zlianon Feature freeze is currently planned for Jul 20, see https://wiki.php.net/todo/php81.

@nikic
Copy link
Member Author

nikic commented Jul 13, 2021

Closing in favor of #7153.

@nikic nikic closed this Jul 13, 2021
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.

3 participants