Req #69262 [Com]: Native property-support

[email protected] ("[email protected]")
Newsgroups php.standards
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=69262&edit=1

 ID:                 69262
 Comment by:         [email protected]
 Reported by:        andreas dot prucha at gmail dot com
 Summary:            Native property-support
 Status:             Open
 Type:               Feature/Change Request
 Package:            PHP Language Specification
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Note that a similar RFC[1] has been declined.

[1] <https://wiki.php.net/rfc/propertygetsetsyntax-v1.2>


Previous Comments:
------------------------------------------------------------------------
[2015-03-19 11:13:17] andreas dot prucha at gmail dot com

Description:
------------
I think native support for properties like in Delphi would be nice. For example:

{

  protected $myPropertyField;

  public proprety $myProperty get $myPropertyField set setMyProperty;

  public function setMyProperty($aValue)
  {
    $this->myPropertyField = $aValue;
  }

}

In the declaration a getter and setter could be defined, which could be either direct reference to a variable or a setter/getter function.

I know it's syntatctic sugar, but it may make property declarations more obvious, easier to document (once phpdocumentor supports it) and it might even bring slight performance gains as we do not go through __get and __set to determine the getter/setter function.



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



--
Edit this bug report at https://bugs.php.net/bug.php?id=69262&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.