Gets/sets the schema instance.

@param  object schema The schema instance to set or none to get it.
@return mixed         The schema instance on get or `$this` otherwise.
428393
public function schema($schema = null)
    {
        if (func_num_args()) {
            $this->_schema = $schema;
            return $this;
        }
        if (!$this->_schema) {
            $this->_schema = static::definition();
        }
        return $this->_schema;
    }
1304137
function GetSchema()
	{
		$this->Connection->Connect();
		
		$schema = new DBSchema($this);
		
		$this->Connection->Disconnect();
		
		return $schema;
	}
280141
public function create(\stdClass $definition = null): Schema
    {
        if (!$definition) {
            $definition       = (object)[];
            $definition->type = Schema::TYPE_ANY;
        }
        if (!isset($definition->type)) {
            $definition = clone $definition;
            if (isset($definition->allOf)) {
                foreach ($definition->allOf as $nested) {
                    if (isset($nested->type)) {
                        $definition->type = $nested->type;
                    }
                }
            }
            if (!isset($definition->type)) {
                $definition->type = Schema::TYPE_STRING;
            }
        }
        if (isset($definition->properties)) {
            $definition->type = 'object';
        }

        $index = array_search($definition, $this->definitions);

        if (false === $index) {
            if ($definition->type == Schema::TYPE_OBJECT) {
                $propertySchemas = (object)[];

                if (isset($definition->properties)) {
                    foreach ($definition->properties as $attributeName => $propertyDefinition) {
                        $propertySchemas->$attributeName = $this->create($propertyDefinition);
                    }
                }

                if (isset($definition->allOf)) {
                    foreach ($definition->allOf as $nested) {
                        if (isset($nested->properties)) {
                            foreach ($nested->properties as $attributeName => $propertyDefinition) {
                                $propertySchemas->$attributeName = $this->create($propertyDefinition);
                            }
                        }
                    }
                    unset($definition->type);
                }

                $schema = new ObjectSchema($definition, $propertySchemas);
            } elseif ($definition->type == Schema::TYPE_ARRAY) {
                $itemsSchema = isset($definition->items) ? $this->create($definition->items) : null;
                $schema      = new ArraySchema($definition, $itemsSchema);
            } elseif ($definition->type == Schema::TYPE_ANY) {
                $schema = new AnySchema($definition);
            } else {
                $schema = new ScalarSchema($definition);
            }

            $this->definitions[] = $definition;
            $this->schemas[]     = $schema;

            return $schema;
        }

        return $this->schemas[$index];
    }
470888
public static function getSchema()
    {
        $attribute = 'schema';

        if (!static::hasClassAttribute($attribute)) {
            $fields = static::getSchemaFieldsValues();
            $parser = static::getDatabase()->getParser();
            $schema = [];

            if ($fields && count($fields) > 0) {
                foreach ($fields as $name => $value) {
                    $schema[$name] = $value;
                }
            }

            $parser->parseTable($schema, $errors, static::getNamespace());

            if ($errors) {
                static::error('class', $errors[0]);
            }

            static::setClassAttribute($attribute, $schema);
        }

        return static::getClassAttribute($attribute);
    }
1346517
public function toObject()
    {
        $output = array('cols' => array(), 'rows' => array());

        // Column Definitions
        foreach ($this->columns as $inputColumn) {
            $output['cols'][] = $inputColumn->toDefinitionObject();
        }

        // Rows
        foreach ($this->rows as $inputRow) {
            $row = array('c' => array());
            foreach ($inputRow->getCells() as $i => $cell) {
                if (null === $cell) {
                    $row['c'][] = null;
                } else {
                    $colType = $this->columns[$i]->getType();
                    $outputCell = array('v' => $colType->convertToCellValue($cell));
                    $stringVal = $colType->convertToStringVersion($cell);
                    if ($stringVal != null) {
                        $outputCell['f'] = trim($stringVal);
                    }
                    $row['c'][] = (object) $outputCell;
                }
            }

            $output['rows'][] = (object) $row;
        }

        return (object) $output;
    }
