php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22725 A derived class cannot call a parent's method that calls a private method
Submitted: 2003-03-15 03:54 UTC Modified: 2003-06-08 14:28 UTC
From: sysadmin at alexdupre dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-03-15 (dev) OS:
Private report: No CVE-ID: None
 [2003-03-15 03:54 UTC] sysadmin at alexdupre dot com
--TEST--
A derived class can call a parent's protected method that calls a private method
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class Foo {
    private function aPrivateMethod() {
        echo "Foo::aPrivateMethod() called.\n";
    }

    protected function aProtectedMethod() {
        echo "Foo::aProtectedMethod() called.\n";
        $this->aPrivateMethod();
    }
}

class Bar extends Foo {
    public function aPublicMethod() {
        echo "Bar::aPublicMethod() called.\n";
        $this->aProtectedMethod();
    }
}

$o = new Bar;
$o->aPublicMethod();
?>
--EXPECT--
Bar::aPublicMethod() called.
Foo::aProtectedMethod() called.
Foo::aPrivateMethod() called.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-06-08 14:28 UTC] zeev@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Aug 17 04:00:02 2025 UTC