ID:               37212
 Updated by:       [EMAIL PROTECTED]
 Reported By:      andreasblixt at msn dot com
 Status:           Assigned
 Bug Type:         Class/Object related
 Operating System: *
-PHP Version:      5.1.*
+PHP Version:      5.1.*, 5.2.0-dev
 Assigned To:      helly
 New Comment:

Fixed in HEAD so far.


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

[2006-05-27 02:05:19] [EMAIL PROTECTED]

Fix requies API change so it is not doable in 5.1.

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

[2006-05-27 01:40:49] [EMAIL PROTECTED]

The problem is that right now struct property_info does not know where
the property was declared. Thus what the engine sees is B accessing
some protected property in C. The fix seems however quite easy. I'll
give it a try.

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

[2006-05-05 19:03:33] [EMAIL PROTECTED]

Probably a missing check if the property was declared in a common
parent class?

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

[2006-04-27 19:39:38] crescentfreshpot at yahoo dot com

Odd. Here is a complete example.
<?php

class A {
    protected $value;
    public function __construct($val) {
        $this->value = $val;
    }
    public function copyValue($obj) {
        $this->value = $obj->value;
    }
    protected function getValue() {
        return $this->value;
    }
}

class B extends A {
    public function copyValue($obj) {
        $this->value = $obj->getValue(); // this works
        $this->value = $obj->value; // this is fatal
    }
}
class C extends A {}

$B = new B("Value from B");
$C = new C("Value from C");
$B->copyValue($C);

?>

Strange that the method call works but the property access doesn't.
Both are protected.

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

[2006-04-27 15:41:26] andreasblixt at msn dot com

The property is not being redeclared in C, though. It is still a
property of A, structure-wise. A method declared and called in the same
way as the property does not cause any error. Here's a simple non-code
example:

protected method() is declared in A.
protected $property is declared in A.
B and C both extend A.
Method in B tries to access $C->property [FATAL ERROR]
Method in B tries to access $C->method() [No error]

One could even make method() return $this->property which would not
cause an error either. It would be expected that both the property and
method would have the same visibility when declared in the same class.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/37212

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

Reply via email to