Req #49526 [Com]: C# style property get/set syntax

From: Date: Sat, 21 Mar 2015 15:48:33 +0000
Subject: Req #49526 [Com]: C# style property get/set syntax
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191505@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49526&edit=1

 ID:                 49526
 Comment by:         andreas dot prucha at gmail dot com
 Reported by:        president at basnetworks dot net
 Summary:            C# style property get/set syntax
 Status:             Open
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   *
 PHP Version:        *
 Block user comment: N
 Private report:     N

 New Comment:

I noticed that the RFC failed because it did not pass the 2/3-Limit, but got more than 50 %.

I would also like to see support for properties as I know them from Delphi/ObjectPascal. Basically
it's 

property <propertyName> read <var-or-getter> write <var-or-setter>

In PHP I could imagine a syntax 

property <propertyName> get <var-or-getter> set <var-or-setter>

for Example:

public property $foo get $bar set setFoo;

This means reading from $this->foo would read $bar directly, while writing to $this->foo would
call the method setFoo, passing the value.

Implementation in PhpDocumentor would also be quite easy.


Previous Comments:
------------------------------------------------------------------------
[2015-03-20 15:11:37] levim@php.net

Related To: Bug #54019

------------------------------------------------------------------------
[2015-03-20 15:02:39] levim@php.net

Related To: Bug #53229

------------------------------------------------------------------------
[2015-03-20 14:49:58] levim@php.net

Related To: Bug #69262

------------------------------------------------------------------------
[2013-03-02 18:36:32] reeze@php.net

@see https://wiki.php.net/rfc/propertygetsetsyntax-v1.2

this RFC failed to win the vote sadly.

------------------------------------------------------------------------
[2013-01-09 01:36:22] anka17pinky at yahoo dot com

I wish this request was implemented in PHP 5.5 :(

There are so many questions on SO asking for ways to implement readonly properties in PHP...

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=49526


--
Edit this bug report at https://bugs.php.net/bug.php?id=49526&edit=1


Thread (10 messages)

« previous php.bugs (#191505) next »