[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-doc-cvs
Subject:    [DOC-CVS] cvs: phpdoc /en/language/oop5 reflection.xml  /en/reference/funchand/functions call-user-f
From:       "Felipe Pena" <felipe () php ! net>
Date:       2008-08-29 12:47:26
Message-ID: cvsfelipe1220014046 () cvsserver
[Download RAW message or body]

felipe		Fri Aug 29 12:47:26 2008 UTC

  Modified files:              
    /phpdoc/en/language/oop5	reflection.xml 
    /phpdoc/en/reference/funchand/functions	call-user-func-array.xml 
                                           	call-user-func.xml 
  Log:
  - Added new examples related to PHP 5.3
  
http://cvs.php.net/viewvc.cgi/phpdoc/en/language/oop5/reflection.xml?r1=1.36&r2=1.37&diff_format=u
                
Index: phpdoc/en/language/oop5/reflection.xml
diff -u phpdoc/en/language/oop5/reflection.xml:1.36 \
                phpdoc/en/language/oop5/reflection.xml:1.37
--- phpdoc/en/language/oop5/reflection.xml:1.36	Wed Aug  6 21:50:59 2008
+++ phpdoc/en/language/oop5/reflection.xml	Fri Aug 29 12:47:25 2008
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.36 $ -->
+<!-- $Revision: 1.37 $ -->
  <sect1 xml:id="language.oop5.reflection" xmlns="http://docbook.org/ns/docbook">
   <title>Reflection</title>
   <sect2 xml:id="language.oop5.reflection.toc">
@@ -176,6 +176,7 @@
     public string getName()
     public bool isInternal()
     public bool isDisabled()
+    public mixed getClosure() /* As of PHP 5.3.0 */
     public bool isUserDefined()
     public string getFileName()
     public int getStartLine()
@@ -578,6 +579,7 @@
     public bool isConstructor()
     public bool isDestructor()
     public int getModifiers()
+    public mixed getClosure() /* As of PHP 5.3.0 */
     public ReflectionClass getDeclaringClass()
 
     // Inherited from ReflectionFunctionAbstract
@@ -667,6 +669,27 @@
 ]]>
     </programlisting>
    </example>
+   <example>
+    <title>Getting closure using <classname>ReflectionMethod</classname> \
class</title> +    <programlisting role='php'>
+<![CDATA[
+<?php
+
+class Example {
+    static function printer () {
+        echo "Hello World!\n";
+    }
+}
+ 
+$class = new ReflectionClass('Example');
+$method = $class->getMethod('printer');
+$closure = $method->getClosure(); /* As of PHP 5.3.0 */
+$closure(); // Hello World!
+
+?>
+]]>
+    </programlisting>
+   </example>
    <note>
     <simpara>
      Trying to invoke private, protected or abstract methods will result
@@ -771,6 +794,32 @@
 ]]>
     </programlisting>
    </example>
+   <example>
+    <title>Getting value from private and protected properties using \
<classname>ReflectionProperty</classname> class</title> +    <programlisting \
role='php'> +<![CDATA[
+<?php
+
+class Foo {
+    public $x = 1;
+    protected $y = 2;
+    private $z = 3;
+}
+
+$obj = new Foo;
+
+$prop = new ReflectionProperty('Foo', 'y');
+$prop->setAccessible(true); /* As of PHP 5.3.0 */
+var_dump($prop->getValue($obj)); // int(2)
+
+$prop = new ReflectionProperty('Foo', 'z');
+$prop->setAccessible(true); /* As of PHP 5.30 */
+var_dump($prop->getValue($obj)); // int(2)
+
+?>
+]]>
+    </programlisting>
+   </example>
    <note>
     <simpara>
      Trying to get or set private or protected class property's values
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/funchand/functions/call-user-func-array.xml?r1=1.19&r2=1.20&diff_format=u
                
Index: phpdoc/en/reference/funchand/functions/call-user-func-array.xml
diff -u phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.19 \
                phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.20
--- phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.19	Wed Jan 23 \
                19:06:10 2008
+++ phpdoc/en/reference/funchand/functions/call-user-func-array.xml	Fri Aug 29 \
12:47:25 2008 @@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.19 $ -->
+<!-- $Revision: 1.20 $ -->
 <refentry xml:id="function.call-user-func-array" \
xmlns="http://docbook.org/ns/docbook">  <refnamediv>
   <refname>call_user_func_array</refname>
@@ -105,6 +105,23 @@
 ]]>
     </programlisting>
    </example>
+   <example>
+    <title>Using lambda function</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+
+$func = function($arg1, $arg2) {
+    return $arg1 * $arg2;
+};
+
+var_dump(call_user_func($func, 2, 4)); /* As of PHP 5.3.0 */
+// int(8)
+
+?>
+]]>
+    </programlisting>
+   </example>
   </para>
  </refsect1>
 
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/funchand/functions/call-user-func.xml?r1=1.19&r2=1.20&diff_format=u
                
Index: phpdoc/en/reference/funchand/functions/call-user-func.xml
diff -u phpdoc/en/reference/funchand/functions/call-user-func.xml:1.19 \
                phpdoc/en/reference/funchand/functions/call-user-func.xml:1.20
--- phpdoc/en/reference/funchand/functions/call-user-func.xml:1.19	Fri Jan 25 \
                00:02:31 2008
+++ phpdoc/en/reference/funchand/functions/call-user-func.xml	Fri Aug 29 12:47:25 \
2008 @@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.19 $ -->
+<!-- $Revision: 1.20 $ -->
 <refentry xml:id="function.call-user-func" xmlns="http://docbook.org/ns/docbook">
  <refnamediv>
   <refname>call_user_func</refname>
@@ -141,6 +141,19 @@
 ]]>
     </programlisting>
    </example>
+   <example>
+    <title>Using lambda function</title>
+    <programlisting role="php">
+<![CDATA[
+<?php
+
+call_user_func(function($arg) { print "[$arg]\n"; }, 'test'); /* As of PHP 5.3.0 */
+// [test]
+
+?>
+]]>
+    </programlisting>
+   </example>
   </para>
  </refsect1>
 



-- 
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic