Re: include methods of one class in another

From: Date: Thu, 21 Aug 2008 12:49:09 +0000
Subject: Re: include methods of one class in another
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-278464@lists.php.net to get a copy of this message
Pavel schreef:
Hello, firstly, sorry for my English... I have class: //--- class manageClassError{
    private $errorsList=array();
               private function addError($ex){
        $errorsList[]=$ex;
    }
    public function isError(){
        return (bool)(count($this->errorsList));
    }
    public function getErrorsList(){
        return $this->errorsList;
    }
    public function returnLastError(){
        $cErrorsList=count($this->errorsList);
        If($cErrorsList==0){
            return false;
        }else{
            return $this->errorsList[$cErrorsList-1];
        }
    }
    }
//--- this class alone can't do anything practicality, but if "include" this class to another it can salve other class to copy code of first class... so i had many class,which contain all method of manageClassError and i need to mark managing error in other class...can you help me?
use a decorator pattern or wait till hell freezes over and the core devs actually allow the Traits functionality into php. Traits is actually well thought out and implemented addition AFAICT ... but there are countless half-baked, 'must-have', buzzword-of-the-moment stuff that needs to be implemented first ... and the unicode stuff (which is actually going to be kick-ass if they get it right) you can attribute this to the Narky::Sarcasm namespace.
P.S. I think, use "extends" isn't good for my idea...


« previous php.general (#278464) next »