|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77039 about `protected` keywords
Submitted: 2018-10-19 07:56 UTC Modified: -
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: 200847041 at qq dot com Assigned:
Status: Open Package: Doc Build problem
PHP Version: 7.2.11 OS: Ubuntu16
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.
Block user comment
Status: Assign to:
Bug Type:
From: 200847041 at qq dot com
New email:
PHP Version: OS:


 [2018-10-19 07:56 UTC] 200847041 at qq dot com
Derived classes of the same base class can access each other's protected method and protected property.

Test script:
class Base {
protected function foo() {
   echo 'foo';

class A extends Base {


class B extends Base {

public function bar() {
  $a = new A();
  // in fact, it is ok, and will echo foo.
  // but I think it should not access


(new B())->bar();


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 03:01:23 2020 UTC