src/Stub/EmptyValueFactory.php
public function fromType(ReflectionType $type)
    {
        if ($type->allowsNull()) {
            return null;
        }

        $typeName = strval($type);

        switch (strtolower($typeName)) {
            case 'bool':
                return false;

            case 'int':
                return 0;

            case 'float':
                return .0;

            case 'string':
                return '';

            case 'array':
            case 'iterable':
                return [];

            case 'object':
                // @codeCoverageIgnoreStart
                if (!$this->isObjectTypeSupported) {
                    break;
                }
                // @codeCoverageIgnoreEnd

                // no break

            case 'stdclass':
                return (object) [];

            case 'callable':
                return $this->stubVerifierFactory->create();

            case 'closure':
                return function () {};

            case 'generator':
                $fn = function () { return; yield; };

                return $fn();

            case 'void':
                return null;
        }

        return $this->mockBuilderFactory->create($typeName)->full();
    }
public function fromType(ReflectionType $type)
    {
        if ($type->allowsNull()) {
            return null;
        }

        $typeName = strval($type);

        switch (strtolower($typeName)) {
            case 'bool':
                return false;

            case 'int':
                return 0;

            case 'float':
                return .0;

            case 'string':
                return '';

            case 'array':
            case 'iterable':
                return [];

            case 'object':
                // @codeCoverageIgnoreStart
                if (!$this->isObjectTypeSupported) {
                    break;
                }
                // @codeCoverageIgnoreEnd

                // no break

            case 'stdclass':
                return (object) [];

            case 'callable':
                return $this->stubVerifierFactory->create();

            case 'closure':
                return function () {};

            case 'generator':
                $fn = function () { return; yield; };

                return $fn();

            case 'void':
                return null;
        }

        return $this->mockBuilderFactory->create($typeName)->full();
    }
public function fromType ( ReflectionType $ type ) { if ( $ type -> allowsNull ( ) ) { return null ; } $ typeName = strval ( $ type ) ; switch ( strtolower ( $ typeName ) ) { case 'bool' : return false ; case 'int' : return 0 ; case 'float' : return .0 ; case 'string' : return '' ; case 'array' : case 'iterable' : return [ ] ; case 'object' : // @codeCoverageIgnoreStart if ( ! $ this -> isObjectTypeSupported ) { break ; } // @codeCoverageIgnoreEnd // no break case 'stdclass' : return ( object ) [ ] ; case 'callable' : return $ this -> stubVerifierFactory -> create ( ) ; case 'closure' : return function ( ) { } ; case 'generator' : $ fn = function ( ) { return ; yield ; } ; return $ fn ( ) ; case 'void' : return null ; } return $ this -> mockBuilderFactory -> create ( $ typeName ) -> full ( ) ; }
Create a value of the supplied type.

@param ReflectionType $type The type.

@return mixed A value of the supplied type.
Create a value of the supplied type .