package access (OOP)
Posted: Mon Feb 15, 2010 12:51 pm
Hi,
how you usually solve missing "package" access visiblity in php?
Let's say we have following code:
how to disallow access to property $var from the outside?
Is there any pretty (in the name of OOP) solution to this? Or how is it commonly solved?
Thanks in advance.
how you usually solve missing "package" access visiblity in php?
Let's say we have following code:
Code: Select all
class A {
public $b;
public function __construct() {
$this->b = new B();
$this->b->var = 0;
}
}
class B {
public $var; // want to set its public visibility only for the package
}
Code: Select all
$a = new A();
$a->b->var = 1; //not good
Thanks in advance.