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 9025567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:18:15+00:00 2026-06-16T06:18:15+00:00

I have an abstract parent class Mongo_Document (from mongodb-php-odm ) and an inherited class

  • 0

I have an abstract parent class Mongo_Document (from mongodb-php-odm) and an inherited class Model_ActionPlan. Mongo_Document has magic __isset and __get methods that interact with an array inside the Mongo_Document class.

I am trying to use the following code (snippet from inside a method of Model_ActionPlan):

if (isset($this->status))
{
    if (($this->status === "closed") AND ($this->close_type != "failure"))
    {
        return;
    }
}

(Note that close_type is guaranteed to be set if status == 'closed'.)

The isset call returns true and then execution proceeds to the next statement. There, I receive the following error:

 Undefined property: Model_ActionPlan::$status

However, if I replace $this->status with parent::__get('status'), this code works as expected. Note that everywhere else in the program, I am able to use:

$ap = new Model_ActionPlan($plan_id);
echo $ap->status;
// Prints 'closed' (or 'active') as expected

It is only here, inside the class itself, that this doesn’t work.

I looked around and I can’t seem to find anywhere that says that magic methods can’t be called in the child class. I could use the parent::__get call instead but I think that is probably the wrong way to do it. Does anyone know if there is a right/better way to do this?

Updated #1 2012-12-16:
The full code of the parent class is here on Github.

Updated #2 2012-12-18:
For the people who asked about where or whether it is set properly, the answer is that since calling parent::__get('status') does work, the problem is obviously not that the variable isn’t getting set. The __get() is getting its data from a private instace variable called _object. If I var_dump($this), I see that $this->_object['status'] does equal the expected “closed” value.

Update #3:
The code of the child class is available at https://gist.github.com/4332062.
The important part starts on line 69.


I have seen this similar question but that one is about using a parent’s magic method to get the child’s properties and my issue is using the parent’s getter to get the parent’s properties.

  • 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-16T06:18:16+00:00Added an answer on June 16, 2026 at 6:18 am

    The __get function in the parent is somewhat complex, so I haven’t fully figured out whether the following might be happening or not. If your __get function, once called, is in some way triggering another call back into itself (perhaps with some intervening calls to other functions on the stack), this is exactly what would happen.

    See http://php.net/manual/en/language.oop5.overloading.php#55486, which shows the exact same type of error being logged when the getter triggers a call to itself. In that instance, it is pretty easy to spot, but with a more complicated call graph of something like func() to __get() to funcB() to funcC() to __get(), it would not be easy to spot.

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

Sidebar

Related Questions

I have an abstract parent class Item , from which different types of items
I have a abstract Parent class that has multiple children. I'd like the child
I have an abstract parent class which child classes that inherit from it. I
I have an abstract parent class(Product) and two child classes that inherit from it(Book,Software).
Let's say I have these class hierarchy : public abstract class Parent { }
I have a model that looks something like this: public abstract class Parent {
I have one parent class, which is abstract class for now, for four different
I have an abstract base class class AbstractClass { Col<AbstractClass> parent public AbstractClass() {
Suppose we have 2 classes, Child, and the class from which it inherits, Parent.
Let's say I have something like this: abstract class Parent { protected function foobar($data)

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.