@param \stdClass $definition

@return Schema
166956
protected function createParameterSchema(\stdClass $definition): Schema
    {
        // Remove non-JSON-Schema properties
        $schemaDefinition     = clone $definition;
        $swaggerPropertyNames = [
            'name',
            'in',
            'description',
            'required',
            'allowEmptyValue',
            'collectionFormat',
        ];
        foreach ($swaggerPropertyNames as $propertyName) {
            if (property_exists($schemaDefinition, $propertyName)) {
                unset($schemaDefinition->$propertyName);
            }
        }

        return $this->schemaFactory->create($schemaDefinition);
    }
1334732
public function create(string $uri, \stdClass $definition): Description
    {
        switch ($this->type) {
            case self::BUILDER_OPEN_API:
                return (
                new OpenApiBuilder(
                    new Document(
                        $uri,
                        (new RefResolver($definition, $uri))->resolve()
                    )
                )
                )->build();
            case self::BUILDER_RAML:
                return (
                new RamlBuilder(
                    new Document(
                        $uri,
                        $definition
                    )
                )
                )->build();
            default:
                throw new \InvalidArgumentException();
        }
    }
187388
public function generate(Schema $schema, string $className, Context $context)
    {
        foreach ($schema->getClasses() as $class) {
            $properties = [];
            $methods = [];

            foreach ($class->getProperties() as $property) {
                $properties[] = $this->createProperty($property, $schema->getNamespace() . '\\Model');
                $methods[] = $this->createGetter($property, $schema->getNamespace() . '\\Model');
                $methods[] = $this->createSetter($property, $schema->getNamespace() . '\\Model');
            }

            $model = $this->createModel(
                $class->getName(),
                $properties,
                $methods,
                \count($class->getExtensionsType()) > 0
            );

            $namespace = new Stmt\Namespace_(new Name($schema->getNamespace() . '\\Model'), [$model]);

            $schema->addFile(new File($schema->getDirectory() . '/Model/' . $class->getName() . '.php', $namespace, self::FILE_TYPE_MODEL));
        }
    }
261426
protected function createParameter(string $name, string $in, \stdClass $definition)
    {
        $schema   = $this->createParameterSchema($definition);
        $required = isset($definition->required) && $definition->required;

        return new Parameter($name, $required, $schema, $in);
    }
492969
public function bind(string $name, $definition)
    {
        $this->definitions[$name] = new Singleton($name, $definition);
        return $this;
    }
1053634
public function arrayToClassElement($definition)
    {
        $class = new Classes();
        if (isset($definition['docblock'])) {
            $docblock = $this->arrayToDocblockElement($definition['docblock']);
            $class->setDocbloc($docblock);
        }
        if (isset($definition['namespace'])) {
            $class->setNamespace($definition['namespace']);
        }
        if (isset($definition['name'])) {
            $class->setName($definition['name']);
        }
        if (isset($definition['extends'])) {
           $class->setExtends($definition['extends']);
        }
        if (isset($definition['implements'])) {
            foreach ($definition['implements'] as $interface) {
                $class->addImplements($interface);
            }
        }
        if (isset($definition['uses'])) {
            foreach ($definition['uses'] as $alias => $use) {
                $alias = is_string($alias) ? $alias : null;
                $class->addUse($use, $alias);
            }
        }
        if (isset($definition['functions'])) {
            foreach ($definition['functions'] as $definition) {
                $function = $this->arrayToFunctionElement($definition);
                $class->addFunction($function);
            }
        }
        return $class;
    }
1289901
public function parseSchema(\stdClass $schema, Context $context)
    {
        if ($this->isProcessed($schema, $this->parsedSchemas)) {
            return $schema;
        }

        $version = $this->getVersion($schema);
        $constraints = $this->registry->getConstraints($version);
        $constraints = $this->filterConstraintsForSchema($constraints, $schema);

        foreach ($constraints as $constraint) {
            $constraint->normalize($schema, $context, $this);
        }

        return $schema;
    }
232814
private function resolveDefinition(Definition $definition): Definition
    {
        $definition->setArguments($this->resolveArguments($definition->getArguments()));
        $definition->setFactory($this->resolveFactory($definition->getFactory()));
        $definition->setMethodCalls($this->resolveMethodCalls($definition->getMethodCalls()));

        return $definition;
    }
