svn: /phpdoc/en/trunk/language/types/ callable.xml

From: Date: Fri, 06 Nov 2015 18:16:40 +0000
Subject: svn: /phpdoc/en/trunk/language/types/ callable.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-13831@lists.php.net to get a copy of this message
chx Fri, 06 Nov 2015 18:16:40 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=338094 Log: Added a note about private and protected methods to callables Changed paths: U phpdoc/en/trunk/language/types/callable.xml Modified: phpdoc/en/trunk/language/types/callable.xml =================================================================== --- phpdoc/en/trunk/language/types/callable.xml 2015-11-06 13:07:04 UTC (rev 338093) +++ phpdoc/en/trunk/language/types/callable.xml 2015-11-06 18:16:40 UTC (rev 338094) @@ -2,7 +2,7 @@ <!-- $Revision$ --> <sect1 xml:id="language.types.callable"> <title>Callbacks / Callables</title> - + <para> Callbacks can be denoted by <type>callable</type> type hint as of PHP 5.4. This documentation used <type>callback</type> type information for the same @@ -23,8 +23,8 @@ A PHP function is passed by its name as a <type>string</type>. Any built-in or user-defined function can be used, except language constructs such as: <function>array</function>, <function>echo</function>, - <function>empty</function>, <function>eval</function>, - <function>exit</function>, <function>isset</function>, + <function>empty</function>, <function>eval</function>, + <function>exit</function>, <function>isset</function>, <function>list</function>, <function>print</function> or <function>unset</function>. </para> @@ -32,7 +32,8 @@ <para> A method of an instantiated <type>object</type> is passed as an <type>array</type> containing an <type>object</type> at index 0 and the - method name at index 1. + method name at index 1. Accessing protected and private methods from + within a class is allowed. </para> <para> @@ -56,7 +57,7 @@ </title> <programlisting role="php"> <![CDATA[ -<?php +<?php // An example callback function function my_callback_function() { @@ -71,10 +72,10 @@ } // Type 1: Simple callback -call_user_func('my_callback_function'); +call_user_func('my_callback_function'); // Type 2: Static class method call -call_user_func(array('MyClass', 'myCallbackMethod')); +call_user_func(array('MyClass', 'myCallbackMethod')); // Type 3: Object method call $obj = new MyClass(); @@ -128,8 +129,8 @@ // This is our range of numbers $numbers = range(1, 5); -// Use the closure as a callback here to -// double the size of each element in our +// Use the closure as a callback here to +// double the size of each element in our // range $new_numbers = array_map($double, $numbers); @@ -159,7 +160,7 @@ </sect2> </sect1> - + <!-- Keep this comment at the end of the file Local variables: mode: sgml

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