Beispiel #1
0
<?php

class A
{
    private static $a = 0;
    protected static $b = 1;
    public static $c = 2;
    private function f()
    {
    }
    private static function sf()
    {
    }
}
class C extends A
{
}
ReflectionClass::export("C");
Beispiel #2
0
<?php

class Base
{
    public final function __construct()
    {
    }
}
class Works extends Base
{
}
class Extended extends Base
{
    public function Extended()
    {
    }
}
ReflectionClass::export('Extended');
#!/usr/bin/env php
<?php 
class A
{
    public $field = 'value';
}
$a = new A();
$reflection = new ReflectionClass('A');
// echo $reflection;
echo ReflectionClass::export('A', true);
<?php

ReflectionClass::export('Countable');
Beispiel #5
0
 /**
  * Exports a ReflectionClass 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 (ReflectionClass::export()).
  * @param ReflectionClass|string $class
  *        ReflectionClass object or name of the class
  * @param boolean $return
  *        Whether to return (TRUE) or print (FALSE) the output
  * @return mixed
  */
 public static function export($class, $return = false)
 {
     return parent::export($class, $return);
 }
 public function testExport()
 {
     self::assertEquals(ReflectionClass::export('TestWebservice', true), ezcReflectionClass::export('TestWebservice', true));
 }
Beispiel #7
0
    public function methJ()
    {
    }
    public function methK()
    {
    }
    private function methB()
    {
    }
}
class C
{
}
$rb = new ReflectionClass("B");
print "--- export() ---\n";
var_dump($rb->export('B', true));
print "\n";
print "--- getConstant() ---\n";
var_dump($rb->getConstant('C0'));
var_dump($rb->getConstant('C1'));
print "\n";
print "--- getConstants() ---\n";
var_dump($rb->getConstants());
print "\n";
print "--- getConstructor() ---\n";
var_dump($rb->getConstructor());
print "\n";
print "--- getDocComment() ---\n";
var_dump($rb->getDocComment());
print "\n";
print "--- getStartLine() ---\n";
 /**
  * Tests export.
  */
 public function testToString()
 {
     $tests = array('lines', 'docComment', 'noDocComment', 'constants', 'noConstants', 'properties', 'noProperties', 'doubleProperties', 'publicConstructor', 'privateConstructor', 'publicClone', 'privateClone', 'methods', 'noMethods', 'instances', 'abstract', 'abstractImplicit', 'noAbstract', 'final', 'noFinal', 'interface', 'noInterface', 'interfaces', 'noInterfaces', 'iterator', 'noIterator', 'parent', 'noParent', 'userDefined', 'noNamespace');
     if (PHP_VERSION_ID >= 50400) {
         // Test traits only on PHP >= 5.4
         $tests[] = 'traits';
     }
     foreach ($tests as $test) {
         $rfl = $this->getClassReflection($test);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
         $this->assertSame(InternalReflectionClass::export($this->getClassName($test), true), ReflectionClass::export($this->getBroker(), $this->getClassName($test), true));
         // Test loading from a string
         $rfl = $this->getClassReflection($test, true);
         $this->assertSame($rfl->internal->__toString(), $rfl->token->__toString());
     }
     $this->assertSame(InternalReflectionClass::export('ReflectionClass', true), ReflectionClass::export($this->getBroker(), 'ReflectionClass', true));
     $this->assertSame(InternalReflectionClass::export(new InternalReflectionClass('ReflectionClass'), true), ReflectionClass::export($this->getBroker(), new InternalReflectionClass('ReflectionClass'), 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 ] ...
Beispiel #10
0
 public function __construct()
 {
     parent::create(func_get_args());
     $this->refelection = ReflectionClass::export('Apple', true);
 }
Beispiel #11
0
<?php

class foo
{
    public function foo()
    {
    }
}
class bar extends foo
{
}
ReflectionClass::export("bar");
Beispiel #12
0
<?php

interface a
{
    function foo();
    function bar();
}
interface b
{
    function foo();
}
abstract class c
{
    function bar()
    {
    }
}
class x extends c implements a, b
{
    function foo()
    {
    }
}
ReflectionClass::export('x');