Req #70236 [Opn->Sus]: $->var as syntactic sugar for $this->var
| From: | krakjoe@php.net | Date: | Sat, 26 Mar 2016 21:44:23 +0000 |
| Subject: | Req #70236 [Opn->Sus]: $->var as syntactic sugar for $this->var | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200124@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70236&edit=1
ID: 70236
Updated by: krakjoe@php.net
Reported by: z4k4ri4 at gmail dot com
Summary: $->var as syntactic sugar for $this->var
-Status: Open
+Status: Suspended
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: All
PHP Version: 7.0.0beta3
Block user comment: N
Private report: N
New Comment:
For this kind of change, an RFC is required.
Please see: https://wiki.php.net/rfc/howto
Previous Comments:
------------------------------------------------------------------------
[2015-12-22 11:38:30] daniel dot korner at tu-dortmund dot de
I don't think introducing yet another alias is a good idea. Each new alias only adds
unnecessary complexity to the interpreter and to the written PHP code without adding any kind of
feature.
But I also think, changing the current "this"-Syntax might be a good idea. Currently the
$-Symbol implies that "$this" is a "normal" variable (which it is not!). But the
proposed alias "$" would not have this "problem", as the $-Symbol alone
isn't a valid variable name.
therefor I think adding this alias with the future plan of removing "$this" might not be
such a bad idea.
------------------------------------------------------------------------
[2015-10-19 22:20:38] rahi at atsspec dot co
No offense but I think this is a silly idea. If you have that many $this->something that
it's distracting, then you need to take another look at the code. Maybe have a method that
sets the class properties based on an array keyed by the class property names (for example).
For 'setter' type methods you can 'return $this' (fluent interface) to make your
code less verbose.
------------------------------------------------------------------------
[2015-08-26 11:33:30] matt at re-gister dot com
I would appreciate this
------------------------------------------------------------------------
[2015-08-11 08:18:07] z4k4ri4 at gmail dot com
Description:
------------
In a everyday PHP OOP coding, $this->var or $this->method() is so common and verbose, it
becomes a distraction for code reading.
I request that PHP add short form of $->var or $->method() as an alias for $this->var and
$this->method().
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70236&edit=1