-
Notifications
You must be signed in to change notification settings - Fork 820
Add stub/document ReflectionFunctionAbstract::getClosureCalledClass() #4043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bc1fa9a
Add stub for ReflectionFunctionAbstract::getClosureCalledClass()
Girgias d2107ee
Attempt to document methods
Girgias 31890e4
whitespace
Girgias 942b421
Fix XIncludes
Girgias f371eef
Suggestions from Arnaud
Girgias 814e498
Improve examples
Girgias 6c0c6d5
Stop referring to $this
Girgias 6227b74
whitespace
Girgias File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
reference/reflection/reflectionfunctionabstract/getclosurecalledclass.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<refentry xml:id="reflectionfunctionabstract.getclosurecalledclass" xmlns="http://docbook.org/ns/docbook"> | ||
<refnamediv> | ||
<refname>ReflectionFunctionAbstract::getClosureCalledClass</refname> | ||
<refpurpose>Returns the class corresponding to static:: inside a closure</refpurpose> | ||
</refnamediv> | ||
|
||
<refsect1 role="description"> | ||
&reftitle.description; | ||
<methodsynopsis role="ReflectionFunctionAbstract"> | ||
<modifier>public</modifier> <type class="union"><type>ReflectionClass</type><type>null</type></type><methodname>ReflectionFunctionAbstract::getClosureCalledClass</methodname> | ||
<void/> | ||
</methodsynopsis> | ||
<simpara> | ||
Returns the class as a <classname>ReflectionClass</classname> that | ||
corresponds to <literal>static::</literal> inside the | ||
<classname>Closure</classname>. | ||
</simpara> | ||
</refsect1> | ||
|
||
<refsect1 role="parameters"> | ||
&reftitle.parameters; | ||
&no.function.parameters; | ||
</refsect1> | ||
|
||
<refsect1 role="returnvalues"> | ||
&reftitle.returnvalues; | ||
<simpara> | ||
Returns a <classname>ReflectionClass</classname> corresponding to the class | ||
represented by <literal>static::</literal> in the <classname>Closure</classname>. | ||
If the function is not a closure or if it has global scope &null; | ||
is returned instead. | ||
</simpara> | ||
</refsect1> | ||
|
||
<refsect1 role="examples"> | ||
&reftitle.examples; | ||
<example> | ||
<title> | ||
Example showcasing difference between | ||
<methodname>ReflectionFunctionAbstract::getClosureCalledClass</methodname>, | ||
<methodname>ReflectionFunctionAbstract::getClosureScopeClass</methodname>, | ||
and <methodname>ReflectionFunctionAbstract::getClosureThis</methodname> | ||
with an instance method | ||
</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
|
||
class A { | ||
public function getClosure() { | ||
var_dump(self::class, static::class); | ||
return function () { | ||
|
||
}; | ||
} | ||
} | ||
|
||
class B extends A { | ||
|
||
} | ||
|
||
$b = new B(); | ||
$c = $b->getClosure(); | ||
$r = new ReflectionFunction($c); | ||
var_dump($r->getClosureThis()); // $this === $b | ||
var_dump($r->getClosureScopeClass()); // self::class | ||
var_dump($r->getClosureCalledClass()); // static::class | ||
|
||
?> | ||
]]> | ||
</programlisting> | ||
&example.outputs; | ||
<screen> | ||
<![CDATA[ | ||
string(1) "A" | ||
string(1) "B" | ||
object(B)#1 (0) { | ||
} | ||
object(ReflectionClass)#4 (1) { | ||
["name"]=> | ||
string(1) "A" | ||
} | ||
object(ReflectionClass)#4 (1) { | ||
["name"]=> | ||
string(1) "B" | ||
} | ||
]]> | ||
</screen> | ||
</example> | ||
<example> | ||
<title> | ||
Example showcasing difference between | ||
<methodname>ReflectionFunctionAbstract::getClosureCalledClass</methodname>, | ||
<methodname>ReflectionFunctionAbstract::getClosureScopeClass</methodname>, | ||
and <methodname>ReflectionFunctionAbstract::getClosureThis</methodname> | ||
with a static method | ||
</title> | ||
<programlisting role="php"> | ||
<![CDATA[ | ||
<?php | ||
|
||
class A { | ||
public function getClosure() { | ||
var_dump(self::class, static::class); | ||
return static function () { | ||
|
||
}; | ||
} | ||
} | ||
|
||
class B extends A { | ||
|
||
} | ||
|
||
$b = new B(); | ||
$c = $b->getClosure(); | ||
$r = new ReflectionFunction($c); | ||
var_dump($r->getClosureThis()); // NULL | ||
var_dump($r->getClosureScopeClass()); // self::class | ||
var_dump($r->getClosureCalledClass()); // static::class | ||
|
||
?> | ||
]]> | ||
</programlisting> | ||
&example.outputs; | ||
<screen> | ||
<![CDATA[ | ||
string(1) "A" | ||
string(1) "B" | ||
NULL | ||
object(ReflectionClass)#4 (1) { | ||
["name"]=> | ||
string(1) "A" | ||
} | ||
object(ReflectionClass)#4 (1) { | ||
["name"]=> | ||
string(1) "B" | ||
} | ||
|
||
]]> | ||
</screen> | ||
</example> | ||
</refsect1> | ||
|
||
<refsect1 role="seealso"> | ||
&reftitle.seealso; | ||
<simplelist> | ||
<member><methodname>ReflectionFunctionAbstract::getClosureScopeClass</methodname></member> | ||
<member><methodname>ReflectionFunctionAbstract::getClosureThis</methodname></member> | ||
<member><xref linkend="language.oop5.late-static-bindings" /></member> | ||
</simplelist> | ||
</refsect1> | ||
|
||
</refentry> | ||
<!-- Keep this comment at the end of the file | ||
Local variables: | ||
mode: sgml | ||
sgml-omittag:t | ||
sgml-shorttag:t | ||
sgml-minimize-attributes:nil | ||
sgml-always-quote-attributes:t | ||
sgml-indent-step:1 | ||
sgml-indent-data:t | ||
indent-tabs-mode:nil | ||
sgml-parent-document:nil | ||
sgml-default-dtd-file:"~/.phpdoc/manual.ced" | ||
sgml-exposed-tags:nil | ||
sgml-local-catalogs:nil | ||
sgml-local-ecat-files:nil | ||
End: | ||
vim600: syn=xml fen fdm=syntax fdl=2 si | ||
vim: et tw=78 syn=sgml | ||
vi: ts=1 sw=1 | ||
--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is funky. This would also have been an option for the curl multi docs.