Bug #52120 [Opn->Fbk]: Unable to call inherited protected __construct

From: Date: Sat, 19 Jun 2010 22:39:12 +0000
Subject: Bug #52120 [Opn->Fbk]: Unable to call inherited protected __construct
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151639@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52120&edit=1

 ID:               52120
 Updated by:       felipe@php.net
 Reported by:      vrana@php.net
 Summary:          Unable to call inherited protected __construct
-Status:           Open
+Status:           Feedback
 Type:             Bug
-Package:          Class/Object related
+Package:          Scripting Engine problem
 Operating System: *
 PHP Version:      5.3.2

 New Comment:

"This is true for all methods except __construct()."
Can you provide an test case for non __construct method? I cannot
reproduce it.


Previous Comments:
------------------------------------------------------------------------
[2010-06-18 17:15:42] vrana@php.net

Description:
------------
Protected visibility allows accessing parent members and also members of
parent's children. If class A defines protected method f() and classes B
and C are children of A then B can call C::f(). This is true for all
methods except __construct().

Test script:
---------------
class A {
	protected function __construct() {
	}
}

class B extends A {
	static function test() {
		new C;
	}
}

class C extends A {
	protected function __construct() {
		echo "OK\n";
	}
}

B::test();


Expected result:
----------------
OK

Actual result:
--------------
Fatal error: Call to protected C::__construct() from context 'B' on line
9


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52120&edit=1


Thread (5 messages)

« previous php.bugs (#151639) next »