Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2005
    Posts
    63

    Unanswered: Execute ancestor method before descendant method from another method

    Is there any way to invoke the ancestor method and then the descendant method? I'm not saying:

    parent::method();
    ...
    <script for the current method>


    What I'm looking for is to manually execute the ancestor method (bypassing the descendant method) and then execute the descendant method from 'another' method. All of this execution is done from another method. I'm creating an ancestor class where the descendants do not have to execute the ancestor method.

    I tried the ReflectionMethod class but it doesn't work:

    $method = new ReflectionMethod( 'Counter', 'increment' );
    $method->invokeArgs( $method, array( $start, $step ));

    It bombs saying 'Invoking of Counter::increment failed'.

    thanks,
    Last edited by screenmates; 05-17-06 at 06:50.

  2. #2
    Join Date
    Jul 2005
    Posts
    63
    If the above is not clear, here is the clarfication and what I'm trying to accomplish:

    I'm instantiating a list of descendant classes from another class and trying to invoke the ancestor methods of those classes first and then the descendant methods (at the same time) so the developer does not need to invoke those methods (ancestor/descendant) in the descendant classes - just write code in the descendant methods (for the descendant). But the descendant methods depend on their ancestor methods for some initialization/validations. In other words, the descendants do not have to execute the ancestor method nor contain code to invoke the ancestor script. I tried the ReflectionMethod class but it doesn't work:

    $method = new ReflectionMethod( 'Counter', 'increment' );
    $method->invokeArgs( $method, array( $start, $step ));

    It bombs saying 'Invoking of Counter::increment failed'.

    Hope the above is clear...

    Thanks,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •