本文整理汇总了PHP中ReflectionObject::export方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::export方法的具体用法?PHP ReflectionObject::export怎么用?PHP ReflectionObject::export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::export方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: D
<?php
class C
{
private $p = 1;
}
class D extends C
{
}
$Obj = new D();
$Obj->p = 'value';
ReflectionObject::export($Obj);
示例2: __addReflectInfo
/**
* Add reflection info
*
* @param array $trace
*
* @return string
*/
private static function __addReflectInfo($trace)
{
$refLog = array();
$i = 0;
foreach ($trace as $row) {
if (isset($row['class']) && isset($row['function'])) {
if (isset($row['object'])) {
$refLog[$i]['export'] = ReflectionObject::export($row['object'], true);
}
$ref = new ReflectionMethod($row['class'], $row['function']);
$refLog[$i]['file'] = $ref->getFileName();
$refLog[$i]['doc'] = $ref->getDocComment();
$refLog[$i]['start'] = $ref->getStartLine();
$refLog[$i]['end'] = $ref->getEndLine();
}
$i++;
}
return $refLog;
}
示例3: export
/**
* Exports a ReflectionObject instance.
*
* 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 (ReflectionObject::export()).
* @param ReflectionObject $object ReflectionClass instance of the object
* @param boolean $return
* Whether to return (TRUE) or print (FALSE) the output
* @return mixed
*/
public static function export($object, $return = false)
{
return parent::export($object, $return);
}
示例4: foo
<?php
class Foo
{
public $bar = 1;
}
$f = new foo();
ReflectionObject::export($f);
示例5: testExport
public function testExport()
{
$object = new TestWebservice();
self::assertEquals(ReflectionObject::export($object, true), ezcReflectionObject::export($object, true));
}
示例6: Func
<?php
class Foo
{
public $prop;
function Func($name)
{
echo "Hello {$name}";
}
}
ReflectionClass::export('Foo');
//output: Class [ class Foo ] { @@ /home/cg/root/main.php 3-10 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $prop ] } - Methods [1] { Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } } } }
ReflectionObject::export(new Foo());
// output: Object of class [ class Foo ] { @@ /home/cg/root/main.php 3-10 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [1] { Property [ public $prop ] } - Dynamic properties [0] { } - Methods [1] { Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } } } }
ReflectionMethod::export('Foo', 'func');
// output: Method [ public method Func ] { @@ /home/cg/root/main.php 7 - 9 - Parameters [1] { Parameter #0 [ $name ] } }
ReflectionProperty::export('Foo', 'prop');
//output: Property [ public $prop ]
ReflectionExtension::export('standard');
//output: Extension [ extension #15 standard version 5.5.18 ] ...
示例7: __construct
/**
* My constructor
* @param string $name
*/
public function __construct($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setSpouse(Person $spouse)
{
$this->spouse = $spouse;
}
private function setPassword($password)
{
$this->password = $password;
}
}
$reflectionClass = new ReflectionClass('Person');
echo Reflection::export($reflectionClass, true);
$firstMethod = $reflectionClass->getMethods()[0];
$firstProperty = $reflectionClass->getProperties()[0];
var_dump($reflectionClass->getMethods(), $reflectionClass->hasMethod('getName'), $firstMethod->getDocComment(), $firstMethod->getParameters(), $reflectionClass->getProperties(), $firstProperty->isPublic());
echo '<hr />';
ReflectionObject::export(new Person('Reflection'));
?>
</pre>