<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
 <sect1 id="language.oop5.abstract">
  <title>Object Abstraction</title>

  <para>
   PHP 5 introduces abstract classes and methods. It is not allowed to create
   an instance of a class that has been defined as abstract.  Any class that
   contains at least one abstract method must also be abstract.  Methods
   defined as abstract simply declare the method's signature they cannot
   define the implementation.
  </para>

  <para>
   The class that implements the abstract method must define with the same
   <link linkend="language.oop5.visibility">visibillity</link> or weaker. If the
   abstract method is defined as protected, the function implenetation must be
   defined as either protected or public.
  </para>

  <example>
   <title>Abstract class example</title>
    <programlisting role="php">
<![CDATA[
<?php

abstract class AbstractClass {

   /* Force Extending class to define this method */
   abstract protected function getValue();

   /* Common method */
   public function print() {
     print $this->getValue();
   }

}

class ConcreteClass1 extends AbstractClass {

   protected function getValue() {
     return "ConcreteClass1";
   }

}

class ConcreteClass2 extends AbstractClass {

   protected function getValue() {
     return "ConcreteClass2";
   }

}

$class1 = new ConcreteClass1;
$class1->print();

$class2 = new ConcreteClass2;
$class2->print();
?> 
]]>
   </programlisting>
  </example>

   <para>
    Old code that has no user-defined classes or functions named
    'abstract' should run without modifications.
   </para>
 </sect1>
 
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->