Edit report at https://bugs.php.net/bug.php?id=70236&edit=1
ID: 70236
Comment by: daniel dot korner at tu-dortmund dot de
Reported by: z4k4ri4 at gmail dot com
Summary: $->var as syntactic sugar for $this->var
Status: Open
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:
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.
Previous Comments:
------------------------------------------------------------------------
[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