Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Empty abstract function cannot contain body

Tags:

I'm trying to build an abstract class (StatusService) which along with some basic logic defines methods that need to be present in extended classes, but am running into this error that I can't explain:

Fatal error: Abstract function StatusService::upd() cannot contain body in /path/to/lib/services/service.class.php on line 62

Snippet of my base class:

abstract class StatusService {
    /** ... */

    /**
     * @return boolean
     * @abstract
     */
    abstract public function upd(){}
}

Now I can be completely wrong (haven't written much abstract classes yet), but it doesn't look like it has a body to me..? I would appreciate any pointers to help figure out what I'm doing wrong.

My extended class (just one right now) does define the upd() function and returns a value, but it's still dumping that error on me. In case it matters, this is PHP 5.4.4 running on MAMP Pro.

like image 806
Mark Hamstra Avatar asked Oct 14 '12 22:10

Mark Hamstra


1 Answers

abstract public function upd(){}

should be

abstract public function upd();

Note that braces.. forms the body of a method.

like image 169
Lews Therin Avatar answered Sep 22 '22 07:09

Lews Therin