ID:               44273
 Updated by:       [EMAIL PROTECTED]
 Reported By:      paulscheltema at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: Windows XP / Linux Debian
 PHP Version:      5.2.5
 New Comment:

Yes, but can you _change_ it? (answer: no, not via that array..)


Previous Comments:
------------------------------------------------------------------------

[2008-03-04 13:27:58] paulscheltema at gmail dot com

I think the bug is that I CAN access private / protected class data at
runtime which neglects the whole point of private or protected data
inside classes. It is to be protected!

Why else use private data if you can access it anyway? its useless
then. its just obstruction instead of security. (security in terms of
data integrity)

On the positive side at least i can not change the data.

And to refer to your reaction precisely, lets have two classes A and B
A is instanciated and has a private property x which is set, class B
casts class A to an array and gains access to class A's private property
x. This is not directly about visibility but it allows class B to "view"
class A's private property x.

------------------------------------------------------------------------

[2008-03-03 13:41:02] [EMAIL PROTECTED]

Private/protected is about visibility between _classes_ not with a
class cast to an array. So what's the "bug" here?

------------------------------------------------------------------------

[2008-02-27 20:49:25] paulscheltema at gmail dot com

Description:
------------
Hello dear developer(s),

When i setup a simple class with a protected/private var,
instanciate the class, and cast the instance to an array
i can access the protected/private var.


Reproduce code:
---------------
class test {
        public $public = 'public';
        private $private = 'private';
        protected $protected = 'protected';
}

$t = new test;
$a = (array)$t;

print '<br>public: '.$a['public'];
print '<br>private: '.$a["\0test\0private"];
print '<br>protected: '.$a["\0*\0protected"];

Expected result:
----------------
Expected:

public: public

Or at most an Error like:
    Cannot access private property test::$private
as the value of the private property



Actual result:
--------------
Result:

public: public
private: private
protected: protected


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44273&edit=1

Reply via email to