Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Class must be declared abstract or implement the remaining methods

Tags:

php

I have a class that implements several abstract methods. When I extend that class I get the following fatal error message:

Class CI_Controller_Rest contains 6 abstract methods and must therefore be declared abstract or implement the remaining methods  

The class with abstract methods:

class CI_Controller_Rest extends CI_Controller {
    public function __construct() {
        parent::__construct();
    }

    abstract public function index();

    abstract public function get();

    abstract public function head();

    abstract public function post();

    abstract public function put();

    abstract public function delete();
}  

The class where I extend CI_Controller_Rest:

class Welcome extends CI_Controller_Rest {

    public function __construct() 
    {
        parent::__construct();
    }

    public function index() {}

    public function get() {}

    public function head() {}

    public function post() {}

    public function put() {}

    public function delete() {}
}  

What should I do more than this?

like image 297
Andrew Avatar asked Oct 02 '12 10:10

Andrew


1 Answers

If a class has one or more abstract functions, it MUST be declared as an abstract class:

abstract class CI_Controller_Rest extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    abstract public function index();

    abstract public function get();

    abstract public function head();

    abstract public function post();

    abstract public function put();

    abstract public function delete();
}  
like image 196
Wayne Whitty Avatar answered Oct 25 '22 07:10

Wayne Whitty