svn: /phpdoc/en/trunk/language/ functions.xml

From: Date: Sun, 22 May 2016 20:06:10 +0000
Subject: svn: /phpdoc/en/trunk/language/ functions.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-14144@lists.php.net to get a copy of this message
tpunt Sun, 22 May 2016 20:06:10 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=339217 Log: Resolve doc by #61999 Bug: https://bugs.php.net/61999 (Duplicate) Static lambdas not documented Changed paths: U phpdoc/en/trunk/language/functions.xml Modified: phpdoc/en/trunk/language/functions.xml =================================================================== --- phpdoc/en/trunk/language/functions.xml 2016-05-22 19:47:04 UTC (rev 339216) +++ phpdoc/en/trunk/language/functions.xml 2016-05-22 20:06:10 UTC (rev 339217) @@ -1503,7 +1503,46 @@ </programlisting> </example> - <sect2> + <example> + <title>Automatic binding of <literal>$this</literal></title> + <programlisting role="php"> +<![CDATA[ +<?php + +class Test +{ + public function testing() + { + (function() { + var_dump($this); + })(); + } +} + +(new Test)->testing(); + +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +object(Test)#1 (0) { +} +]]> + </screen> + </example> + + <para> + When declared in the context of a class, the current class is + automatically bound to it, making <literal>$this</literal> available + inside of the function's scope. If this automatic binding of the current + class is not wanted, then + <link linkend="functions.anonymous-functions.static">static anonymous + functions</link> may be used instead. + </para> + + <sect2 xml:id="functions.anonymous-functions.static"> <title>Static anonymous functions</title> <para> As of PHP 5.4, anonymous functions may be declared statically. This

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