src/Generator.php
private function getDefaultForType(string $type, int $mode = 0) : string
    {
        $isClass = false;
        switch ($type) {
            case 'string': $value = "'blarps'"; break;
            case 'int': $value = '1'; break;
            case 'float': $value = '1.1'; break;
            case 'mixed': $value = "'MIXED'"; break;
            case 'callable': $value = 'function () {}'; break;
            case 'bool': $value = 'true'; break;
            case 'array': $value = '[]'; break;
            default:
                if (class_exists($type)) {
                    $isClass = true;
                }
                $value = $type;
        }
        switch ($mode) {
            case self::AS_INSTANCE:
                if ($isClass) {
                    return "new $value";
                } else {
                    return $value;
                }
            case self::AS_RETURNCHECK:
                if ($isClass) {
                    return "\$result instanceof $value";
                } elseif ($value === 'array') {
                    return "is_array(\$result)";
                } elseif ($value == 'callable') {
                    return "is_callable(\$result)";
                } else {
                    return "\$result === $value";
                }
            default: return $type;
        }
    }
private function getDefaultForType(string $type, int $mode = 0) : string
    {
        $isClass = false;
        switch ($type) {
            case 'string': $value = "'blarps'"; break;
            case 'int': $value = '1'; break;
            case 'float': $value = '1.1'; break;
            case 'mixed': $value = "'MIXED'"; break;
            case 'callable': $value = 'function () {}'; break;
            case 'bool': $value = 'true'; break;
            case 'array': $value = '[]'; break;
            default:
                if (class_exists($type)) {
                    $isClass = true;
                }
                $value = $type;
        }
        switch ($mode) {
            case self::AS_INSTANCE:
                if ($isClass) {
                    return "new $value";
                } else {
                    return $value;
                }
            case self::AS_RETURNCHECK:
                if ($isClass) {
                    return "\$result instanceof $value";
                } elseif ($value === 'array') {
                    return "is_array(\$result)";
                } elseif ($value == 'callable') {
                    return "is_callable(\$result)";
                } else {
                    return "\$result === $value";
                }
            default: return $type;
        }
    }
private function getDefaultForType ( string $ type , int $ mode = 0 ) : string { $ isClass = false ; switch ( $ type ) { case 'string' : $ value = "'blarps'" ; break ; case 'int' : $ value = '1' ; break ; case 'float' : $ value = '1.1' ; break ; case 'mixed' : $ value = "'MIXED'" ; break ; case 'callable' : $ value = 'function () {}' ; break ; case 'bool' : $ value = 'true' ; break ; case 'array' : $ value = '[]' ; break ; default : if ( class_exists ( $ type ) ) { $ isClass = true ; } $ value = $ type ; } switch ( $ mode ) { case self :: AS_INSTANCE : if ( $ isClass ) { return "new $value" ; } else { return $ value ; } case self :: AS_RETURNCHECK : if ( $ isClass ) { return "\$result instanceof $value" ; } elseif ( $ value === 'array' ) { return "is_array(\$result)" ; } elseif ( $ value == 'callable' ) { return "is_callable(\$result)" ; } else { return "\$result === $value" ; } default : return $ type ; } }
Get a string representation of a default value for a given type.

@param string $type
@param int $mode
@return string
Get a string representation of a default value for a given type .