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

From: Date: Wed, 16 Apr 2008 16:31:46 +0000
Subject: cvs: phpdoc /en/language/oop5 typehinting.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-1512@lists.php.net to get a copy of this message
felipe Wed Apr 16 16:31:46 2008 UTC Modified files: /phpdoc/en/language/oop5 typehinting.xml Log: - Added information about NULL as the default parameter value http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop5/typehinting.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/language/oop5/typehinting.xml diff -u phpdoc/en/language/oop5/typehinting.xml:1.5 phpdoc/en/language/oop5/typehinting.xml:1.6 --- phpdoc/en/language/oop5/typehinting.xml:1.5 Sun Nov 11 15:03:30 2007 +++ phpdoc/en/language/oop5/typehinting.xml Wed Apr 16 16:31:45 2008 @@ -1,11 +1,13 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.5 $ --> +<!-- $Revision: 1.6 $ --> <sect1 xml:id="language.oop5.typehinting" xmlns="http://docbook.org/ns/docbook"> <title>Type Hinting</title> <para> PHP 5 introduces Type Hinting. Functions are now able to force parameters to be objects (by specifying the name of the class in the function - prototype) or arrays (since PHP 5.1). + prototype) or arrays (since PHP 5.1). However, if <type>NULL</type> is used + as the default parameter value, it will be allowed as an argument for any + later call. </para> <example> @@ -100,6 +102,24 @@ ?> ]]> </programlisting> + <para> + Type hinting allowing NULL value: + </para> + <programlisting role="php"> +<![CDATA[ +<?php + +/* Accepting NULL value */ +function test(stdClass $obj = NULL) { + +} + +test(NULL); +test(new stdClass); + +?> +]]> + </programlisting> </example> <para> Type Hints can only be of the <type>object</type> and <type>array</type>

« previous php.doc.cvs (#1512) next »