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

The Archive Base Latest Questions

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

So I am working with a settings class that extends a base settings class

  • 0

So I am working with a settings class that extends a base settings class that would be similar to a “global settings”. There are several services and each service has its own settings class that extends the abstract base settings class. The abstract base settings class corresponds to settings that are shared between services. So first I will illustrate with an example below and then I will define the problem:

example:

abstract class BaseSettings {
    protected $settingA;
    protected $settingB;
}

class MyServiceSettings extends BaseSettings {
    private $settingC;
    public $settingD;
}

problem:

If I create a ReflectionClass instance like so..

$reflect = new ReflectionClass($this);

..from either the MyServiceSettings class or the BaseSettings class (because obviously you can’t have an instance of an abstract class), $reflect->getProperties() will always return the properties of both MyServiceSettings and the BaseSettings (and I guess that’s appropriate because we’re really working with a single concrete class)

Now I am sure I could create an empty class that extends the abstract BaseClass to figure out which properties go where (or just get rid of the abstract and create an instance of the BaseClass), but that seems rather messy, so I am wondering if there is, perhaps, a more elegant way to determine which properties belong to the parent class and which belong to the child class?

If you are curious why I am even doing this – I am serializing the settings to a .json file for the purposes of a recovery feature I added so that one can continue from the last atomic operation that last successfully completed. Why I have to do it this way – limitation of the environment.

  • 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-18T03:15:28+00:00Added an answer on June 18, 2026 at 3:15 am

    I would get it like this:

    $class = new ReflectionClass('Some_class_name');
    $properties = array_filter($class->getProperties(), function($prop) use($class){ 
        return $prop->getDeclaringClass()->getName() == $class->getName();
    });
    

    So basically get all properties and iterate through them checking if they were declared in class we reflected.

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

Sidebar

Related Questions

I am working on a uploader class which will use the system's proxy settings
I have a WCF service application with most basic settings working properly on my
I developed a plugin with Settings link that was working fine in WordPress 2.7.
On a site that I am working on, if users change the language settings
I have two AsyncTask that are not working. There must be something in common
I've created a class that extends View in order to draw it myself, in
I've got application settings working just fine. However, I'd like to be able to
I removed the settings.bundle from an app I'm working on as it's no longer
I'm working on a web interface for modifying Oracle database backup settings. One of
I have a working Flex/BlazeDS application (for simple AMF remoting) with the following settings:

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.