#37632 [Asn->Csd]: Protected method access problem (similar bug 37212)

From: Date: Mon, 29 May 2006 20:08:54 +0000
Subject: #37632 [Asn->Csd]: Protected method access problem (similar bug 37212)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97767@lists.php.net to get a copy of this message
ID: 37632 Updated by: helly@php.net Reported By: stochnagara at hotmail dot com -Status: Assigned +Status: Closed Bug Type: Class/Object related Operating System: * PHP Version: 5CVS-2006-05-29 (snap) Assigned To: helly New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-05-29 20:08:43] helly@php.net Fixed in 5.2, HEAD. Since the rule cannot be fixed for properties in 5.1 it stays the same for methods in 5.1, too. That way we lower the WTF factor. ------------------------------------------------------------------------ [2006-05-29 18:43:24] stochnagara at hotmail dot com Description: ------------ In class structures where the sub-classes are extended non-linearly (i.e. multiple classes on the same tier), the sub-classes in different lines cannot access methods defined as protected in a shared parent class in eachother. Actually this is a clone of bug 37212 but for method instead of variables. Reproduce code: --------------- class A { protected function testProtected() { echo "Test Protected Called in A"; } } class B extends A { public function doTest (A $obj) { $obj->testProtected(); } } class C extends A { protected function testProtected() { echo "Test Protected Called in C"; } } $B = new B; $C = new C; $B->doTest ($C); // fatal ?> Expected result: ---------------- Test Protected Called in C Actual result: -------------- Fatal error: Call to protected method C::testProtected() from context 'B' in c:\program files\apache group\Apache\htdocs\cinh.php on line 8 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37632&edit=1

« previous php.bugs (#97767) next »