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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
46 + 11 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 09:01:26 2024 UTC