Bug #77039 [Opn->Dup]: about `protected` keywords

From: Date: Mon, 01 Feb 2021 13:21:54 +0000
Subject: Bug #77039 [Opn->Dup]: about `protected` keywords
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231859@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77039&edit=1 ID: 77039 Updated by: cmb@php.net Reported by: 200847041 at qq dot com Summary: about protected keywords -Status: Open +Status: Duplicate Type: Bug -Package: Doc Build problem +Package: Scripting Engine problem Operating System: Ubuntu16 PHP Version: 7.2.11 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Closing as duplicate of bug #50892. Previous Comments: ------------------------------------------------------------------------ [2018-10-19 07:56:28] 200847041 at qq dot com Description: ------------ 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 $a->foo(); } } (new B())->bar(); ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77039&edit=1

« previous php.bugs (#231859) next »