php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64204 Read only and write once paramater visibility
Submitted: 2013-02-13 15:12 UTC Modified: 2013-02-13 16:34 UTC
From: andy at mrhunt dot co dot uk Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andy at mrhunt dot co dot uk
New email:
PHP Version: OS:

 

 [2013-02-13 15:12 UTC] andy at mrhunt dot co dot uk
Description:
------------
This is a hopefully simple request to add an extra visibility type into classes to 
allow for paramaters that can be read outside the class like with public but can 
only be written too inside as with protected. I've put a sample of how I think 
this should work below to hopefully give you a better idea of this.

Test script:
---------------
class Test
{
  readonly $param_ro;

  public funcion test()
  {
    $this->param_ro = 'test-ro'; // Works
  }
}
$test = new Test();

echo $test->param_ro; // Works

$this->param_ro = 'test'; // Fails


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-13 16:34 UTC] johannes@php.net
-Status: Open +Status: Wont fix
 [2013-02-13 16:34 UTC] johannes@php.net
No, this is not easy, mind cases like this:

$test = new Test();
$foo = &$test->param_ro;
$foo = 'test';

Our current discussion state is more around accessors, while that's not yet accepted either: https://wiki.php.net/rfc/propertygetsetsyntax-v1.2
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC