#43083 [NEW]: Protected method access from outside class.

From: Date: Tue, 23 Oct 2007 14:22:52 +0000
Subject: #43083 [NEW]: Protected method access from outside class.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118874@lists.php.net to get a copy of this message
From: purpurby at gmail dot com Operating system: RedHat PHP version: 5.2.4 PHP Bug Type: Class/Object related Bug description: Protected method access from outside class. Description: ------------ Availability to call protected method from outside class or its descendants. Reproduce code: --------------- <?php class a { protected function aa() { echo "a-aa\n"; } } class b extends a { protected function aa() { echo "b-aa\n"; } } // Extends is affects on the behaviour: // - When "c" extends the "a" - not correct behaviour: working as in "Actual result" // - When "c" NOT extends the "a" - correct behaviour: working as in "Expected result" class c extends a { public function cc() { $obj = new a(); $obj->aa(); $obj2 = new b(); $obj2->aa(); } } $c = new c(); $c->cc(); ?> Expected result: ---------------- Fatal error: Call to protected method a::aa() from context 'c' Actual result: -------------- a-aa b-aa -- Edit bug report at http://bugs.php.net/?id=43083&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43083&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43083&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43083&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43083&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43083&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43083&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43083&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43083&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43083&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43083&r=support Expected behavior: http://bugs.php.net/fix.php?id=43083&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43083&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43083&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43083&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43083&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43083&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43083&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43083&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43083&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43083&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43083&r=mysqlcfg

« previous php.bugs (#118874) next »