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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:01:55+00:00 2026-05-23T23:01:55+00:00

I have a class named DataBoundObject which is quite big. And works good. Its

  • 0

I have a class named DataBoundObject which is quite big. And works good. Its an ORM class i have developed. One of its functions is to automatically do the setXXX() and getXXX() functions so that no coding is required. The following function does that

public function __call($strFunction, $arArguments) {
        $strMethodType = substr ( $strFunction, 0, 3 );
        $strMethodMember = substr ( $strFunction, 3 );

        if(!is_callable(array($this, $strFunction)))
            throw new Exception("Function cannot be called!"); 

        switch ($strMethodType) {
            case "set" :
                return ($this->SetAccessor ( $strMethodMember, $arArguments [0] ));
                break;
            case "get" :
                return ($this->GetAccessor ( $strMethodMember ));
                break;
            default :
                throw new Exception ( "Non existent method call dude!" );
        }
        return false;
    }

Now in a class which derives this i override one function like this:

<?php

require_once ('DataBoundObject.php');
/** 
 * ORM extension of BUBBLES_HOTEL_REVIEWS Tabel
 * @author footy
 * @copyright Ajitah
 * 
 */
class reviews extends DataBoundObject {
    protected $ReviewID;
    //Other codes

    private function setReviewID($ReviewID) {
        throw new Exception ( "Cannot set the review ID Explicitly" );
    }
    //Other codes
    //Other codes
    //Other codes
    //Other codes
    //Other codes    
}
$x = new reviews();
$x->setReviewID(5);

?>

Thus finally i create a new object and try to call setReviewID() function which is private. Why is it not generating any Exception? Besides is_callable() is returning true!

EDIT

Mainly i need help to correct this problem so that it throws an Exception

  • 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-05-23T23:01:55+00:00Added an answer on May 23, 2026 at 11:01 pm

    You can’t override private methods using __call magic in PHP. I allow myself to quote from php.net website http://php.net/language.oop5.visibility#92995, where your question is perfectly answered in a comment:

    1. In the overriding, the method names and arguments (arg’s) must be
      same.

    2. final methods can’t be overridden.

    3. private methods never participate in the in the overriding because
      these methods are not visible in the child classes.

    4. While overriding decreasing access specifier is not allowed

    If you desperately need this feature – your (unconventional) options will be:

    1. Use public scope for the method, documenting the function of its restrictions for other developers in PHPDoc string.
    2. You can use PECL extensions like runkit sandbox http://php.net/book.runkit
    3. Go for code generation or preprocessor.
    4. Choose a different language.

    EDIT

    Note that, protected child method is also hidden form the parent, but there is always an option of overriding __call() in a child. Generally, making too much “magical” overrides may be a bad taste for such a serious undertaken as ORM design.

    PS

    I believe eventually developing a DSL could be an ultimate goal for your project. Before doing so, continuing your project is a nice way to gather respective experience. GL!

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

Sidebar

Related Questions

I have a class named Page with a private property currently called _pageData which
I have a class named toto which I send to a function that does
I have a class named InvoiceLine which has the following properties. public class InvoiceLine
I have one class named handler and this class process the http request comming
I have one class named Question and another named StudentDriver . StudentDriver have a
I have a class named Particle which has a std::set as a member. The
Lets say I have a class named Dog which is a subclass of Animal
In Java i have abstract class named Operation and three its subclasses called OperationActivation,
I have created a class named ListCell which is a subclass of UITableViewCell .
I have one class named A and one class B public class A :

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.