Req #81231 [Com]: improve or add short method for creating objects, it was done with arrays.
| From: | fffr dot fffg at hf dot dd | Date: | Wed, 07 Jul 2021 19:23:34 +0000 |
| Subject: | Req #81231 [Com]: improve or add short method for creating objects, it was done with arrays. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234884@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81231&edit=1
ID: 81231
Comment by: fffr dot fffg at hf dot dd
Reported by: icarosnet at gmail dot com
Summary: improve or add short method for creating objects, it
was done with arrays.
Status: Open
Type: Feature/Change Request
Package: Unknown/Other Function
Operating System: Ubuntu 20.04
PHP Version: 8.1.0alpha2
Block user comment: N
Private report: N
New Comment:
what problem do you want to solve?
you don't need the () at all unless you want to provide parameters for a constructor - so you
save exactly one char for what benefit?
Previous Comments:
------------------------------------------------------------------------
[2021-07-07 19:13:29] icarosnet at gmail dot com
Description:
------------
improve or add short method for creating objects, it was done with arrays.
Test script:
---------------
The only two ways to create an object in PHP are:
$obj = new stdclass ();
$obj = (object) Array(); // the same as $ obj = (object)[];
or am I wrong?
why objects don't have a short initialization method:
$obj = Object(); // avoiding the use of new stdclass ();
$obj = {};
similar to how an array is created
$arr = Array();
$arr = [];
Actual result:
--------------
Error
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=81231&edit=1