php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69934 Allow initialize classes as statement or array
Submitted: 2015-06-25 20:36 UTC Modified: 2015-06-26 08:16 UTC
From: david dot proweb at gmail dot com Assigned: kalle (profile)
Status: Closed Package: PHP Language Specification
PHP Version: 7.0.0alpha2 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david dot proweb at gmail dot com
New email:
PHP Version: OS:

 

 [2015-06-25 20:36 UTC] david dot proweb at gmail dot com
Description:
------------
I think that it is possible in Java and C#, something like it:

return new PartialConsumed($constructorArgs) [
    $propertyOfPartialConsumedA => $valueA,
    $propertyOfPartialConsumedB => $valueB,
];

It will replace:

$temp = new PartialConsumed($constructorArgs);
$temp->propertyOfPartialConsumedA = $valueA;
$temp->propertyOfPartialConsumedB = $valueB;
return $temp;


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 08:16 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2015-06-26 08:16 UTC] kalle@php.net
Hi

I think you might be interested in the following RFCs:
https://wiki.php.net/rfc/automatic_property_initialization
https://wiki.php.net/rfc/constructor-promotion

Although these RFCs target property initialization in the constructor, not when called.

I highly suggest you either write an RFC or subscribe to internals and start a thread for some debate.

I'm gonna close this ticket, because such features are done via RFCs only nowadays. Also note, this is too late for 7.0, so you will have to target 7.1 :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC