/** * Creates a new class instance without using a constructor. * * @return object * @throws \TokenReflection\Exception\RuntimeException If the class inherits from an internal class. */ public function newInstanceWithoutConstructor() { if (!class_exists($this->name, true)) { throw new Exception\RuntimeException('Could not create an instance; class does not exist.', Exception\RuntimeException::DOES_NOT_EXIST, $this); } $reflection = new \TokenReflection\Php\ReflectionClass($this->name, $this->getBroker()); return $reflection->newInstanceWithoutConstructor(); }
/** * Tests an exception thrown when it is impossible to create an instance without invoking the constructor. * * @expectedException \TokenReflection\Exception\RuntimeException */ public function testInternalClassNewInstanceWithoutConstructor2() { $reflection = new Php\ReflectionClass('TokenReflection\\Exception\\RuntimeException', $this->getBroker()); $reflection->newInstanceWithoutConstructor(); }