Good evening Stas, Am Mittwoch, den 30.04.2008, 10:02 -0700 schrieb Stanislav Malyshev: [...] > You can easily do this by having __get call getProperty. That's like 1 > line of code to do. No language change needed.
With the substantial difference, that __get()/__set() does not work
properly with inheritance, as the language can't verify the LSP.
class Mother
{
public function __set($property, $value)
{
switch ($property) {
case 'foo':
$this->_foo = (string)$value;
return true;
}
}
}
class Child extends Mother
{
public function __set($property, $value)
{
switch ($property) {
case 'foo':
throw new Exception('Foo is not allowed to set');
}
return parent::__set($property, $value);
}
}
This means, Child behaves more strict than Mother and breaks the
principle.
With advanced properties, the interpreter could at least verify that
getting/setting properties is not stricter in subclasses.
SO far, Lars
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
