Hello internals,

The following code:
<?php

class a {
        protected $bla;
}

class b extends a {
        public function murks() {
                return $this->bla;
        }
}

$o = new b;
print_r($o)
?>

results in two properties which is wrong:
  b Object
  (
      [bla] =>
      [bla:protected] =>
  )

I tried to fix this bug and found three solutions:

1) when the new class does its inheritance checks it could 'merge' the
two properties (remove the implicit public one). But this approach is very
small and imho the wrong way.

2) implicit public properties are declared at compile time by the function
zend_do_declare_implicit_property(). This function has access to the class
entry of the class to be declared. However that class is not initialized
yet and doesn't know about it's parent class entry. So i suggest we make
this code new opcode. Since then we would do it at run time the class entry
can already know its parent and the property lookup can finally find
inherited members.

3) Don't have implicit public declared properties at all. That would be a
more purist approach which only allows properties declared in the class and
dynamic object properties that are not part of the class. Unluckily the
problem also happens when you declare the property in the derived class as
public, too.

So i think we really need a new opcode.

Any thoughts?


-- 
Best regards,
 Marcus                          mailto:[EMAIL PROTECTED]

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to