public static function createFromArray($name, array $data = [])
    {
        $class = new static($name);

        $class->setType($data['type']);
        if (isset($data['usage'])) {
            \assert($class instanceof TraitDefinition);
            $class->setUsage($data['usage']);
        }
        if (isset($data['required'])) {
            $class->setRequired($data['required']);
        }
        if (isset($data['enum'])) {
            $class->setEnum($data['enum']);
        }
        if (\substr($name, -1) === '?') {
            $class->setRequired(false);
            $class->setName(\substr($name, 0, -1));
        }
        $class->setDefinition($data);

        return $class;
    }