Edit report at https://bugs.php.net/bug.php?id=44033&edit=1

 ID:                 44033
 Comment by:         dagguh at gmail dot com
 Reported by:        giorgio dot liscio at email dot it
 Summary:            make working abstract methods body in abstract
                     classes
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   *
 PHP Version:        5.2.5
 Block user comment: N
 Private report:     N

 New Comment:

You obviously don't know what abstract methods are about.

Learn OOP, please. This is what you want:

<?php

abstract class Base
{
      protected final function commonCheck()
      {
           echo("WOW! ");
           $this->customCheck();
      }

     protected abstract function customCheck();
}

class Real extends Base
{

      protected function customCheck()
      {
            echo("IT IS WORKING!");
      }
}

?>


Previous Comments:
------------------------------------------------------------------------
[2008-02-03 20:33:53] giorgio dot liscio at email dot it

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");}
}

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=44033&edit=1

Reply via email to