Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Roman Borschel
For what it matters, the same thing in Java returns the expected result: Class clazz = Foo.class; Field fooProp = clazz.getDeclaredField(foo); fooProp.setAccessible(true); Bar bar = new Bar(); String value = (String)fooProp.get(bar); System.out.println(value); So is this a bug or some weird

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Sebastian Bergmann
Johannes Schlüter schrieb: This really looks like a bug in this feature. I will have a look at it this afternoon. -- Sebastian BergmannCo-Founder and Principal Consultant http://sebastian-bergmann.de/ http://thePHP.cc/ -- PHP Internals - PHP

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Johannes Schlüter
On Sat, 2009-04-04 at 13:08 +0200, Roman Borschel wrote: My patch is simply to replace the first argument of zend_update_property/zend_read_property in ext/php_reflection.c like this: [...] So simply replacing Z_OBJCE_P(object) with ref-ce. yes, that was what i was thinking about, too

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Roman Borschel
Hi, Despite my almost non-existant C-skills I managed to put together a patch (or what I think is a patch) that does not break any tests. My patch is simply to replace the first argument of zend_update_property/zend_read_property in ext/php_reflection.c like this: within the getValue

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Johannes Schlüter
On Sat, 2009-04-04 at 07:34 +0200, Roman Borschel wrote: Thanks for your answer. Yes, this works, but here $f is an instance of Foo, not Bar. When you make it an instance of Bar you get NULL. I think this is not correct, is it? Given that we have a ReflectionProperty of class Foo at hand,

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Roman Borschel
Hi, i created 2 patches that are attached to this mail, one to fix the issue and the other to add tests for it (I added them into reflectionProperty_setAccessible.phpt). Roman On Apr 4, 2009, at 1:23 PM, Johannes Schlüter wrote: On Sat, 2009-04-04 at 13:08 +0200, Roman Borschel

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-04 Thread Sebastian Bergmann
Roman Borschel schrieb: i created 2 patches that are attached to this mail Your attachments did not make it to the list. No worries, though, I committed a patch together with updated tests earlier. -- Sebastian BergmannCo-Founder and Principal Consultant

[PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-03 Thread Roman Borschel
Hi, i've got a little question that involves private properties, inheritance and Reflection with PHP 5.3 RC1. Given the following simple classes class Foo { private $foo = 'value'; public function getFoo() { return $this-foo; } } class Bar extends Foo {} Obviously, given an

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-03 Thread Johannes Schlüter
On Fri, 2009-04-03 at 22:37 +0200, Roman Borschel wrote: Given the following simple classes class Foo { private $foo = 'value'; public function getFoo() { return $this-foo; } } class Bar extends Foo {} Obviously, given an instance of Bar, say $bar, $bar-getFoo() returns

Re: [PHP-DEV] Private properties, Inheritance, Reflection (5.3)

2009-04-03 Thread Roman Borschel
Hi, On Apr 4, 2009, at 1:53 AM, Johannes Schlüter wrote: On Fri, 2009-04-03 at 22:37 +0200, Roman Borschel wrote: Given the following simple classes class Foo { private $foo = 'value'; public function getFoo() { return $this-foo; } } class Bar extends Foo {} Obviously, given an

Re: [PHP-DEV] private properties ....

2007-12-02 Thread Etienne Kneuss
Hello, Sorry late replies shouldn't be allowed ;) class A { private $foo = 2; } class B extends A { } $b = new B; $b-foo = 3; // Allowed already, it will create a public property foo in $b -- Etienne Kneuss http://www.colder.ch Men never do evil so completely and cheerfully as when they do it

Re: [PHP-DEV] private properties ....

2007-12-01 Thread Richard Quadling
On 01/12/2007, Jingcheng Zhang [EMAIL PROTECTED] wrote: Well, yes, private denies accessing from other class(including its child class), this is what encapsulation means. But when refering to inheritance, why forbids private properties/methods being *extended* to child classes? This is what I

Re: [PHP-DEV] private properties ....

2007-12-01 Thread Mike Lively
Jingcheng Zhang wrote: Well, yes, private denies accessing from other class(including its child class), this is what encapsulation means. But when refering to inheritance, why forbids private properties/methods being *extended* to child classes? This is what I mean, as the following example:

Re: [PHP-DEV] private properties ....

2007-12-01 Thread Etienne Kneuss
Hello, On Dec 1, 2007 9:38 PM, Richard Quadling [EMAIL PROTECTED] wrote: On 01/12/2007, Jingcheng Zhang [EMAIL PROTECTED] wrote: Well, yes, private denies accessing from other class(including its child class), this is what encapsulation means. But when refering to inheritance, why

Re: [PHP-DEV] private properties ....

2007-11-30 Thread Etienne Kneuss
Hello, On Nov 30, 2007 5:24 PM, Jingcheng Zhang [EMAIL PROTECTED] wrote: Hi Etienne, Is private only an access limiter between classes?If so, I think private properties and methods should be OK to be extended into the child class, but currently that's not the case, You're describing

Re: [PHP-DEV] private properties ....

2007-11-30 Thread Johannes Schlüter
Hi, On Sat, 2007-12-01 at 00:24 +0800, Jingcheng Zhang wrote: Hi Etienne, Is private only an access limiter between classes?If so, I think private properties and methods should be OK to be extended into the child class, but currently that's not the case, and there is also a bug here,

Re: [PHP-DEV] private properties ....

2007-11-30 Thread Jingcheng Zhang
Hi Etienne, Is private only an access limiter between classes?If so, I think private properties and methods should be OK to be extended into the child class, but currently that's not the case, and there is also a bug here, consider the following example: ?php class P { private $name =

Re: [PHP-DEV] private properties ....

2007-11-30 Thread Etienne Kneuss
Hello, On 11/30/07, Marco Kaiser [EMAIL PROTECTED] wrote: Conclusion: 1. Why i can access a private property from a different class instance (name) but same type ? $aa and $bb are instances of aaa but not the same. 2. This doesnt works if cc is a own class with same property name (ie.

[PHP-DEV] private properties ....

2007-11-30 Thread Marco Kaiser
Hi List, ?php error_reporting(E_ALL); class aaa { protected $_parent = null; private $_value = 0; public function setValue($value) { $this-_value = $value; } public function getValue) { return $this-_value; } public function

Re: [PHP-DEV] private properties ....

2007-11-30 Thread Jingcheng Zhang
Well, yes, private denies accessing from other class(including its child class), this is what encapsulation means. But when refering to inheritance, why forbids private properties/methods being *extended* to child classes? This is what I mean, as the following example: ?php class p {