602649
private function getCompilerPass(Definition $definition)
    {
        $driver = $this->getResourceDriver($definition);

        if ($driver === null) {
            return;
        }

        $class = $this->getCompilerPassClass($driver);
        $method = $this->getCompilerPassMethod($this->getResourceDriverMappingFormat($definition));
        $path = $this->getResourceDriverMappingPath($definition);
        $model = $this->getResourceModel($definition);

        return $class::$method([$path => ClassUtils::getRealNamespace($model)], []);
    }
262290
public function addSource(string $class, string $source): SchemaBuilder
    {
        if (!$this->hasSchema($class)) {
            throw new SchemaException("Unable to add source to '{$class}', class is unknown to ODM");
        }

        //See usage below
        $scope = [
            $this->getSchema($class)->getDatabase(),
            $this->getSchema($class)->getCollection()
        ];

        //Ensuring same source for all children classes from same collection
        foreach ($this->schemas as $schema) {
            if (isset($this->sources[$schema->getClass()])) {
                //Already set
                continue;
            }

            if (is_a($schema->getClass(), $class, true)) {
                //Only for entities from the same collection
                if ([$schema->getDatabase(), $schema->getCollection()] == $scope) {
                    $this->sources[$schema->getClass()] = $source;
                }
            }
        }

        return $this;
    }
696469
protected function createParameter(\stdClass $definition)
    {
        if ($definition->in === Parameter::IN_BODY) {
            $definition->schema       = isset($definition->schema) ? $definition->schema : (object)[];
            $definition->schema->type = $definition->schema->type ?: 'object';
        }
        if (isset($definition->schema)) {
            $schema = $this->schemaFactory->create($definition->schema);
        } else {
            $schema = $this->createParameterSchema($definition);
        }

        $required         = isset($definition->required) && $definition->required;
        $collectionFormat = isset($definition->collectionFormat) ? $definition->collectionFormat : null;

        return new Parameter($definition->name, $required, $schema, $definition->in, $collectionFormat);
    }
132764
public function createWritableDictionary(DictionaryDefinition $definition): WritableDictionaryInterface
    {
        $builder = $this->getDictionaryBuilder($definition);

        /** @var DictionaryBuilderInterface $builder */
        return $builder->buildWritable($this, $definition);
    }
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;
    }
975926
public function set($id, $definition)
	{
	    if (is_numeric($id)) {
	        $id = is_string($definition) ? $definition : $definition['class'];
	    }
	    $this->_definitions[$id] = $definition;
	    return $this;
	}
855413
public function parseMigrationDefinition(MigrationDefinition $definition)
    {
        $dbType = $this->getDBFromFile($definition->name);

        if (!in_array($dbType, $this->supportedDatabases))
        {
            return new MigrationDefinition(
                $definition->name,
                $definition->path,
                $definition->rawDefinition,
                MigrationDefinition::STATUS_INVALID,
                array(),
                "Unsupported or missing database: '$dbType'. The database name is the part of the filename after the 1st underscore"
            );
        }

        return new MigrationDefinition(
            $definition->name,
            $definition->path,
            $definition->rawDefinition,
            MigrationDefinition::STATUS_PARSED,
            array(
                new MigrationStep('sql', array($dbType => $definition->rawDefinition), array('path' => $definition->path))
            )
        );
    }
61835
static public function formatDefinition($name, $definition)
	{
	    if (empty($definition)) {
	        return ['class' => $name];
	    } elseif (is_callable($definition, false) || is_object($definition)) {
	        return $definition;
	    } elseif (is_string($definition)) {
	        if (strpos($definition, ':') !== false) {
	            return $definition;
	        }
	        return ['class' => $definition];
	    } elseif (is_array($definition)) {
	        if (!isset($definition['class'])) {
	            if (strpos($name, '\\') !== false) {
	                $definition['class'] = $name;
	            } else {
	                throw new InvalidConfigException("A class definition requires a \"class\" member.");
	            }
	        }
	        return $definition;
	    } else {
	        throw new InvalidConfigException("Unsupported definition type for \"$name\": " . gettype($definition));
	    }
	}
192646
private function getDictionaryBuilder(DictionaryDefinition $definition): DictionaryBuilderInterface
    {
        if (!$this->dictionaryBuilders->has($typeName = $definition->getType())) {
            $typeName = 'default';
        }

        return $this->dictionaryBuilders->get($typeName);
    }