public static function createFromInstance($object) : ReflectionClass
    {
        if (! is_object($object)) {
            throw new InvalidArgumentException('Can only create from an instance of an object');
        }

        $className = get_class($object);

        if (strpos($className, ReflectionClass::ANONYMOUS_CLASS_NAME_PREFIX) === 0) {
            $reflector = new ClassReflector(new AnonymousClassObjectSourceLocator(
                $object,
                (new BetterReflection())->phpParser()
            ));
        } else {
            $reflector = (new BetterReflection())->classReflector();
        }

        return new self($reflector, $reflector->reflect($className), $object);
    }
public static function createFromInstance($object) : ReflectionClass
    {
        if (! is_object($object)) {
            throw new InvalidArgumentException('Can only create from an instance of an object');
        }

        $className = get_class($object);

        if (strpos($className, ReflectionClass::ANONYMOUS_CLASS_NAME_PREFIX) === 0) {
            $reflector = new ClassReflector(new AnonymousClassObjectSourceLocator(
                $object,
                (new BetterReflection())->phpParser()
            ));
        } else {
            $reflector = (new BetterReflection())->classReflector();
        }

        return new self($reflector, $reflector->reflect($className), $object);
    }
public static function createFromInstance ( $ object ) : ReflectionClass { if ( ! is_object ( $ object ) ) { throw new InvalidArgumentException ( 'Can only create from an instance of an object' ) ; } $ className = get_class ( $ object ) ; if ( strpos ( $ className , ReflectionClass :: ANONYMOUS_CLASS_NAME_PREFIX ) === 0 ) { $ reflector = new ClassReflector ( new AnonymousClassObjectSourceLocator ( $ object , ( new BetterReflection ( ) ) -> phpParser ( ) ) ) ; } else { $ reflector = ( new BetterReflection ( ) ) -> classReflector ( ) ; } return new self ( $ reflector , $ reflector -> reflect ( $ className ) , $ object ) ; }
Pass an instance of an object to this method to reflect it

@param object $object

@throws ReflectionException
@throws InvalidArgumentException
@throws IdentifierNotFound

@psalm-suppress DocblockTypeContradiction
Pass an instance of an object to this method to reflect it