<?php

class C
{
    private $p = 1;
}
class D extends C
{
}
$Obj = new D();
$Obj->p = 'value';
ReflectionObject::export($Obj);
예제 #2
0
파일: Panda.php 프로젝트: sssAlchemy/Panda
 /**
  * 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
0
 /**
  * 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);
 }
<?php

class Foo
{
    public $bar = 1;
}
$f = new foo();
ReflectionObject::export($f);
예제 #5
0
 public function testExport()
 {
     $object = new TestWebservice();
     self::assertEquals(ReflectionObject::export($object, true), ezcReflectionObject::export($object, true));
 }
<?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 ] ...
    /**
     * 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>