#44033 [Opn]: feature request: make working abstract methods body in abstract classes

From: Date: Sun, 03 Feb 2008 20:33:53 +0000
Subject: #44033 [Opn]: feature request: make working abstract methods body in abstract classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121929@lists.php.net to get a copy of this message
ID: 44033 User updated by: giorgio dot liscio at email dot it Reported By: giorgio dot liscio at email dot it Status: Open Bug Type: Feature/Change Request Operating System: Irrelevant PHP Version: 5.2.5 New Comment: the requested behavior can works with multiple abstract inheritance abstract class One {abstract function m(){echo("one ");}} abstract class Two extends One {abstract function m(){parent::m();echo("two ");}} abstract class Three extends Two {abstract function m(){parent::m();echo("three ");}} class RealClass extends Three { function m(){parent::m();echo("real implementation");} } Previous Comments: ------------------------------------------------------------------------ [2008-02-03 18:57:02] giorgio dot liscio at email dot it Description: ------------ hello i think can be useful make working abstract methods body in abstract classes please read carefully ;) i hope you like it thank you for your time Reproduce code: --------------- <?php abstract class Base { abstract protected function commonCheck() { echo("WOW! "); } } class Real extends Base { // there I MUST implement the abstract method in all cases // the implementation can consists: // 1 - in one new procedure, // 2 - in parent method calling (used the abstract body like a model) // 3 - both protected function commonCheck() { parent::commonCheck(); echo("IT IS WORKING!"); } } ?> Expected result: ---------------- echo("WOW "); echo("IT IS WORKING!"); Actual result: -------------- Fatal error: Abstract function Base::commonCheck() cannot contain body ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44033&edit=1

« previous php.bugs (#121929) next »