> Most often if I need a super __construct(), I don't need it exactly
> before or exactly after the bottom constructor but at a specific point
> where I can setup super's input data and do stuff to its output.

I've most often seen, or reluctantly implemented, the Call Super
antipattern by putting the call at the bottom of sub code.

It's true that it's an antipattern regardless of "advisory" placement.
But to me, somewhere-in-the-middle is even smellier than usual, since
in human hands that's got to be more prone to failure.

I think if Contractual Call Super were considered for the language it
should have before and after variants, not just after. There isn't a
practical way to declare "at some point," is there, even if you wanted
it?

> What is the typical use case for calling all supers (before or after the
> class' __construct itself) ?

I can't think of a valid case in my memory for _all_ supers. Typically
you mean to call the immediate super _or_ the root super. Which is of
course the problem with the "advisory" form of this pattern, since
innocently inserting an intermediate class breaks your code.

If this feature were introduced, I see no reason for it to be allowed
to call more than one method for each occurrence of 'sequential'
keyword.

That is,

class A { sequentialBefore function __construct() {} }
class Asub extends A { function __construct() {} }
class Asubsub extends Asub { function __construct() {} }

would run A::__construct and then Asubsub::construct()

class A { sequentialBefore function __construct() {} }
class Asub extends A { sequentialBefore function __construct() {} }
class Asubsub extends Asub { function __construct() {} }

would run A::__construct, Asub::__construct, Asubsub::__construct

class A { sequentialBefore function __construct() {} }
class Asub extends A { sequentialAfter function __construct() {} }
class Asubsub extends Asub { function __construct() {} }

would run A::__construct, Asubsub::construct(), Asub::__construct

I'm not particularly cheering for this feature but enjoy thinking
about how it might work. If you see my notes on the previous thread
you can see I'm pretty adamant about Call Super being very bad
_unless_ it's baked into the language in an interesting way.

-- S.


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

Reply via email to