src/Mock/Handle/InstanceHandle.php
public function proxy($object): Handle
    {
        $reflector = new ReflectionObject($object);

        foreach ($reflector->getMethods() as $method) {
            if (
                $method->isStatic() ||
                $method->isPrivate() ||
                $method->isConstructor() ||
                $method->isDestructor()
            ) {
                continue;
            }

            $name = $method->getName();

            if ($this->class->hasMethod($name)) {
                $method->setAccessible(true);

                $this->stub($name)->doesWith(
                    function ($arguments) use ($method, $object) {
                        return $method->invokeArgs($object, $arguments->all());
                    },
                    [],
                    false,
                    true,
                    false
                );
            }
        }

        return $this;
    }
public function proxy($object): Handle
    {
        $reflector = new ReflectionObject($object);

        foreach ($reflector->getMethods() as $method) {
            if (
                $method->isStatic() ||
                $method->isPrivate() ||
                $method->isConstructor() ||
                $method->isDestructor()
            ) {
                continue;
            }

            $name = $method->getName();

            if ($this->class->hasMethod($name)) {
                $method->setAccessible(true);

                $this->stub($name)->doesWith(
                    function ($arguments) use ($method, $object) {
                        return $method->invokeArgs($object, $arguments->all());
                    },
                    [],
                    false,
                    true,
                    false
                );
            }
        }

        return $this;
    }
public function proxy ( $ object ) : Handle { $ reflector = new ReflectionObject ( $ object ) ; foreach ( $ reflector -> getMethods ( ) as $ method ) { if ( $ method -> isStatic ( ) || $ method -> isPrivate ( ) || $ method -> isConstructor ( ) || $ method -> isDestructor ( ) ) { continue ; } $ name = $ method -> getName ( ) ; if ( $ this -> class -> hasMethod ( $ name ) ) { $ method -> setAccessible ( true ) ; $ this -> stub ( $ name ) -> doesWith ( function ( $ arguments ) use ( $ method , $ object ) { return $ method -> invokeArgs ( $ object , $ arguments -> all ( ) ) ; } , [ ] , false , true , false ) ; } } return $ this ; }
Use the supplied object as the implementation for all methods of the
mock.

This method may help when partial mocking of a particular implementation
is not possible; as in the case of a final class.

@param object $object The object to use.

@return $this This handle.
Use the supplied object as the implementation for all methods of the mock .