Need help with an error in somebody else's OOP PHP

Hi

I'm looking into an issue but I am not an advanced (or OOP) PHP developer - I do a little bit of everything, design, front-end/html/css/js, procedural PHP and Wordpress, as well as being a Windows server and network administrator.

The original developer of the script is unavailable and I am getting the following errors after the hosting server changed PHP version from 4.x to 5.3:

-----------------------------------------------------------
[]: Declaration of OptionManager::Get() should be compatible with that of ItemManager::Get()
in /home/upsca5/public_html/croatiandating/lib/php5/class.ItemManager.php:201

Stack Dump:

errorHandler(integer(2048), string("Declaration of OptionManager::Get() should be compatible with that of ItemManager::Get()"), string("/home/upsca5/public_html/croatiandating/lib/php5/class.ItemManager.php"), integer(201), array(array))
    [/home/upsca5/public_html/croatiandating/init.php:10]

include_once()
    [/home/upsca5/public_html/croatiandating/init.php:10]

include(string("/home/upsca5/public_html/croatiandating/init.php"))
    [/home/upsca5/public_html/croatiandating/db_connect.php:62]

include(string("/home/upsca5/public_html/croatiandating/db_connect.php"))
    [/home/upsca5/public_html/croatiandating/index2.php:20]
-----------------------------------------------------------

This is the code in the file, I'm not sure if all of it needed pasted in but as I tend to only do procedural PHP I wasn't sure too much about the OOP classes.

Can anyone spot a quix fix for this error?

-----------------------------------------------------------
<?

require_once(__INCLUDE_CLASS_PATH."/class.Main.php");
require_once(__INCLUDE_CLASS_PATH."/class.SingeltonStorage.php");
require_once(__INCLUDE_CLASS_PATH."/class.Options.php");
require_once(__INCLUDE_CLASS_PATH."/class.Template.php");

class ItemManager extends Main{
    public $aCache = array();

    function Get(){}
    function GetList(){}
    /**
     * Return value of option
     *
     * @param string $name
     * @return mixed value
     * @access public
     */
    function GetValue($name){
        $item = $this->Get($name);
        if ($item === null) {
            return $this->CriticalError("Can't create option $name");
        }
        return $item->value;
    }


    /**
     * Remove option from pull
     *
     * @param string $name
     * @return bollean
     * @access public
     */

    function Clear($name){
        if (isset($this->aCache[$name])) {
            unset($this->aCache[$name]);
        }
        return true;
    }


    /**
     * Clear list of options
     *
     * @access public
     */
    function ClearAll(){
        $this->aCache = array();
    }
}

class OptionManager extends ItemManager{

    /**
     * Return static link to object
     *
     * @return static link
     * @access public
     */
    static function & getInstance(){
        $manager = & SingeltonStorage::get("instance", "OptionManager", null);
        if ($manager === null){
            $manager = new OptionManager;
        }
        return $manager;
    }

    /**
     * Return option object from pull if it is not in pull create option and add to pull
     *
     * @param string $name
     * @return object
     * @access public
     */
    function Get($name,$row=null){
        $db = & db::getInstance();
        if (isset($this->aCache[$name]))
        {
            return $this->aCache[$name];
        } else {
            if ($row === null){
                $eName = $db->escape($name);
                $option = $db->get_row("SELECT * FROM options WHERE Name='$eName'");
                if ($option == 0)
                    return $this->CriticalError("Unknown option name [$name]");
            } else {
                $option = $row;
            }
            switch ($option->Type) {
                case 'numeric'	    :$this->aCache[$name] = new NumericOption();break;
                case 'skin'		    :$this->aCache[$name] = new SkinOption();break;
                case 'string'	    :$this->aCache[$name] = new StringOption();break;
                case 'list'	        :$this->aCache[$name] = new ListOption();break;
                case 'email'        :$this->aCache[$name] = new EmailOption();break;
                case 'url'	        :$this->aCache[$name] = new UrlOption();break;
                case 'dateformat'	:$this->aCache[$name] = new DateFormatOption();break;
                case 'timeformat'	:$this->aCache[$name] = new TimeFormatOption();break;
                case 'language'		:$this->aCache[$name] = new LangOption();break;
                default:
                        return $this->CriticalError("Unknown option Type [$option->Type]");
            }
            $data = ($row === null) ? $name : $row;
            $this->aCache[$name]->Init($data);
            return $this->aCache[$name];
        }
    }

