note 78388 modified in language.oop5.abstract by felipe
| From: | felipe@php.net | Date: | Mon, 24 Mar 2008 23:20:52 +0000 |
| Subject: | note 78388 modified in language.oop5.abstract by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-137526@lists.php.net to get a copy of this message | ||
Ok...the docs are a bit vague when it comes to an abstract class extending another abstract class.
An abstract class that extends another abstract class doesn't need to define the abstract
methods from the parent class. In other words, this causes an error:
<?php
abstract class class1 {
abstract public function someFunc();
}
abstract class class2 extends class1 {
abstract public function someFunc();
}
?>
Error: Fatal error: Can't inherit abstract function class1::someFunc() (previously declared
abstract in class2) in /home/sneakyimp/public/chump.php on line 7
However this does not:
<?php
abstract class class1 {
abstract public function someFunc();
}
abstract class class2 extends class1 {
}
?>
An abstract class that extends an abstract class can pass the buck to its child classes when it
comes to implementing the abstract methods of its parent abstract class.
--was--
Ok...the docs are a bit vague when it comes to an abstract class extending another abstract class.
An abstract class that extends another abstract class doesn't need to define the abstract
methods from the parent class. In other words, this causes an error:
[php]
abstract class class1 {
abstract public function someFunc();
}
abstract class class2 extends class1 {
abstract public function someFunc();
}
[/php]
Error: Fatal error: Can't inherit abstract function class1::someFunc() (previously declared
abstract in class2) in /home/sneakyimp/public/chump.php on line 7
However this does not:
[php]
abstract class class1 {
abstract public function someFunc();
}
abstract class class2 extends class1 {
}
[/php]
An abstract class that extends an abstract class can pass the buck to its child classes when it
comes to implementing the abstract methods of its parent abstract class.
http://php.net/manual/en/language.oop5.abstract.php