php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69262 Native property-support
Submitted: 2015-03-19 11:13 UTC Modified: 2015-03-20 14:49 UTC
From: andreas dot prucha at gmail dot com Assigned:
Status: Duplicate Package: PHP Language Specification
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2015-03-19 11:13 UTC] 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-19 19:43 UTC] cmb@php.net
Note that a similar RFC[1] has been declined.

[1] <https://wiki.php.net/rfc/propertygetsetsyntax-v1.2>
 [2015-03-20 14:49 UTC] levim@php.net
-Status: Open +Status: Duplicate
 [2015-03-20 14:49 UTC] levim@php.net
This is a duplicate of bug #49526.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Oct 19 10:01:26 2019 UTC