    /**
     * Return list of options
     *
    * @param string $name
     * @return array
     * @access public
     */
    function GetList(){
        $db = & db::getInstance();
        $aOptions = $db->get_results("
                                SELECT 	A.Name,
                                        A.Value,
                                        A.Label,
                                        A.Config,
                                        A.Type,
                                        A.Comments,
                                        B.Name AS GroupName,
                                        B.Title AS GroupTitle
                                FROM options A
                                    INNER JOIN optionsgroup B
                                    ON (A.OptionsGroup_ID = B.OptionsGroup_ID)
                                ORDER BY `Order`
        ");
        foreach ($aOptions as $row){
            $this->Get($row->Name,$row);
        }
        return $this->aCache;
    }

    /**
     * Return list of options by group
     *
     * @param string $name
     * @return array
     * @access public
     */
    function GetListByGroup($name){
        $aResult = array();
        $db = & db::getInstance();
        $eName = $db->escape($name);

        $oGroup = $db->get_row("
                            SELECT OptionsGroup_ID
                            FROM optionsgroup
                            WHERE
                                Name = '$eName'
                            ");
        if (!$oGroup)
            return $this->CriticalError("Incorrect group name $name");

        $aGroups = $db->get_results("
                                    SELECT Name
                                    FROM options
                                    WHERE OptionsGroup_ID = '$oGroup->OptionsGroup_ID'
                                    ORDER BY `Order`
                                       ");
       if (is_array($aGroups))
            foreach ($aGroups as $row){
                $aResult[] = $this->Get($row->Name);
            }
        return $aResult;
    }

    /**
     * Return list of groups
     *
     * @return array List of objects
     * @access public
     */
    function GetGroupList(){
        $db = & db::getInstance();
        $aGroups = $db->get_results("SELECT * FROM optionsgroup");
        foreach ($aGroups as $row) {
            $row->Title = (defined($row->Title)) ? constant($row->Title) : $row->Title;
            $aResult[] = $row;
        }
        return $aResult;
    }

    /**
     * Return group by name
     *
     * @return object
     * @access public
     */
    function GetGroup($name){
        $db = & db::getInstance();
        $eName = $db->escape($name);
        $oGroup = $db->get_row("SELECT * FROM optionsgroup WHERE Name='$eName'");
        if (!$oGroup)
            return $this->Error("Can't find group $name");
        return $oGroup;
    }

}
class MTemplateManager extends ItemManager{

    /**
     * Return static link to object
     *
     * @return static link
     * @access public
     */
    static function & getInstance(){
        $manager = & SingeltonStorage::get("instance", "MTemplateManager", null);
        if ($manager === null){
            $manager = new MTemplateManager;
        }
        return $manager;
    }

    /**
     * Return template object from pull if it is not in pull create template and add to pull
     *
     * @param string $name
     * @return object
     * @access public
     */
    function Get($name){
        if (isset($this->aCache[$name]))
        {
            return $this->aCache[$name];
        } else {
            $parser = new StrictParser();
            $this->aCache[$name] = new MTemplate($name,$parser);
        }
        return $this->aCache[$name];
    }

    /**
     * Return list of options
     *
     * @param string $name
     * @return array
     * @access public

    */
    function GetList(&$pager){
        $db = & db::getInstance();
        $count = $db->get_var("SELECT count(*) AS cnt FROM mailtemplate");

        $limit = $pager->GetLimit($count);
        $aTemplates = $db->get_results("SELECT * FROM mailtemplate $limit");
        foreach ($aTemplates as $row){
            $this->Get($row->Name);
        }
        return $this->aCache;
    }
}
class PTemplateManager extends ItemManager{

    /**
     * Return static link to object
     *
     * @return static link
     * @access public
     */
    static function & getInstance(){
        $manager = & SingeltonStorage::get("instance", "PTemplateManager", null);
        if ($manager === null){
            $manager = new PTemplateManager;
        }
        return $manager;
    }

    /**
     * Return template object from pull if it is not in pull create template and add to pull

    *
     * @param string $name
     * @return object
     * @access public
     */
    function Get($name){
        $db = & db::getInstance();
        if (isset($this->aCache[$name]))
        {
            return $this->aCache[$name];
        } else {
            $parser = new EvalParser();
            $this->aCache[$name] = new PTemplate($name,$parser);
        }
        return $this->aCache[$name];
    }

    /**
     * Return list of options
     *
     * @param string $name
     * @return array
     * @access public
     */
    function GetList(){
        $db = & db::getInstance();
        $aTemplates = $db->get_results("SELECT * FROM pagetemplate");
        foreach ($aTemplates as $row){
            $this->Get($row->Name);
        }
        return $this->aCache;
    }
}

?>

Open in new window


-----------------------------------------------------------

Many thanks in advance if you can help :-)
VolunteerGlasgowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I'm fairly sure you want to refactor this entire application.  PHP's object model at PHP 4 was amazingly lame and it has been completely rewritten for PHP 5+.  Also, PHP 5.3 is obsolete, so if you're going to modernize this app, choose one of the current levels of PHP listed in the upper right corner of this page: http://php.net.  

My guess is that any "quick fix" in one area is going to turn up a spooky action in another area, and you will find yourself playing Whack-A-Mole with a cascade of errors and incompatibilities. The faster way to a working solution is to rewrite it from the ground up using the modern OOP principles as implemented in the PHP5+ object model.

This is just a guess because I have none of the testing tools, but I'll try to explain what I think might be causing the error.  At line 11, where ItemManager extends Main, we have this:

function Get(){}

What that means is that a public method named Get() has no arguments and no body.  In other words, it's a null function, accepting no inputs and returning no outputs.  Now look at line 78.

function Get($name,$row=null){

That is inside OptionManager, which extends ItemManager.  The conflicting definitions of the Get method may be leading to some kind of trouble, causing the error.  It's just a guess, but since I've never seen any method definition without a type hint (at least not recently) I get the feeling that this may be a possible cause.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VolunteerGlasgowAuthor Commented:
Thank you, I managed to identify all the empty functions across various classes.  It was indeed a bit whack-the-monkey but I got through it so the site is now working again.
0
Ray PaseurCommented:
Thanks for the points and best of luck with it! ~Ray
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.