assertInstanceOf(\ReflectionFunction::class, $refl); $refl = Mirror::get(self::class); $this->assertInstanceOf(\ReflectionClass::class, $refl); $refl = Mirror::get($this); $this->assertInstanceOf(\ReflectionObject::class, $refl); $refl = Mirror::get($this, 'FOO'); if (\version_compare(\PHP_VERSION, '7.1.0', '>=')) { $this->assertInstanceOf(\ReflectionClassConstant::class, $refl); } else { $this->assertInstanceOf(ReflectionClassConstant::class, $refl); } $refl = Mirror::get('PHP_VERSION'); $this->assertInstanceOf(ReflectionConstant_::class, $refl); $refl = Mirror::get($this, 'bar'); $this->assertInstanceOf(\ReflectionProperty::class, $refl); $refl = Mirror::get($this, 'baz'); $this->assertInstanceOf(\ReflectionProperty::class, $refl); $refl = Mirror::get($this, 'aPublicMethod'); $this->assertInstanceOf(\ReflectionMethod::class, $refl); $refl = Mirror::get($this, 'baz', Mirror::STATIC_PROPERTY); $this->assertInstanceOf(\ReflectionProperty::class, $refl); $refl = Mirror::get('Psy\\Test\\Util'); $this->assertInstanceOf(ReflectionNamespace::class, $refl); // This is both a namespace and a class, so let's make sure it gets the class: $refl = Mirror::get('Psy\\CodeCleaner'); $this->assertInstanceOf(\ReflectionClass::class, $refl); } public function testMirrorThrowsExceptions() { $this->expectException(\RuntimeException::class); Mirror::get($this, 'notAMethod'); $this->fail(); } /** * @dataProvider invalidArguments */ public function testMirrorThrowsInvalidArgumentExceptions($value) { $this->expectException(\InvalidArgumentException::class); Mirror::get($value); $this->fail(); } public function invalidArguments() { return [ ['not_a_function_or_class'], [[]], [1], ]; } }