本文整理汇总了PHP中ReflectionFunction::export方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionFunction::export方法的具体用法?PHP ReflectionFunction::export怎么用?PHP ReflectionFunction::export使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionFunction
的用法示例。
在下文中一共展示了ReflectionFunction::export方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getClosureDefinition
/**
* Return where a closure has been defined
*
* If for some reason this doesn't work - it'll return the closure instance in the full knowledge
* that it'll probably get dumped as the string "function"
*
* @param Closure $closure
* @return mixed string or Closure
*/
protected function _getClosureDefinition(Closure $closure)
{
$exported = ReflectionFunction::export($closure, true);
preg_match('#@@ (.*) (\\d+) - (\\d+)#', $exported, $match);
if (!$match) {
return $closure;
}
list($m, $path, $start) = $match;
$path = Debugger::trimPath($path);
return "{$path}:{$start}";
}
示例2: g
var_dump($rf->getStaticVariables());
print "\n";
/**
* This is g's doc comment.
*/
function g($a = null, $b = array(1, 2, 3), $c = SOME_CONSTANT)
{
print "In g({$a}, {$b}, {$c})\n";
}
$rg = new ReflectionFunction("g");
print "--- invoke(\"g\") ---\n";
var_dump($rg->invoke("a", "b"));
var_dump($rg->invoke("a", "b"));
print "\n";
print "--- export(\"g\") ---\n";
var_dump($rf->export('g', true));
print "\n";
#===============================================================================
# ReflectionClass.
interface H
{
public function methH();
}
interface I
{
public function methI();
}
interface J
{
public function methJ();
}
示例3: testToString
/**
* Tests export.
*/
public function testToString()
{
$tests = array('lines', 'docComment', 'noComment', 'invoke', 'noParameters', 'parameters', 'reference', 'noReference', 'noNamespace', 'userDefined', 'noClosure');
foreach ($tests as $test) {
$rfl = $this->getFunctionReflection($test);
$this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
$this->assertSame(InternalReflectionFunction::export($this->getFunctionName($test), true), ReflectionFunction::export($this->getBroker(), $this->getFunctionName($test), true));
// Test loading from a string
$rfl = $this->getFunctionReflection($test, true);
$this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
}
$this->assertSame(InternalReflectionFunction::export('strpos', true), ReflectionFunction::export($this->getBroker(), 'strpos', true));
}
示例4: ReflectionFunction
$func = new ReflectionFunction('clamp');
for($i = $min - .5; $i < $max + .5; $i += 0.01) {
echo "<tr><td>";
echo $i,"</td><td>";
var_dump($func->invokeArgs(Array($i, $max, $min)));
echo "</td></tr>";
}
?>
</table>
<h1>Test random_val</h1>
<pre>
<?php
echo ReflectionFunction::export('random_val');
?>
</pre>
<table>
<?
$max = -0.06;
$min = 0.06;
$func = new ReflectionFunction('random_val');
for($i = 0; $i < 50; $i++) {
echo "<tr><td>";
echo $i,"</td><td>";
var_dump($func->invokeArgs(Array($max, $min)));
echo "</td></tr>";
}
示例5: testExport
public function testExport()
{
self::assertEquals(ReflectionFunction::export('m1', true), ezcReflectionFunction::export('m1', true));
self::assertEquals(ReflectionFunction::export('m2', true), ezcReflectionFunction::export('m2', true));
self::assertEquals(ReflectionFunction::export('m3', true), ezcReflectionFunction::export('m3', true));
}
示例6: export
/**
* Exports a ReflectionFunction object.
*
* Returns the output if TRUE is specified for $return, printing it otherwise.
* This is purely a wrapper method, which calls the corresponding method of
* the parent class (ReflectionFunction::export()).
* @param string $function Name of the function
* @param boolean $return
* Whether to return (TRUE) or print (FALSE) the output
* @return mixed
*/
public static function export($function, $return = false)
{
return parent::export($function, $return);
}
示例7: ReflectionFunction
<h1>Test Format Duration</h1>
<pre>
<?php
require_once "utility/date.php";
echo ReflectionFunction::export('format_duration');
?>
</pre>
<table>
<?
$max = 3601;
$min = 1;
$func = new ReflectionFunction('format_duration');
for($i = $min; $i < $max; $i++) {
echo "<tr><td>";
echo $i,"</td><td>";
var_dump($func->invokeArgs(Array($i)));
echo "</td></tr>";
}
?>
</table>
示例8: myFunction
<pre><?php
/**
* @see http://php.net/manual/en/class.reflection.php
* @version PHP 5+
*/
function myFunction($param1 = 'World')
{
return "Hello {$param1}!";
}
var_dump(get_defined_functions()['user']);
var_dump(ReflectionFunction::export('myFunction', true));
echo '<hr />';
class Person
{
public $name;
protected $spouse;
private $password;
/**
* My constructor
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setSpouse(Person $spouse)
{
示例9: test
<?php
/**
hoho
*/
function test($a, $b = 1, $c = "")
{
static $var = 1;
}
$func = new ReflectionFunction("test");
var_dump($func->export("test"));
echo "--getName--\n";
var_dump($func->getName());
echo "--isInternal--\n";
var_dump($func->isInternal());
echo "--isUserDefined--\n";
var_dump($func->isUserDefined());
echo "--getFilename--\n";
var_dump($func->getFilename());
echo "--getStartline--\n";
var_dump($func->getStartline());
echo "--getEndline--\n";
var_dump($func->getEndline());
echo "--getDocComment--\n";
var_dump($func->getDocComment());
echo "--getStaticVariables--\n";
var_dump($func->getStaticVariables());
echo "--invoke--\n";
var_dump($func->invoke(array(1, 2, 3)));
echo "--invokeArgs--\n";
var_dump($func->invokeArgs(array(1, 2, 3)));