What would happen if you "call the parent constructor":

class A extends B {
   static public function __static() {
        B::__static();
   }
}

On Mon, Apr 13, 2015 at 5:23 PM, Johannes Schlüter <johan...@schlueters.de>
wrote:

> Hi,
>
> On Mon, 2015-04-13 at 15:37 +0200, Johannes Ott wrote:
> > finally I managed to do my first RFC draft.
> >
> > https://wiki.php.net/rfc/static_class_constructor
> >
> > I hope I have done everything correct so far and I'm looking forward to
> > your feedback on it.
>
> In my opinion this makes the language way more complex as there are more
> places which "suddenly" execute code but solves a small problem compared
> to that. (Which actually is an issue many people would suggest to avoid
> completely instead of ennobling this with a language feature.
>
> Why am I saying it makes the language more complex? - Your proposal
> seems to miss mentioning when exactly the method is executed. what is
> the output of
>
>
> a.php:
> <?php
> echo 'A: '.__FILE__.':'.__LINE__."\n";
> class A {
>     static function __static() {
>       echo __CLASS__.'::'.__METHOD__."\n";
>     }
> }
> echo 'B: '.__FILE__.':'.__LINE__."\n";
> class B {
>     static function __static() {
>       echo __CLASS__.'::'.__METHOD__."\n";
>     }
> }
> echo 'C: '.__FILE__.':'.__LINE__."\n";
> ?>
>
> b.php:
> <?php
> echo 'D: '.__FILE__.':'.__LINE__."\n";
>
> C::$foo = 23;
> echo 'E: '.__FILE__.':'.__LINE__."\n";
>
> include 'a.php';
> echo 'F: '.__FILE__.':'.__LINE__."\n";
>
>
> class C {
>     static $foo = 0;
>     static function __static() {
>       echo __CLASS__.'::'.__METHOD__."\n";
>     }
> }
>
> echo 'G: '.__FILE__.':'.__LINE__."\n";
>
> class D extends B {
>     static function __static() {
>       echo __CLASS__.'::'.__METHOD__."\n";
>     }
> }
>
> echo 'H: '.__FILE__.':'.__LINE__."\n";
> ?>
>
>
> Mind that in b.php we make use of class C above the declaration, which
> we can do as C is a simple class and can be bound early during
> compilation. Class D however can only be bound during run-time, after
> including a.php, which happens after C was already used.
>
> johannes
>
>

Reply via email to