ID:               36707
 User updated by:  andreigurin at tiscali dot it
 Reported By:      andreigurin at tiscali dot it
-Status:           Bogus
+Status:           Open
 Bug Type:         Class/Object related
 Operating System: windows xp sp2 / linux centos /
 PHP Version:      4.4.2
 New Comment:

Well, IMHO, such a behavior is violating the basics of OOP...
Documentation is missing(am I right?). This is a BUG (a feature???
mmm...). In php4 (private & public modifiers missing), you may access
every object field...
<?php
error_reporting(E_ALL);
class Foo {
    protected $__prv;
    public function Foo($v) {
        $this->__prv = $v;
    }
    public function prv() {
        return $this->__prv;
    }
    function tst() {
        Bar::babar();
    }
}
class Bar {
    public function babar() {
        $this->__prv = 'a very very bad value'; /* IS IT OK???!!!*/
        print $this->prv();
    }
}
$foo = new Foo('PRV VALUE');
$foo->tst(); /* $foo->__prv is modified now!!!*/
?>


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

[2006-03-13 10:42:24] andreigurin at tiscali dot it

Are there a piece of documentation describing this behavior? Thanks for
reply!

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

[2006-03-13 10:37:58] [EMAIL PROTECTED]

This is expected and it was done in order to keep compatibility with
4.x.

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

[2006-03-13 10:34:12] andreigurin at tiscali dot it

ok, try this

<?php

error_reporting(E_ALL);

class Foo {
        protected $__prv;
       
    public function Foo($v) {
        $this->__prv = $v;
    }
       
        public function prv() {
        return $this->__prv;
    }
       
        function tst() {
                Bar::babar();
        }
}

class Bar {

        public function babar() {
                print $this->prv();
        }
}

$foo = new Foo('PRV VALUE');
$foo->tst();

?>

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

[2006-03-13 09:19:01] [EMAIL PROTECTED]

Works fine both with 4.x and 5.x.
No bug here.

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

[2006-03-13 09:18:28] andreigurin at tiscali dot it

Look here: This happens in 4.xxx versions, and in 5.xxx, my code is for
version 5.
I reported the first version i tested it. It equally falls on 4 an on
5.

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

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/36707

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

Reply via email to