php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34060 PHP5 OOP Visibility does not fully document protected constriants
Submitted: 2005-08-10 03:02 UTC Modified: 2005-08-29 17:52 UTC
From: david dot tulloh at anu dot edu dot au Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david dot tulloh at anu dot edu dot au
New email:
PHP Version: OS:

 

 [2005-08-10 03:02 UTC] david dot tulloh at anu dot edu dot au
Description:
------------
The first paragraph includes the following description of protected:

"Protected limits access to inherited classes (and to the class that defines the item)."

However it actually allows access from functions in both the parent and child classes.  I've provided some example code.

Reproduce code:
---------------
<?php                           
class aParent {                 
  function get_a () {             
    echo $this->a;
  }
}

class aChild extends aParent {
  protected $a = "hi";
}

$my_obj = new aChild();
$my_obj->get_a(); # Prints hi
?>


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-29 17:52 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Changed to "Protected limits access to inherited and parent classes (and to the class that defines the item)."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Nov 19 18:00:02 2025 UTC