Inheritance: extends ReflectionClass
 public function testCannotClone()
 {
     $classInfo = ReflectionObject::createFromInstance(new \stdClass());
     $this->expectException(Uncloneable::class);
     $unused = clone $classInfo;
 }
Exemplo n.º 2
0
 /**
  * Create a ReflectionClass from an instance, using default reflectors etc.
  *
  * This is simply a helper method that calls ReflectionObject::createFromInstance().
  *
  * @see ReflectionObject::createFromInstance
  * @param object $instance
  * @return ReflectionClass
  */
 public static function createFromInstance($instance)
 {
     if (gettype($instance) !== 'object') {
         throw new \InvalidArgumentException('Instance must be an instance of an object');
     }
     return ReflectionObject::createFromInstance($instance);
 }
 /**
  * {@inheritDoc}
  */
 public function getShortName()
 {
     return $this->betterReflectionObject->getShortName();
 }
    public function testReflectionObjectExportMatchesExpectation()
    {
        $foo = new ClassForHinting();
        $foo->bar = 'huzzah';
        $expectedExport = <<<'BLAH'
Object of class [ <user> class BetterReflectionTest\Fixture\ClassForHinting ] {
  @@ %s

  - Constants [0] {
  }

  - Static properties [0] {
  }

  - Static methods [0] {
  }

  - Properties [1] {
    Property [ <default> public $someProperty ]
  }

  - Dynamic properties [1] {
    Property [ <dynamic> public $bar ]
  }

  - Methods [0] {
  }
}
BLAH;
        $actualExport = ReflectionObject::export($foo);
        $this->assertStringMatchesFormat($expectedExport, $actualExport);
    }