Bug #52120 [NEW]: Unable to call inherited protected __construct
| From: | vrana@php.net | Date: | Fri, 18 Jun 2010 15:15:44 +0000 |
| Subject: | Bug #52120 [NEW]: Unable to call inherited protected __construct | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-151608@lists.php.net to get a copy of this message | ||
From: vrana
Operating system: *
PHP version: 5.3.2
Package: Class/Object related
Bug Type: Bug
Bug description:Unable to call inherited protected __construct
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 bug report at http://bugs.php.net/bug.php?id=52120&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52120&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52120&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52120&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52120&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52120&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52120&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52120&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52120&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52120&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52120&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52120&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52120&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52120&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52120&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52120&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52120&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52120&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52120&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52120&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52120&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52120&r=mysqlcfg