Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:38:17+00:00 2026-06-04T11:38:17+00:00

There are lots of examples of child classes calling overridden parent methods, most commonly

  • 0

There are lots of examples of child classes calling overridden parent methods, most commonly parent::__construct(). In these cases, however, you are actually calling the parent from a concrete method in the child itself.

Is there a way that I can recursively call a method from the child to the first ancestor, using an inherited method?

If I use parent::methodName() in my abstract parent class it causes a fatal error saying ‘Cannot access parent:: when current class scope has no parent’. Presumably this is because ‘parent’ is being evaluated relative to the abstract class itself, not the current class context.

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:38:19+00:00Added an answer on June 4, 2026 at 11:38 am

    Maybe something like this? (untested)

    foreach (get_class_parents($this) as $className) {
        (new ReflectionMethod($className, __METHOD__))->invoke($this, $args...);
    }
    

    I hate when I see this kinda junk in code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are lots of examples out there on this, but they
I am using data.table package quite a bit. There are lots of examples of
There are lots of examples on this site about adding to NSMutableArray and I
There are lots of examples how to install windows service in one line: ManagedInstallClass.InstallHelper(
There are lots of examples out there about how to open and use a
There are lots of examples on this, and I'm pretty sound with the concept
There are lots of examples of how to strip HTML tags from a document
There are lots of examples around that show how to get a list of
There are lots of examples of how to create skinnable components in AS3 using
I'm using AutoMapper which is a great tool. There's lots of examples converting from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.