<commit_before><?php
namespace GraphQL\Type\Definition;

use GraphQL\Utils;

class FieldDefinition
{
    /**
     * @var string
     */
    public $name;

    /**
     * @var OutputType
     */
    private $type;

    private $resolvedType;

    /**
     * @var array<GraphQLFieldArgument>
     */
    public $args;

    /**
     * source?: any,
     * args?: ?{[argName: string]: any},
     * context?: any,
     * fieldAST?: any,
     * fieldType?: any,
     * parentType?: any,
     * schema?: GraphQLSchema
     *
     * @var callable
     */
    public $resolve;

    /**
     * @var string|null
     */
    public $description;

    /**
     * @var string|null
     */
    public $deprecationReason;

    private static $def;

    public static function getDefinition()
    {
        return self::$def ?: (self::$def = [
            'name' => Config::STRING | Config::REQUIRED,
            'type' => Config::OUTPUT_TYPE | Config::REQUIRED,
            'args' => Config::arrayOf([
                'name' => Config::STRING | Config::REQUIRED,
                'type' => Config::INPUT_TYPE | Config::REQUIRED,
                'defaultValue' => Config::ANY
            ], Config::KEY_AS_NAME),
            'resolve' => Config::CALLBACK,
            'description' => Config::STRING,
            'deprecationReason' => Config::STRING,
        ]);
    }

    /**
     * @param array|Config $fields
     * @return array
     */
    public static function createMap(array $fields)
    {
        $map = [];
        foreach ($fields as $name => $field) {
            if (!isset($field['name'])) {
                $field['name'] = $name;
            }
            $map[$name] = self::create($field);
        }
        return $map;
    }

    /**
     * @param array|Config $field
     * @return FieldDefinition
     */
    public static function create($field)
    {
        Config::validate($field, self::getDefinition());
        return new self($field);
    }

    protected function __construct(array $config)
    {
        $this->name = $config['name'];
        $this->type = $config['type'];
        $this->resolve = isset($config['resolve']) ? $config['resolve'] : null;
        $this->args = isset($config['args']) ? FieldArgument::createMap($config['args']) : [];

        $this->description = isset($config['description']) ? $config['description'] : null;
        $this->deprecationReason = isset($config['deprecationReason']) ? $config['deprecationReason'] : null;
    }

    /**
     * @param $name
     * @return FieldArgument|null
     */
    public function getArg($name)
    {<commit_msg>Saving original field config with field definition to allow custom app-level definitions<commit_after><?php
namespace GraphQL\Type\Definition;

use GraphQL\Utils;

class FieldDefinition
{
    /**
     * @var string
     */
    public $name;

    /**
     * @var OutputType
     */
    private $type;

    private $resolvedType;

    /**
     * @var array<GraphQLFieldArgument>
     */
    public $args;

    /**
     * source?: any,
     * args?: ?{[argName: string]: any},
     * info
     *
     * @var callable
     */
    public $resolve;

    /**
     * @var string|null
     */
    public $description;

    /**
     * @var string|null
     */
    public $deprecationReason;

    /**
     * Original field definition config
     *
     * @var array
     */
    public $config;

    private static $def;

    public static function getDefinition()
    {
        return self::$def ?: (self::$def = [
            'name' => Config::STRING | Config::REQUIRED,
            'type' => Config::OUTPUT_TYPE | Config::REQUIRED,
            'args' => Config::arrayOf([
                'name' => Config::STRING | Config::REQUIRED,
                'type' => Config::INPUT_TYPE | Config::REQUIRED,
                'description' => Config::STRING,
                'defaultValue' => Config::ANY
            ], Config::KEY_AS_NAME),
            'resolve' => Config::CALLBACK,
            'description' => Config::STRING,
            'deprecationReason' => Config::STRING,
        ]);
    }

    /**
     * @param array|Config $fields
     * @return array
     */
    public static function createMap(array $fields)
    {
        $map = [];
        foreach ($fields as $name => $field) {
            if (!isset($field['name'])) {
                $field['name'] = $name;
            }
            $map[$name] = self::create($field);
        }
        return $map;
    }

    /**
     * @param array|Config $field
     * @return FieldDefinition
     */
    public static function create($field)
    {
        Config::validate($field, self::getDefinition());
        return new self($field);
    }

    protected function __construct(array $config)
    {
        $this->name = $config['name'];
        $this->type = $config['type'];
        $this->resolve = isset($config['resolve']) ? $config['resolve'] : null;
        $this->args = isset($config['args']) ? FieldArgument::createMap($config['args']) : [];

        $this->description = isset($config['description']) ? $config['description'] : null;
        $this->deprecationReason = isset($config['deprecationReason']) ? $config['deprecationReason'] : null;

        $this->config = $config;
    }

    /**
     * @param $name
     * @return FieldArgument|null
     */
    public function getArg($name)
    {
{'fraction_non_alphanumeric': 0.15967802321228006, 'fraction_numerical': 0.0, 'mean_word_length': 2.0566361556064074, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2635733', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1528, 'n_words': 314}