class Foo {} $foo = new Foo(); $reflection = new ReflectionObject($foo); echo $reflection->getName(); // outputs "Foo"
interface Bar {} class Baz implements Bar {} $baz = new Baz(); $reflection = new ReflectionObject($baz); echo $reflection->getName(); // outputs "Baz"In both examples, we create an instance of a class and pass it to ReflectionObject to create a reflection object. We then call getName() on the reflection object to get the fully qualified class name. As for determining the package library, it is not possible to know that from the use of ReflectionObject alone. However, it is likely that ReflectionObject is being used in conjunction with other libraries or frameworks in order to inspect and manipulate objects at runtime.