php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22726 Referencing a parent's private member in a derived class causes its deletion
Submitted: 2003-03-15 04:05 UTC Modified: 2003-04-23 03:23 UTC
From: sysadmin at alexdupre dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2003-03-15 (dev) OS: FreeBSD 4-STABLE
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sysadmin at alexdupre dot com
New email:
PHP Version: OS:

 

 [2003-03-15 04:05 UTC] sysadmin at alexdupre dot com
--TEST--
Referencing a parent's private member in a derived class
--SKIPIF--
<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
--FILE--
<?php
class MyClass {
    private $Bar = "Hello, Bar!";
    protected $Foo = "Hello, Foo!";

    public function printHello() {
        print "MyClass::printHello() " . $this->Bar . "\n";
        print "MyClass::printHello() " . $this->Foo . "\n";
    }
}

class MyClass2 extends MyClass {
    public function printHello2() {
        $this->printHello();
        print "MyClass2::printHello2() " . $this->Bar . "\n";
        print "MyClass2::printHello2() " . $this->Foo . "\n";
    }
}

$obj = new MyClass();
$obj->printHello();
$obj = new MyClass2();
$obj->printHello2();
?>
--EXPECT--
MyClass::printHello() Hello, Bar!
MyClass::printHello() Hello, Foo!
MyClass::printHello() Hello, Bar!
MyClass::printHello() Hello, Foo!
MyClass2::printHello2() 
MyClass2::printHello2() Hello, Foo!


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-19 11:03 UTC] thekid at thekid dot de
With latest CVS, I get:

MyClass::printHello() Hello, Bar!
MyClass::printHello() Hello, Foo!
MyClass::printHello() Hello, Bar!
MyClass::printHello() Hello, Foo!
MyClass2::printHello2() 
MyClass2::printHello2() Hello, Foo!

I guess this is fixed, then.
 [2003-04-23 02:46 UTC] sysadmin at alexdupre dot com
Yes, tested today and now it works.
 [2003-04-23 03:23 UTC] magnus@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: Sat Aug 16 22:00:02 2025 UTC