cvs: phpdoc /en/language/oop5 final.xml

From: Date: Wed, 29 Sep 2004 19:53:43 +0000
Subject: cvs: phpdoc /en/language/oop5 final.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969364350@lists.php.net to get a copy of this message
helly Wed Sep 29 15:53:43 2004 EDT Modified files: /phpdoc/en/language/oop5 final.xml Log: - Include final classes http://cvs.php.net/diff.php/phpdoc/en/language/oop5/final.xml?r1=1.4&r2=1.5&ty=u Index: phpdoc/en/language/oop5/final.xml diff -u phpdoc/en/language/oop5/final.xml:1.4 phpdoc/en/language/oop5/final.xml:1.5 --- phpdoc/en/language/oop5/final.xml:1.4 Mon Sep 27 10:38:44 2004 +++ phpdoc/en/language/oop5/final.xml Wed Sep 29 15:53:43 2004 @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <sect1 id="language.oop5.final"> <title>Final Keyword</title> <para> PHP 5 introduces the final keyword, which prevents child classes from - overriding a method by prefixing the definition with final. + overriding a method by prefixing the definition with final. If the class + itself is being defined final then it cannot be extended. </para> <example> @@ -33,6 +34,29 @@ </programlisting> </example> + <example> + <title>Final class example</title> + <programlisting role="php"> +<![CDATA[ +<?php +final class BaseClass { + public function test() { + echo "BaseClass::test() called\n"; + } + + // Here it doesn't matter if you specify the function as final or not + final public function moreTesting() { + echo "BaseClass::moreTesting() called\n"; + } +} + +class ChildClass extends BaseClass { +} +// Results in Fatal error: Class ChildClass may not inherit from final class (BaseClass) +?> +]]> + </programlisting> + </example> </sect1> <!-- Keep this comment at the end of the file

« previous php.doc (#969364350) next »