php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45648 Visibility of private in another Obj of that same class
Submitted: 2008-07-28 18:21 UTC Modified: 2008-07-28 21:15 UTC
From: gwd at heex dot pl Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.6 OS: Win XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gwd at heex dot pl
New email:
PHP Version: OS:

 

 [2008-07-28 18:21 UTC] gwd at heex dot pl
Description:
------------
Private/protected property/method is visible in methods of another object of that same class

Reproduce code:
---------------
class A {
      private $sameVar = "it's private variable!<br>";
      
      private function testMthd () {
            echo "it's private method!<br>";
      }
      
      public function testVar($otherObj) {
            echo $otherObj->sameVar;
            $otherObj->testMthd();
      }
}

$sm1 = new A();
$sm2 = new A();

$sm1->testVar($sm2);

Expected result:
----------------
it should rise an "Fatal error: Cannot access private property"

Actual result:
--------------
it's private variable!
it's private method!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-28 18:52 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Visibility is bound to the class, not the object.
 [2008-07-28 21:15 UTC] gwd at heex dot pl
Sorry, my fault. I should know it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC