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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Jun 15 21:01:28 2024 UTC