1306511
public function schema($schema = null)
    {
        if (func_num_args() === 0) {
            return $this->collection->schema();
        }

        return $this->collection->schema($schema);
    }
144459
public function getSchema()
    {
        $schema = new Schema(['adapter' => $this->_adapter]);
        $tables = $this->getTables();
        foreach ($tables as $tableName) {
            $schema->addTable($this->getTable($tableName));
        }

        return $schema;
    }
1000226
public function getSchema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = new Schema($this);
        }

        return $this->schema;
    }
380588
public function getSchema()
    {
        if ($this->schema !== null) {
            return $this->schema;
        }
        $response = $this->_sendRawGet($this->_constructUrl(self::SCHEMA_SERVLET));

        $this->schema = $this->schemaParser->parseJson($response->getRawResponse());
        return $this->schema;
    }
378624
protected static function getDbKey($schema)
    {
        static $keys = [];
        
        if ($schema === null) {
            return null;
        }
        if (!$keys) {
            foreach (self::getDbConfig() as $key => $conf) {
                $keys[$conf['database']] = $key;
            }
        }
        return isset($keys[$schema]) ? $keys[$schema] : null;
    }
452522
public function visitSchema(Schema $schema)
    {
        return new Schema(
            $this->transformConstraintArray($schema->constraints()),
            $schema->defaultValue(),
            $schema->title(),
            $schema->description()
        );
    }
625452
public function schema($schema = null)
    {
        $this->schema = empty($schema) ? null : $schema;

        return $this->schema;
    }
1192700
public static function make($class)
    {
        if (!array_key_exists(
            'class',
            $class
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "'class' field has not been found for defining 'object' schema entry",
                400
            );
        }

        if (!class_exists($class['class'])) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "class {$class['class']} has not been defined",
                400
            );
        }

        if (!method_exists(
            $class['class'],
            'make'
        )
        ) {
            throw new SchemaException(
                __CLASS__,
                __METHOD__,
                "a 'class' defined in the 'object' schema entry must have a make method",
                400
            );
        }

        $instance = new static(
            $class['class']
        );

        if (array_key_exists(
            'relationship',
            $class
        )) {
            $instance->setRelationship(Relationship::make($class['relationship']));
        }

        return $instance;
    }
332714
function convertObject (schema, self) {
  var keys = Object.keys(schema);
  var ret = {};

  for (var i = 0; i < keys.length; ++i) {
    var key = keys[i];
    ret[key] = convertElement(schema[key], self);
  }

  return ret;
}
1157211
function instance(schema, defaults, options) {
  const name = 'instance'
  const type = `instance<${schema.name}>`
  const validate = (value = resolveDefaults(defaults)) => {
    return value instanceof schema
      ? [undefined, value]
      : [{ data: value, path: [], value, type }]
  }

  return new Kind(name, type, validate)
}
1374500
public static function definition($schema = null)
    {
        if (func_num_args()) {
            if (is_string($schema)) {
                static::$_definition = $schema;
            } elseif($schema) {
                static::$_definitions[static::class] = $schema;
            } else {
                unset(static::$_definitions[static::class]);
            }
            return;
        }
        $self = static::class;
        if (isset(static::$_definitions[$self])) {
            return static::$_definitions[$self];
        }
        $conventions = static::conventions();
        $config = [
            'connection'  => static::$_connection,
            'conventions' => $conventions,
            'class'       => $self,
            'locked'      => Document::class !== $self
        ];
        $config += ['source' => $conventions->apply('source', $self)];

        $class = static::$_definition;
        $schema = static::$_definitions[$self] = new $class($config);
        static::_define($schema);
        return $schema;
    }
205165
public function getSchema()
    {
        $schema = $this->onikiri()->getTableSchema($this->getTableName(), $this->getDatabase());
        return $schema;
    }