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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

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: Fri Apr 19 20:01:29 2024 UTC