repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
toplan/phpsms | src/phpsms/PhpSmsServiceProvider.php | PhpSmsServiceProvider.register | public function register()
{
if ($this->app instanceof LumenApplication) {
$this->app->configure('phpsms');
}
$this->mergeConfigFrom(__DIR__ . '/../config/phpsms.php', 'phpsms');
$this->app->singleton('Toplan\\PhpSms\\Sms', function () {
Sms::scheme(config('phpsms.scheme', []));
Sms::config(config('phpsms.agents', []));
return new Sms(false);
});
} | php | public function register()
{
if ($this->app instanceof LumenApplication) {
$this->app->configure('phpsms');
}
$this->mergeConfigFrom(__DIR__ . '/../config/phpsms.php', 'phpsms');
$this->app->singleton('Toplan\\PhpSms\\Sms', function () {
Sms::scheme(config('phpsms.scheme', []));
Sms::config(config('phpsms.agents', []));
return new Sms(false);
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"instanceof",
"LumenApplication",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"configure",
"(",
"'phpsms'",
")",
";",
"}",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"_... | Register the service provider. | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/PhpSmsServiceProvider.php#L35-L48 |
toplan/phpsms | src/phpsms/agents/ParasiticAgent.php | ParasiticAgent.handle | protected function handle($name, array $args = [])
{
if (isset($this->handlers[$name]) && is_callable($this->handlers[$name])) {
array_unshift($args, $this);
call_user_func_array($this->handlers[$name], $args);
}
} | php | protected function handle($name, array $args = [])
{
if (isset($this->handlers[$name]) && is_callable($this->handlers[$name])) {
array_unshift($args, $this);
call_user_func_array($this->handlers[$name], $args);
}
} | [
"protected",
"function",
"handle",
"(",
"$",
"name",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"handlers",
"[",
"$",
"name",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"handlers",
... | Handle send process by closure.
@param $name
@param array $args | [
"Handle",
"send",
"process",
"by",
"closure",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/ParasiticAgent.php#L96-L102 |
toplan/phpsms | src/phpsms/agents/ParasiticAgent.php | ParasiticAgent.methods | public static function methods()
{
if (!is_array(self::$methods)) {
self::$methods = [];
$interfaces = class_implements('Toplan\\PhpSms\\ParasiticAgent');
foreach ($interfaces as $interface) {
self::$methods = array_merge(self::$methods, get_class_methods($interface));
}
}
return self::$methods;
} | php | public static function methods()
{
if (!is_array(self::$methods)) {
self::$methods = [];
$interfaces = class_implements('Toplan\\PhpSms\\ParasiticAgent');
foreach ($interfaces as $interface) {
self::$methods = array_merge(self::$methods, get_class_methods($interface));
}
}
return self::$methods;
} | [
"public",
"static",
"function",
"methods",
"(",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"self",
"::",
"$",
"methods",
")",
")",
"{",
"self",
"::",
"$",
"methods",
"=",
"[",
"]",
";",
"$",
"interfaces",
"=",
"class_implements",
"(",
"'Toplan\\\\PhpSm... | Get methods name which inherit from interfaces.
@return array | [
"Get",
"methods",
"name",
"which",
"inherit",
"from",
"interfaces",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/ParasiticAgent.php#L109-L120 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.reset | public function reset()
{
$this->result = [
self::SUCCESS => false,
self::INFO => null,
self::CODE => 0,
];
} | php | public function reset()
{
$this->result = [
self::SUCCESS => false,
self::INFO => null,
self::CODE => 0,
];
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"result",
"=",
"[",
"self",
"::",
"SUCCESS",
"=>",
"false",
",",
"self",
"::",
"INFO",
"=>",
"null",
",",
"self",
"::",
"CODE",
"=>",
"0",
",",
"]",
";",
"}"
] | Reset states. | [
"Reset",
"states",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L46-L53 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.config | public function config($key = null, $value = null, $override = false)
{
if (is_array($key) && is_bool($value)) {
$override = $value;
}
return Util::operateArray($this->config, $key, $value, null, null, $override);
} | php | public function config($key = null, $value = null, $override = false)
{
if (is_array($key) && is_bool($value)) {
$override = $value;
}
return Util::operateArray($this->config, $key, $value, null, null, $override);
} | [
"public",
"function",
"config",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"value",
"=",
"null",
",",
"$",
"override",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"key",
")",
"&&",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"ov... | Get or set the configuration information.
@param string|array $key
@param mixed $value
@param bool $override
@return mixed | [
"Get",
"or",
"set",
"the",
"configuration",
"information",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L64-L71 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.sendSms | public function sendSms($to, $content = null, $tempId = null, array $data = [], array $params = [])
{
$this->reset();
$this->params($params, true);
$to = $this->formatMobile(Util::formatMobiles($to));
if ($tempId && $this instanceof TemplateSms) {
$this->sendTemplateSms($to, $tempId, $data);
} elseif ($content && $this instanceof ContentSms) {
$this->sendContentSms($to, $content);
}
} | php | public function sendSms($to, $content = null, $tempId = null, array $data = [], array $params = [])
{
$this->reset();
$this->params($params, true);
$to = $this->formatMobile(Util::formatMobiles($to));
if ($tempId && $this instanceof TemplateSms) {
$this->sendTemplateSms($to, $tempId, $data);
} elseif ($content && $this instanceof ContentSms) {
$this->sendContentSms($to, $content);
}
} | [
"public",
"function",
"sendSms",
"(",
"$",
"to",
",",
"$",
"content",
"=",
"null",
",",
"$",
"tempId",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"reset",
"(",... | SMS send process.
@param $to
@param $content
@param $tempId
@param array $data
@param array $params | [
"SMS",
"send",
"process",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L100-L111 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.sendVoice | public function sendVoice($to, $content = null, $tempId = null, array $data = [], $code = null, $fileId = null, array $params = [])
{
$this->reset();
$this->params($params, true);
$to = $this->formatMobile(Util::formatMobiles($to));
if ($tempId && $this instanceof TemplateVoice) {
$this->sendTemplateVoice($to, $tempId, $data);
} elseif ($fileId && $this instanceof FileVoice) {
$this->sendFileVoice($to, $fileId);
} elseif ($code && $this instanceof VoiceCode) {
$this->sendVoiceCode($to, $code);
} elseif ($content && $this instanceof ContentVoice) {
$this->sendContentVoice($to, $content);
}
} | php | public function sendVoice($to, $content = null, $tempId = null, array $data = [], $code = null, $fileId = null, array $params = [])
{
$this->reset();
$this->params($params, true);
$to = $this->formatMobile(Util::formatMobiles($to));
if ($tempId && $this instanceof TemplateVoice) {
$this->sendTemplateVoice($to, $tempId, $data);
} elseif ($fileId && $this instanceof FileVoice) {
$this->sendFileVoice($to, $fileId);
} elseif ($code && $this instanceof VoiceCode) {
$this->sendVoiceCode($to, $code);
} elseif ($content && $this instanceof ContentVoice) {
$this->sendContentVoice($to, $content);
}
} | [
"public",
"function",
"sendVoice",
"(",
"$",
"to",
",",
"$",
"content",
"=",
"null",
",",
"$",
"tempId",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"code",
"=",
"null",
",",
"$",
"fileId",
"=",
"null",
",",
"array",
"$",
"... | Voice send process.
@param $to
@param $content
@param $tempId
@param array $data
@param $code
@param $fileId
@param array $params | [
"Voice",
"send",
"process",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L124-L139 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.formatMobile | public function formatMobile(array $list)
{
return implode(',', array_unique(array_map(function ($value) {
return is_array($value) ? "{$value['number']}" : $value;
}, $list)));
} | php | public function formatMobile(array $list)
{
return implode(',', array_unique(array_map(function ($value) {
return is_array($value) ? "{$value['number']}" : $value;
}, $list)));
} | [
"public",
"function",
"formatMobile",
"(",
"array",
"$",
"list",
")",
"{",
"return",
"implode",
"(",
"','",
",",
"array_unique",
"(",
"array_map",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"is_array",
"(",
"$",
"value",
")",
"?",
"\"{$value... | Formatting a mobile number from the list of mobile numbers.
@param array $list
@return string | [
"Formatting",
"a",
"mobile",
"number",
"from",
"the",
"list",
"of",
"mobile",
"numbers",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L148-L153 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.curlPost | public function curlPost($url, array $params = [], array $opts = [])
{
$options = [
CURLOPT_POST => true,
CURLOPT_URL => $url,
];
foreach ($opts as $key => $value) {
if ($key !== CURLOPT_POST && $key !== CURLOPT_URL) {
$options[$key] = $value;
}
}
if (!array_key_exists(CURLOPT_POSTFIELDS, $options)) {
$options[CURLOPT_POSTFIELDS] = $this->params($params);
}
return self::curl($options);
} | php | public function curlPost($url, array $params = [], array $opts = [])
{
$options = [
CURLOPT_POST => true,
CURLOPT_URL => $url,
];
foreach ($opts as $key => $value) {
if ($key !== CURLOPT_POST && $key !== CURLOPT_URL) {
$options[$key] = $value;
}
}
if (!array_key_exists(CURLOPT_POSTFIELDS, $options)) {
$options[CURLOPT_POSTFIELDS] = $this->params($params);
}
return self::curl($options);
} | [
"public",
"function",
"curlPost",
"(",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"opts",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"[",
"CURLOPT_POST",
"=>",
"true",
",",
"CURLOPT_URL",
"=>",
"$",
"url",
",",
... | @codeCoverageIgnore
@param $url
@param array $params
@param array $opts
@return array | [
"@codeCoverageIgnore"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L164-L180 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.curlGet | public function curlGet($url, array $params = [], array $opts = [])
{
$params = $this->params($params);
$queryStr = http_build_query($params);
$opts[CURLOPT_POST] = false;
$opts[CURLOPT_URL] = $queryStr ? "$url?$queryStr" : $url;
return self::curl($opts);
} | php | public function curlGet($url, array $params = [], array $opts = [])
{
$params = $this->params($params);
$queryStr = http_build_query($params);
$opts[CURLOPT_POST] = false;
$opts[CURLOPT_URL] = $queryStr ? "$url?$queryStr" : $url;
return self::curl($opts);
} | [
"public",
"function",
"curlGet",
"(",
"$",
"url",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"opts",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"params",
"(",
"$",
"params",
")",
";",
"$",
"queryStr",
"=... | @codeCoverageIgnore
@param $url
@param array $params
@param array $opts
@return array | [
"@codeCoverageIgnore"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L191-L199 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.curl | public static function curl(array $opts = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
foreach ($opts as $key => $value) {
curl_setopt($ch, $key, $value);
}
$response = curl_exec($ch);
$request = $response !== false;
if (!$request) {
$response = curl_getinfo($ch);
}
curl_close($ch);
return compact('request', 'response');
} | php | public static function curl(array $opts = [])
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
foreach ($opts as $key => $value) {
curl_setopt($ch, $key, $value);
}
$response = curl_exec($ch);
$request = $response !== false;
if (!$request) {
$response = curl_getinfo($ch);
}
curl_close($ch);
return compact('request', 'response');
} | [
"public",
"static",
"function",
"curl",
"(",
"array",
"$",
"opts",
"=",
"[",
"]",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTP_VERSION",
",",
"CURL_HTTP_VERSION_1_1",
")",
";",
"curl_setopt",
"("... | cURl
@codeCoverageIgnore
@param array $opts curl options
@return array ['request', 'response']
request: Whether request success.
response: Response data. | [
"cURl"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L212-L234 |
toplan/phpsms | src/phpsms/agents/Agent.php | Agent.result | public function result($name = null, $value = null)
{
if ($name === null) {
return $this->result;
}
if (array_key_exists($name, $this->result)) {
if ($value === null) {
return $this->result[$name];
}
$this->result[$name] = $value;
}
} | php | public function result($name = null, $value = null)
{
if ($name === null) {
return $this->result;
}
if (array_key_exists($name, $this->result)) {
if ($value === null) {
return $this->result[$name];
}
$this->result[$name] = $value;
}
} | [
"public",
"function",
"result",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"result",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"n... | Get or set the result data.
@param $name
@param $value
@return mixed | [
"Get",
"or",
"set",
"the",
"result",
"data",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/Agent.php#L244-L255 |
toplan/phpsms | src/phpsms/lib/Ucpaas.php | Ucpaas.getResult | private function getResult($url, $body, $type, $method)
{
$data = $this->connection($url, $body, $type, $method);
if (isset($data) && !empty($data)) {
$result = $data;
} else {
$result = '没有返回数据';
}
return $result;
} | php | private function getResult($url, $body, $type, $method)
{
$data = $this->connection($url, $body, $type, $method);
if (isset($data) && !empty($data)) {
$result = $data;
} else {
$result = '没有返回数据';
}
return $result;
} | [
"private",
"function",
"getResult",
"(",
"$",
"url",
",",
"$",
"body",
",",
"$",
"type",
",",
"$",
"method",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"connection",
"(",
"$",
"url",
",",
"$",
"body",
",",
"$",
"type",
",",
"$",
"method",
"... | @param string $url
@param string|null $body
@param string $type
@param string $method
@return mixed|string | [
"@param",
"string",
"$url",
"@param",
"string|null",
"$body",
"@param",
"string",
"$type",
"@param",
"string",
"$method"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/lib/Ucpaas.php#L86-L96 |
toplan/phpsms | src/phpsms/lib/Ucpaas.php | Ucpaas.connection | private function connection($url, $body, $type, $method)
{
if ($type === 'json') {
$mine = 'application/json';
} else {
$mine = 'application/xml';
}
if (function_exists('curl_init')) {
$header = array(
'Accept:' . $mine,
'Content-Type:' . $mine . ';charset=utf-8',
'Authorization:' . $this->getAuthorization(),
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ($method === 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close($ch);
} else {
$opts = array();
$opts['http'] = array();
$headers = array(
'method' => strtoupper($method),
);
$headers[] = 'Accept:' . $mine;
$headers['header'] = array();
$headers['header'][] = 'Authorization: ' . $this->getAuthorization();
$headers['header'][] = 'Content-Type:' . $mine . ';charset=utf-8';
if (!empty($body)) {
$headers['header'][] = 'Content-Length:' . strlen($body);
$headers['content'] = $body;
}
$opts['http'] = $headers;
$result = file_get_contents($url, false, stream_context_create($opts));
}
return $result;
} | php | private function connection($url, $body, $type, $method)
{
if ($type === 'json') {
$mine = 'application/json';
} else {
$mine = 'application/xml';
}
if (function_exists('curl_init')) {
$header = array(
'Accept:' . $mine,
'Content-Type:' . $mine . ';charset=utf-8',
'Authorization:' . $this->getAuthorization(),
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ($method === 'post') {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec($ch);
curl_close($ch);
} else {
$opts = array();
$opts['http'] = array();
$headers = array(
'method' => strtoupper($method),
);
$headers[] = 'Accept:' . $mine;
$headers['header'] = array();
$headers['header'][] = 'Authorization: ' . $this->getAuthorization();
$headers['header'][] = 'Content-Type:' . $mine . ';charset=utf-8';
if (!empty($body)) {
$headers['header'][] = 'Content-Length:' . strlen($body);
$headers['content'] = $body;
}
$opts['http'] = $headers;
$result = file_get_contents($url, false, stream_context_create($opts));
}
return $result;
} | [
"private",
"function",
"connection",
"(",
"$",
"url",
",",
"$",
"body",
",",
"$",
"type",
",",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"'json'",
")",
"{",
"$",
"mine",
"=",
"'application/json'",
";",
"}",
"else",
"{",
"$",
"mine",
... | @param string $url
@param string $type
@param string|null $body
@param string $method
@return mixed|string | [
"@param",
"string",
"$url",
"@param",
"string",
"$type",
"@param",
"string|null",
"$body",
"@param",
"string",
"$method"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/lib/Ucpaas.php#L106-L151 |
toplan/phpsms | src/phpsms/lib/Ucpaas.php | Ucpaas.callBack | public function callBack($appId, $fromClient, $to, $fromSerNum = null, $toSerNum = null, $type = 'json')
{
$url = self::BaseUrl . self::SoftVersion . '/Accounts/' . $this->accountSid . '/Calls/callBack?sig=' . $this->getSigParameter();
if ($type === 'json') {
$body_json = array('callback' => array(
'appId' => $appId,
'fromClient' => $fromClient,
'fromSerNum' => $fromSerNum,
'to' => $to,
'toSerNum' => $toSerNum,
));
$body = json_encode($body_json);
} elseif ($type === 'xml') {
$body_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<callback>
<fromClient>' . $fromClient . '</clientNumber>
<fromSerNum>' . $fromSerNum . '</chargeType>
<to>' . $to . '</charge>
<toSerNum>' . $toSerNum . '</toSerNum>
<appId>' . $appId . '</appId>
</callback>';
$body = trim($body_xml);
} else {
throw new Exception('只能json或xml,默认为json');
}
$data = $this->getResult($url, $body, $type, 'post');
return $data;
} | php | public function callBack($appId, $fromClient, $to, $fromSerNum = null, $toSerNum = null, $type = 'json')
{
$url = self::BaseUrl . self::SoftVersion . '/Accounts/' . $this->accountSid . '/Calls/callBack?sig=' . $this->getSigParameter();
if ($type === 'json') {
$body_json = array('callback' => array(
'appId' => $appId,
'fromClient' => $fromClient,
'fromSerNum' => $fromSerNum,
'to' => $to,
'toSerNum' => $toSerNum,
));
$body = json_encode($body_json);
} elseif ($type === 'xml') {
$body_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<callback>
<fromClient>' . $fromClient . '</clientNumber>
<fromSerNum>' . $fromSerNum . '</chargeType>
<to>' . $to . '</charge>
<toSerNum>' . $toSerNum . '</toSerNum>
<appId>' . $appId . '</appId>
</callback>';
$body = trim($body_xml);
} else {
throw new Exception('只能json或xml,默认为json');
}
$data = $this->getResult($url, $body, $type, 'post');
return $data;
} | [
"public",
"function",
"callBack",
"(",
"$",
"appId",
",",
"$",
"fromClient",
",",
"$",
"to",
",",
"$",
"fromSerNum",
"=",
"null",
",",
"$",
"toSerNum",
"=",
"null",
",",
"$",
"type",
"=",
"'json'",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BaseUrl"... | @param $appId
@param $fromClient
@param string $to
@param null $fromSerNum
@param null $toSerNum
@param string $type
@throws Exception
@return mixed|string
@links http://www.ucpaas.com/page/doc/doc_rest3-1.jsp | [
"@param",
"$appId",
"@param",
"$fromClient",
"@param",
"string",
"$to",
"@param",
"null",
"$fromSerNum",
"@param",
"null",
"$toSerNum",
"@param",
"string",
"$type"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/lib/Ucpaas.php#L166-L194 |
toplan/phpsms | src/phpsms/lib/Ucpaas.php | Ucpaas.voiceCode | public function voiceCode($appId, $verifyCode, $to, $type = 'json')
{
$url = self::BaseUrl . self::SoftVersion . '/Accounts/' . $this->accountSid . '/Calls/voiceCode?sig=' . $this->getSigParameter();
if ($type === 'json') {
$body_json = array('voiceCode' => array(
'appId' => $appId,
'verifyCode' => $verifyCode,
'to' => $to,
));
$body = json_encode($body_json);
} elseif ($type === 'xml') {
$body_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<voiceCode>
<verifyCode>' . $verifyCode . '</clientNumber>
<to>' . $to . '</charge>
<appId>' . $appId . '</appId>
</voiceCode>';
$body = trim($body_xml);
} else {
throw new Exception('只能json或xml,默认为json');
}
$data = $this->getResult($url, $body, $type, 'post');
return $data;
} | php | public function voiceCode($appId, $verifyCode, $to, $type = 'json')
{
$url = self::BaseUrl . self::SoftVersion . '/Accounts/' . $this->accountSid . '/Calls/voiceCode?sig=' . $this->getSigParameter();
if ($type === 'json') {
$body_json = array('voiceCode' => array(
'appId' => $appId,
'verifyCode' => $verifyCode,
'to' => $to,
));
$body = json_encode($body_json);
} elseif ($type === 'xml') {
$body_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<voiceCode>
<verifyCode>' . $verifyCode . '</clientNumber>
<to>' . $to . '</charge>
<appId>' . $appId . '</appId>
</voiceCode>';
$body = trim($body_xml);
} else {
throw new Exception('只能json或xml,默认为json');
}
$data = $this->getResult($url, $body, $type, 'post');
return $data;
} | [
"public",
"function",
"voiceCode",
"(",
"$",
"appId",
",",
"$",
"verifyCode",
",",
"$",
"to",
",",
"$",
"type",
"=",
"'json'",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"BaseUrl",
".",
"self",
"::",
"SoftVersion",
".",
"'/Accounts/'",
".",
"$",
"this"... | @param $appId
@param $verifyCode
@param $to
@param string $type
@throws Exception
@return mixed|string
@links http://www.ucpaas.com/page/doc/doc_rest3-2.jsp | [
"@param",
"$appId",
"@param",
"$verifyCode",
"@param",
"$to",
"@param",
"string",
"$type"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/lib/Ucpaas.php#L207-L231 |
toplan/phpsms | src/phpsms/agents/AlidayuAgent.php | AlidayuAgent.sendTemplateSms | public function sendTemplateSms($to, $tempId, array $tempData)
{
$params = [
'method' => 'alibaba.aliqin.fc.sms.num.send',
'sms_type' => 'normal',
'sms_free_sign_name' => $this->smsFreeSignName,
'sms_param' => $this->getTempDataString($tempData),
'rec_num' => $to,
'sms_template_code' => $tempId,
];
$this->request($params);
} | php | public function sendTemplateSms($to, $tempId, array $tempData)
{
$params = [
'method' => 'alibaba.aliqin.fc.sms.num.send',
'sms_type' => 'normal',
'sms_free_sign_name' => $this->smsFreeSignName,
'sms_param' => $this->getTempDataString($tempData),
'rec_num' => $to,
'sms_template_code' => $tempId,
];
$this->request($params);
} | [
"public",
"function",
"sendTemplateSms",
"(",
"$",
"to",
",",
"$",
"tempId",
",",
"array",
"$",
"tempData",
")",
"{",
"$",
"params",
"=",
"[",
"'method'",
"=>",
"'alibaba.aliqin.fc.sms.num.send'",
",",
"'sms_type'",
"=>",
"'normal'",
",",
"'sms_free_sign_name'",... | Template SMS send process.
@param string|array $to
@param int|string $tempId
@param array $tempData | [
"Template",
"SMS",
"send",
"process",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/AlidayuAgent.php#L23-L34 |
toplan/phpsms | src/phpsms/agents/AlidayuAgent.php | AlidayuAgent.sendTemplateVoice | public function sendTemplateVoice($to, $tempId, array $tempData)
{
$params = [
'called_num' => $to,
'called_show_num' => $this->calledShowNum,
'method' => 'alibaba.aliqin.fc.tts.num.singlecall',
'tts_code' => $tempId,
'tts_param' => $this->getTempDataString($tempData),
];
$this->request($params);
} | php | public function sendTemplateVoice($to, $tempId, array $tempData)
{
$params = [
'called_num' => $to,
'called_show_num' => $this->calledShowNum,
'method' => 'alibaba.aliqin.fc.tts.num.singlecall',
'tts_code' => $tempId,
'tts_param' => $this->getTempDataString($tempData),
];
$this->request($params);
} | [
"public",
"function",
"sendTemplateVoice",
"(",
"$",
"to",
",",
"$",
"tempId",
",",
"array",
"$",
"tempData",
")",
"{",
"$",
"params",
"=",
"[",
"'called_num'",
"=>",
"$",
"to",
",",
"'called_show_num'",
"=>",
"$",
"this",
"->",
"calledShowNum",
",",
"'m... | Template voice send process.
@param string|array $to
@param int|string $tempId
@param array $tempData | [
"Template",
"voice",
"send",
"process",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/AlidayuAgent.php#L43-L53 |
toplan/phpsms | src/phpsms/agents/AlidayuAgent.php | AlidayuAgent.sendVoiceCode | public function sendVoiceCode($to, $code)
{
$params = [
'called_num' => $to,
'called_show_num' => $this->calledShowNum,
'method' => 'alibaba.aliqin.fc.voice.num.singlecall',
'voice_code' => $code,
];
$this->request($params);
} | php | public function sendVoiceCode($to, $code)
{
$params = [
'called_num' => $to,
'called_show_num' => $this->calledShowNum,
'method' => 'alibaba.aliqin.fc.voice.num.singlecall',
'voice_code' => $code,
];
$this->request($params);
} | [
"public",
"function",
"sendVoiceCode",
"(",
"$",
"to",
",",
"$",
"code",
")",
"{",
"$",
"params",
"=",
"[",
"'called_num'",
"=>",
"$",
"to",
",",
"'called_show_num'",
"=>",
"$",
"this",
"->",
"calledShowNum",
",",
"'method'",
"=>",
"'alibaba.aliqin.fc.voice.... | Voice code send process.
@param string|array $to
@param int|string $code | [
"Voice",
"code",
"send",
"process",
"."
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/agents/AlidayuAgent.php#L61-L70 |
toplan/phpsms | src/phpsms/lib/CCPRestSmsSDK.php | REST.voiceVerify | public function voiceVerify($verifyCode, $playTimes, $to, $displayNum = null, $respUrl = null, $lang = 'zh', $userData = null, $welcomePrompt = null, $playVerifyCode = null)
{
//主帐号鉴权信息验证,对必选参数进行判空。
$auth = $this->accAuth();
if ($auth !== true) {
return $auth;
}
// 拼接请求包体
if ($this->BodyType === 'json') {
$body = "{'appId':'$this->AppId','verifyCode':'$verifyCode','playTimes':'$playTimes','to':'$to','respUrl':'$respUrl','displayNum':'$displayNum',
'lang':'$lang','userData':'$userData','welcomePrompt':'$welcomePrompt','playVerifyCode':'$playVerifyCode'}";
} else {
$body = "<VoiceVerify>
<appId>$this->AppId</appId>
<verifyCode>$verifyCode</verifyCode>
<playTimes>$playTimes</playTimes>
<to>$to</to>
<respUrl>$respUrl</respUrl>
<displayNum>$displayNum</displayNum>
<lang>$lang</lang>
<userData>$userData</userData>
<welcomePrompt>$welcomePrompt</welcomePrompt>
<playVerifyCode>$playVerifyCode</playVerifyCode>
</VoiceVerify>";
}
// 大写的sig参数
$sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
// 生成请求URL
$url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/VoiceVerify?sig=$sig";
// 生成授权:主帐户Id + 英文冒号 + 时间戳。
$authen = base64_encode($this->AccountSid . ':' . $this->Batch);
// 生成包头
$header = array("Accept:application/$this->BodyType", "Content-Type:application/$this->BodyType;charset=utf-8", "Authorization:$authen");
// 发送请求
$result = $this->curl_post($url, $body, $header);
if ($this->BodyType === 'json') {//JSON格式
$datas = json_decode($result);
} else { //xml格式
$datas = simplexml_load_string(trim($result, " \t\n\r"));
}
return $datas;
} | php | public function voiceVerify($verifyCode, $playTimes, $to, $displayNum = null, $respUrl = null, $lang = 'zh', $userData = null, $welcomePrompt = null, $playVerifyCode = null)
{
//主帐号鉴权信息验证,对必选参数进行判空。
$auth = $this->accAuth();
if ($auth !== true) {
return $auth;
}
// 拼接请求包体
if ($this->BodyType === 'json') {
$body = "{'appId':'$this->AppId','verifyCode':'$verifyCode','playTimes':'$playTimes','to':'$to','respUrl':'$respUrl','displayNum':'$displayNum',
'lang':'$lang','userData':'$userData','welcomePrompt':'$welcomePrompt','playVerifyCode':'$playVerifyCode'}";
} else {
$body = "<VoiceVerify>
<appId>$this->AppId</appId>
<verifyCode>$verifyCode</verifyCode>
<playTimes>$playTimes</playTimes>
<to>$to</to>
<respUrl>$respUrl</respUrl>
<displayNum>$displayNum</displayNum>
<lang>$lang</lang>
<userData>$userData</userData>
<welcomePrompt>$welcomePrompt</welcomePrompt>
<playVerifyCode>$playVerifyCode</playVerifyCode>
</VoiceVerify>";
}
// 大写的sig参数
$sig = strtoupper(md5($this->AccountSid . $this->AccountToken . $this->Batch));
// 生成请求URL
$url = "https://$this->ServerIP:$this->ServerPort/$this->SoftVersion/Accounts/$this->AccountSid/Calls/VoiceVerify?sig=$sig";
// 生成授权:主帐户Id + 英文冒号 + 时间戳。
$authen = base64_encode($this->AccountSid . ':' . $this->Batch);
// 生成包头
$header = array("Accept:application/$this->BodyType", "Content-Type:application/$this->BodyType;charset=utf-8", "Authorization:$authen");
// 发送请求
$result = $this->curl_post($url, $body, $header);
if ($this->BodyType === 'json') {//JSON格式
$datas = json_decode($result);
} else { //xml格式
$datas = simplexml_load_string(trim($result, " \t\n\r"));
}
return $datas;
} | [
"public",
"function",
"voiceVerify",
"(",
"$",
"verifyCode",
",",
"$",
"playTimes",
",",
"$",
"to",
",",
"$",
"displayNum",
"=",
"null",
",",
"$",
"respUrl",
"=",
"null",
",",
"$",
"lang",
"=",
"'zh'",
",",
"$",
"userData",
"=",
"null",
",",
"$",
"... | 语音验证码
@param mixed $verifyCode 验证码内容,为数字和英文字母,不区分大小写,长度4-8位
@param mixed $playTimes 播放次数,1-3次
@param mixed $to 接收号码
@param mixed $displayNum 显示的主叫号码
@param mixed $respUrl 语音验证码状态通知回调地址,云通讯平台将向该Url地址发送呼叫结果通知
@param mixed $lang 语言类型
@param mixed $userData 第三方私有数据
@param mixed $welcomePrompt 欢迎提示音,在播放验证码语音前播放此内容(语音文件格式为wav)
@param mixed $playVerifyCode 语音验证码的内容全部播放此节点下的全部语音文件
@return mixed | [
"语音验证码"
] | train | https://github.com/toplan/phpsms/blob/863918ed0970d335471fb48c09f9f446a4daddbd/src/phpsms/lib/CCPRestSmsSDK.php#L175-L217 |
digiaonline/graphql-php | src/Util/TypeHelper.php | TypeHelper.isEqualType | public static function isEqualType(TypeInterface $typeA, TypeInterface $typeB): bool
{
// Equivalent types are equal.
if ($typeA === $typeB) {
return true;
}
// If either type is non-null, the other must also be non-null.
if ($typeA instanceof NonNullType && $typeB instanceof NonNullType) {
return self::isEqualType($typeA->getOfType(), $typeB->getOfType());
}
// If either type is a list, the other must also be a list.
if ($typeA instanceof ListType && $typeB instanceof ListType) {
return self::isEqualType($typeA->getOfType(), $typeB->getOfType());
}
// Otherwise the types are not equal.
return false;
} | php | public static function isEqualType(TypeInterface $typeA, TypeInterface $typeB): bool
{
// Equivalent types are equal.
if ($typeA === $typeB) {
return true;
}
// If either type is non-null, the other must also be non-null.
if ($typeA instanceof NonNullType && $typeB instanceof NonNullType) {
return self::isEqualType($typeA->getOfType(), $typeB->getOfType());
}
// If either type is a list, the other must also be a list.
if ($typeA instanceof ListType && $typeB instanceof ListType) {
return self::isEqualType($typeA->getOfType(), $typeB->getOfType());
}
// Otherwise the types are not equal.
return false;
} | [
"public",
"static",
"function",
"isEqualType",
"(",
"TypeInterface",
"$",
"typeA",
",",
"TypeInterface",
"$",
"typeB",
")",
":",
"bool",
"{",
"// Equivalent types are equal.",
"if",
"(",
"$",
"typeA",
"===",
"$",
"typeB",
")",
"{",
"return",
"true",
";",
"}"... | Provided two types, return true if the types are equal (invariant).
@param TypeInterface $typeA
@param TypeInterface $typeB
@return bool | [
"Provided",
"two",
"types",
"return",
"true",
"if",
"the",
"types",
"are",
"equal",
"(",
"invariant",
")",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/TypeHelper.php#L24-L43 |
digiaonline/graphql-php | src/Util/TypeHelper.php | TypeHelper.isTypeSubtypeOf | public static function isTypeSubtypeOf(
Schema $schema,
TypeInterface $maybeSubtype,
TypeInterface $superType
): bool {
// Equivalent type is a valid subtype.
if ($maybeSubtype === $superType) {
return true;
}
// If superType is non-null, maybeSubType must also be non-null.
if ($superType instanceof NonNullType) {
if ($maybeSubtype instanceof NonNullType) {
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType->getOfType());
}
return false;
}
if ($maybeSubtype instanceof NonNullType) {
// If superType is nullable, maybeSubType may be non-null or nullable.
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType);
}
// If superType type is a list, maybeSubType type must also be a list.
if ($superType instanceof ListType) {
if ($maybeSubtype instanceof ListType) {
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType->getOfType());
}
return false;
}
if ($maybeSubtype instanceof ListType) {
// If superType is not a list, maybeSubType must also be not a list.
return false;
}
// If superType type is an abstract type, maybeSubType type may be a currently
// possible object type.
if ($superType instanceof AbstractTypeInterface &&
$maybeSubtype instanceof ObjectType &&
$schema->isPossibleType($superType, $maybeSubtype)) {
return true;
}
// Otherwise, the child type is not a valid subtype of the parent type.
return false;
} | php | public static function isTypeSubtypeOf(
Schema $schema,
TypeInterface $maybeSubtype,
TypeInterface $superType
): bool {
// Equivalent type is a valid subtype.
if ($maybeSubtype === $superType) {
return true;
}
// If superType is non-null, maybeSubType must also be non-null.
if ($superType instanceof NonNullType) {
if ($maybeSubtype instanceof NonNullType) {
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType->getOfType());
}
return false;
}
if ($maybeSubtype instanceof NonNullType) {
// If superType is nullable, maybeSubType may be non-null or nullable.
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType);
}
// If superType type is a list, maybeSubType type must also be a list.
if ($superType instanceof ListType) {
if ($maybeSubtype instanceof ListType) {
return self::isTypeSubtypeOf($schema, $maybeSubtype->getOfType(), $superType->getOfType());
}
return false;
}
if ($maybeSubtype instanceof ListType) {
// If superType is not a list, maybeSubType must also be not a list.
return false;
}
// If superType type is an abstract type, maybeSubType type may be a currently
// possible object type.
if ($superType instanceof AbstractTypeInterface &&
$maybeSubtype instanceof ObjectType &&
$schema->isPossibleType($superType, $maybeSubtype)) {
return true;
}
// Otherwise, the child type is not a valid subtype of the parent type.
return false;
} | [
"public",
"static",
"function",
"isTypeSubtypeOf",
"(",
"Schema",
"$",
"schema",
",",
"TypeInterface",
"$",
"maybeSubtype",
",",
"TypeInterface",
"$",
"superType",
")",
":",
"bool",
"{",
"// Equivalent type is a valid subtype.",
"if",
"(",
"$",
"maybeSubtype",
"==="... | Provided a type and a super type, return true if the first type is either
equal or a subset of the second super type (covariant).
@param Schema $schema
@param TypeInterface $maybeSubtype
@param TypeInterface $superType
@return bool
@throws InvariantException | [
"Provided",
"a",
"type",
"and",
"a",
"super",
"type",
"return",
"true",
"if",
"the",
"first",
"type",
"is",
"either",
"equal",
"or",
"a",
"subset",
"of",
"the",
"second",
"super",
"type",
"(",
"covariant",
")",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/TypeHelper.php#L56-L102 |
digiaonline/graphql-php | src/Util/TypeHelper.php | TypeHelper.doTypesOverlap | public static function doTypesOverlap(Schema $schema, TypeInterface $typeA, TypeInterface $typeB): bool
{
// Equivalent types overlap
if ($typeA === $typeB) {
return true;
}
if ($typeA instanceof AbstractTypeInterface) {
if ($typeB instanceof AbstractTypeInterface) {
// If both types are abstract, then determine if there is any intersection
// between possible concrete types of each.
return arraySome($schema->getPossibleTypes($typeA),
function (NamedTypeInterface $type) use ($schema, $typeB) {
return $schema->isPossibleType($typeB, $type);
});
}
// Determine if the latter type is a possible concrete type of the former.
/** @noinspection PhpParamsInspection */
return $schema->isPossibleType($typeA, $typeB);
}
if ($typeB instanceof AbstractTypeInterface) {
// Determine if the former type is a possible concrete type of the latter.
/** @noinspection PhpParamsInspection */
return $schema->isPossibleType($typeB, $typeA);
}
// Otherwise the types do not overlap.
return false;
} | php | public static function doTypesOverlap(Schema $schema, TypeInterface $typeA, TypeInterface $typeB): bool
{
// Equivalent types overlap
if ($typeA === $typeB) {
return true;
}
if ($typeA instanceof AbstractTypeInterface) {
if ($typeB instanceof AbstractTypeInterface) {
// If both types are abstract, then determine if there is any intersection
// between possible concrete types of each.
return arraySome($schema->getPossibleTypes($typeA),
function (NamedTypeInterface $type) use ($schema, $typeB) {
return $schema->isPossibleType($typeB, $type);
});
}
// Determine if the latter type is a possible concrete type of the former.
/** @noinspection PhpParamsInspection */
return $schema->isPossibleType($typeA, $typeB);
}
if ($typeB instanceof AbstractTypeInterface) {
// Determine if the former type is a possible concrete type of the latter.
/** @noinspection PhpParamsInspection */
return $schema->isPossibleType($typeB, $typeA);
}
// Otherwise the types do not overlap.
return false;
} | [
"public",
"static",
"function",
"doTypesOverlap",
"(",
"Schema",
"$",
"schema",
",",
"TypeInterface",
"$",
"typeA",
",",
"TypeInterface",
"$",
"typeB",
")",
":",
"bool",
"{",
"// Equivalent types overlap",
"if",
"(",
"$",
"typeA",
"===",
"$",
"typeB",
")",
"... | Provided two composite types, determine if they "overlap". Two composite
types overlap when the Sets of possible concrete types for each intersect.
This is often used to determine if a fragment of a given type could possibly
be visited in a context of another type.
@param Schema $schema
@param TypeInterface $typeA
@param TypeInterface $typeB
@return bool
@throws InvariantException | [
"Provided",
"two",
"composite",
"types",
"determine",
"if",
"they",
"overlap",
".",
"Two",
"composite",
"types",
"overlap",
"when",
"the",
"Sets",
"of",
"possible",
"concrete",
"types",
"for",
"each",
"intersect",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/TypeHelper.php#L118-L148 |
digiaonline/graphql-php | src/Util/TypeHelper.php | TypeHelper.compareTypes | public static function compareTypes(TypeInterface $typeA, TypeInterface $typeB): bool
{
if ($typeA instanceof ListType) {
return $typeB instanceof ListType
? self::compareTypes($typeA->getOfType(), $typeB->getOfType())
: true;
}
if ($typeB instanceof ListType) {
return true;
}
if ($typeA instanceof NonNullType) {
return $typeB instanceof NonNullType
? self::compareTypes($typeA->getOfType(), $typeB->getOfType())
: true;
}
if ($typeB instanceof NonNullType) {
return true;
}
if ($typeA instanceof LeafTypeInterface || $typeB instanceof LeafTypeInterface) {
return $typeA !== $typeB;
}
return false;
} | php | public static function compareTypes(TypeInterface $typeA, TypeInterface $typeB): bool
{
if ($typeA instanceof ListType) {
return $typeB instanceof ListType
? self::compareTypes($typeA->getOfType(), $typeB->getOfType())
: true;
}
if ($typeB instanceof ListType) {
return true;
}
if ($typeA instanceof NonNullType) {
return $typeB instanceof NonNullType
? self::compareTypes($typeA->getOfType(), $typeB->getOfType())
: true;
}
if ($typeB instanceof NonNullType) {
return true;
}
if ($typeA instanceof LeafTypeInterface || $typeB instanceof LeafTypeInterface) {
return $typeA !== $typeB;
}
return false;
} | [
"public",
"static",
"function",
"compareTypes",
"(",
"TypeInterface",
"$",
"typeA",
",",
"TypeInterface",
"$",
"typeB",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"typeA",
"instanceof",
"ListType",
")",
"{",
"return",
"$",
"typeB",
"instanceof",
"ListType",
"?",... | Two types conflict if both types could not apply to a value simultaneously.
Composite types are ignored as their individual field types will be compared
later recursively. However List and Non-Null types must match.
@param TypeInterface $typeA
@param TypeInterface $typeB
@return bool | [
"Two",
"types",
"conflict",
"if",
"both",
"types",
"could",
"not",
"apply",
"to",
"a",
"value",
"simultaneously",
".",
"Composite",
"types",
"are",
"ignored",
"as",
"their",
"individual",
"field",
"types",
"will",
"be",
"compared",
"later",
"recursively",
".",... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/TypeHelper.php#L159-L181 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.readToken | protected function readToken(Token $prev): Token
{
$this->position = $prev->getEnd();
$this->skipWhitespace();
$line = $this->line;
$column = (1 + $this->position) - $this->lineStart;
if ($this->position >= $this->bodyLength) {
return $this->createEndOfFileToken($line, $column, $prev);
}
$code = $this->readCharCode($this->position);
// Punctuation: [!$&:=@|()\[\]{}]{1}
if (33 === $code || 36 === $code || 38 === $code || 58 === $code || 61 === $code || 64 === $code || 124 === $code ||
40 === $code || 41 === $code || 91 === $code || 93 === $code || 123 === $code || 125 === $code) {
return $this->lexPunctuation($code, $line, $column, $prev);
}
// Comment: #[\u0009\u0020-\uFFFF]*
if (35 === $code) {
return $this->lexComment($line, $column, $prev);
}
// Int: -?(0|[1-9][0-9]*)
// Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
if (45 === $code || isNumber($code)) {
return $this->lexNumber($code, $line, $column, $prev);
}
// Name: [_A-Za-z][_0-9A-Za-z]*
if (isAlphaNumeric($code)) {
return $this->lexName($line, $column, $prev);
}
// Spread: ...
if ($this->bodyLength >= 3 && $this->isSpread($code)) {
return $this->lexSpread($line, $column, $prev);
}
// String: "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
if ($this->isString($code)) {
return $this->lexString($line, $column, $prev);
}
// Block String: """("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
if ($this->bodyLength >= 3 && $this->isTripleQuote($code)) {
return $this->lexBlockString($line, $column, $prev);
}
throw $this->createSyntaxErrorException();
} | php | protected function readToken(Token $prev): Token
{
$this->position = $prev->getEnd();
$this->skipWhitespace();
$line = $this->line;
$column = (1 + $this->position) - $this->lineStart;
if ($this->position >= $this->bodyLength) {
return $this->createEndOfFileToken($line, $column, $prev);
}
$code = $this->readCharCode($this->position);
// Punctuation: [!$&:=@|()\[\]{}]{1}
if (33 === $code || 36 === $code || 38 === $code || 58 === $code || 61 === $code || 64 === $code || 124 === $code ||
40 === $code || 41 === $code || 91 === $code || 93 === $code || 123 === $code || 125 === $code) {
return $this->lexPunctuation($code, $line, $column, $prev);
}
// Comment: #[\u0009\u0020-\uFFFF]*
if (35 === $code) {
return $this->lexComment($line, $column, $prev);
}
// Int: -?(0|[1-9][0-9]*)
// Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
if (45 === $code || isNumber($code)) {
return $this->lexNumber($code, $line, $column, $prev);
}
// Name: [_A-Za-z][_0-9A-Za-z]*
if (isAlphaNumeric($code)) {
return $this->lexName($line, $column, $prev);
}
// Spread: ...
if ($this->bodyLength >= 3 && $this->isSpread($code)) {
return $this->lexSpread($line, $column, $prev);
}
// String: "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
if ($this->isString($code)) {
return $this->lexString($line, $column, $prev);
}
// Block String: """("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
if ($this->bodyLength >= 3 && $this->isTripleQuote($code)) {
return $this->lexBlockString($line, $column, $prev);
}
throw $this->createSyntaxErrorException();
} | [
"protected",
"function",
"readToken",
"(",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"this",
"->",
"position",
"=",
"$",
"prev",
"->",
"getEnd",
"(",
")",
";",
"$",
"this",
"->",
"skipWhitespace",
"(",
")",
";",
"$",
"line",
"=",
"$",
"thi... | Reads the token after the given token.
@param Token $prev
@return Token
@throws SyntaxErrorException | [
"Reads",
"the",
"token",
"after",
"the",
"given",
"token",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L206-L259 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.createEndOfFileToken | protected function createEndOfFileToken(int $line, int $column, Token $prev): Token
{
return new Token(TokenKindEnum::EOF, $this->bodyLength, $this->bodyLength, $line, $column, $prev);
} | php | protected function createEndOfFileToken(int $line, int $column, Token $prev): Token
{
return new Token(TokenKindEnum::EOF, $this->bodyLength, $this->bodyLength, $line, $column, $prev);
} | [
"protected",
"function",
"createEndOfFileToken",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"return",
"new",
"Token",
"(",
"TokenKindEnum",
"::",
"EOF",
",",
"$",
"this",
"->",
"bodyLength",
","... | Creates an End Of File (EOF) token.
@param int $line
@param int $column
@param Token $prev
@return Token | [
"Creates",
"an",
"End",
"Of",
"File",
"(",
"EOF",
")",
"token",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L277-L280 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexPunctuation | protected function lexPunctuation(int $code, int $line, int $column, Token $prev): ?Token
{
if (!isset(self::$codeTokenKindMap[$code])) {
throw $this->createSyntaxErrorException();
}
return new Token(self::$codeTokenKindMap[$code], $this->position, $this->position + 1, $line, $column, $prev);
} | php | protected function lexPunctuation(int $code, int $line, int $column, Token $prev): ?Token
{
if (!isset(self::$codeTokenKindMap[$code])) {
throw $this->createSyntaxErrorException();
}
return new Token(self::$codeTokenKindMap[$code], $this->position, $this->position + 1, $line, $column, $prev);
} | [
"protected",
"function",
"lexPunctuation",
"(",
"int",
"$",
"code",
",",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"?",
"Token",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"codeTokenKindMap",
"[",
... | Reads a punctuation token from the source file.
@param int $code
@param int $line
@param int $column
@param Token $prev
@return Token
@throws SyntaxErrorException | [
"Reads",
"a",
"punctuation",
"token",
"from",
"the",
"source",
"file",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L292-L299 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexName | protected function lexName(int $line, int $column, Token $prev): Token
{
$start = $this->position;
++$this->position;
while ($this->position !== $this->bodyLength &&
($code = $this->readCharCode($this->position)) !== 0 &&
isAlphaNumeric($code)) {
++$this->position;
}
$value = sliceString($this->body, $start, $this->position);
return new Token(TokenKindEnum::NAME, $start, $this->position, $line, $column, $prev, $value);
} | php | protected function lexName(int $line, int $column, Token $prev): Token
{
$start = $this->position;
++$this->position;
while ($this->position !== $this->bodyLength &&
($code = $this->readCharCode($this->position)) !== 0 &&
isAlphaNumeric($code)) {
++$this->position;
}
$value = sliceString($this->body, $start, $this->position);
return new Token(TokenKindEnum::NAME, $start, $this->position, $line, $column, $prev, $value);
} | [
"protected",
"function",
"lexName",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"position",
";",
"++",
"$",
"this",
"->",
"position",
";",
"while",
"("... | Reads a name token from the source file.
@param int $line
@param int $column
@param Token $prev
@return Token | [
"Reads",
"a",
"name",
"token",
"from",
"the",
"source",
"file",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L309-L324 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexNumber | protected function lexNumber(int $code, int $line, int $column, Token $prev): Token
{
$start = $this->position;
$isFloat = false;
if (45 === $code) {
// -
$code = $this->readCharCode(++$this->position);
}
if (48 === $code) {
// 0
$code = $this->readCharCode(++$this->position);
if (isNumber($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid number, unexpected digit after 0: %s.', printCharCode($code))
);
}
} else {
$this->skipDigits($code);
$code = $this->readCharCode($this->position);
}
if (46 === $code) {
// .
$isFloat = true;
$code = $this->readCharCode(++$this->position);
$this->skipDigits($code);
$code = $this->readCharCode($this->position);
}
if (69 === $code || 101 === $code) {
// e or E
$isFloat = true;
$code = $this->readCharCode(++$this->position);
if (43 === $code || 45 === $code) {
// + or -
$code = $this->readCharCode(++$this->position);
}
$this->skipDigits($code);
}
return new Token(
$isFloat ? TokenKindEnum::FLOAT : TokenKindEnum::INT,
$start,
$this->position,
$line,
$column,
$prev,
sliceString($this->body, $start, $this->position)
);
} | php | protected function lexNumber(int $code, int $line, int $column, Token $prev): Token
{
$start = $this->position;
$isFloat = false;
if (45 === $code) {
// -
$code = $this->readCharCode(++$this->position);
}
if (48 === $code) {
// 0
$code = $this->readCharCode(++$this->position);
if (isNumber($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid number, unexpected digit after 0: %s.', printCharCode($code))
);
}
} else {
$this->skipDigits($code);
$code = $this->readCharCode($this->position);
}
if (46 === $code) {
// .
$isFloat = true;
$code = $this->readCharCode(++$this->position);
$this->skipDigits($code);
$code = $this->readCharCode($this->position);
}
if (69 === $code || 101 === $code) {
// e or E
$isFloat = true;
$code = $this->readCharCode(++$this->position);
if (43 === $code || 45 === $code) {
// + or -
$code = $this->readCharCode(++$this->position);
}
$this->skipDigits($code);
}
return new Token(
$isFloat ? TokenKindEnum::FLOAT : TokenKindEnum::INT,
$start,
$this->position,
$line,
$column,
$prev,
sliceString($this->body, $start, $this->position)
);
} | [
"protected",
"function",
"lexNumber",
"(",
"int",
"$",
"code",
",",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"position",
";",
"$",
"isFloat",
"=",
"false... | Reads a number (int or float) token from the source file.
@param int $code
@param int $line
@param int $column
@param Token $prev
@return Token
@throws SyntaxErrorException | [
"Reads",
"a",
"number",
"(",
"int",
"or",
"float",
")",
"token",
"from",
"the",
"source",
"file",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L336-L392 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.skipDigits | protected function skipDigits(int $code): void
{
if (isNumber($code)) {
do {
$code = $this->readCharCode(++$this->position);
} while (isNumber($code));
return;
}
throw $this->createSyntaxErrorException(
\sprintf('Invalid number, expected digit but got: %s.', printCharCode($code))
);
} | php | protected function skipDigits(int $code): void
{
if (isNumber($code)) {
do {
$code = $this->readCharCode(++$this->position);
} while (isNumber($code));
return;
}
throw $this->createSyntaxErrorException(
\sprintf('Invalid number, expected digit but got: %s.', printCharCode($code))
);
} | [
"protected",
"function",
"skipDigits",
"(",
"int",
"$",
"code",
")",
":",
"void",
"{",
"if",
"(",
"isNumber",
"(",
"$",
"code",
")",
")",
"{",
"do",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"readCharCode",
"(",
"++",
"$",
"this",
"->",
"position",... | Skips digits at the current position.
@param int $code
@throws SyntaxErrorException | [
"Skips",
"digits",
"at",
"the",
"current",
"position",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L400-L413 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexComment | protected function lexComment(int $line, int $column, Token $prev): Token
{
$start = $this->position;
do {
$code = $this->readCharCode(++$this->position);
} while ($code !== 0 && ($code > 0x001f || 0x0009 === $code)); // SourceCharacter but not LineTerminator
return new Token(
TokenKindEnum::COMMENT,
$start,
$this->position,
$line,
$column,
$prev,
sliceString($this->body, $start + 1, $this->position)
);
} | php | protected function lexComment(int $line, int $column, Token $prev): Token
{
$start = $this->position;
do {
$code = $this->readCharCode(++$this->position);
} while ($code !== 0 && ($code > 0x001f || 0x0009 === $code)); // SourceCharacter but not LineTerminator
return new Token(
TokenKindEnum::COMMENT,
$start,
$this->position,
$line,
$column,
$prev,
sliceString($this->body, $start + 1, $this->position)
);
} | [
"protected",
"function",
"lexComment",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"position",
";",
"do",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"... | Reads a comment token from the source file.
@param int $line
@param int $column
@param Token $prev
@return Token | [
"Reads",
"a",
"comment",
"token",
"from",
"the",
"source",
"file",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L423-L440 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexSpread | protected function lexSpread(int $line, int $column, Token $prev): Token
{
return new Token(TokenKindEnum::SPREAD, $this->position, $this->position + 3, $line, $column, $prev);
} | php | protected function lexSpread(int $line, int $column, Token $prev): Token
{
return new Token(TokenKindEnum::SPREAD, $this->position, $this->position + 3, $line, $column, $prev);
} | [
"protected",
"function",
"lexSpread",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"return",
"new",
"Token",
"(",
"TokenKindEnum",
"::",
"SPREAD",
",",
"$",
"this",
"->",
"position",
",",
"$",
... | Reads a spread token from the source.
@param int $line
@param int $column
@param Token $prev
@return Token | [
"Reads",
"a",
"spread",
"token",
"from",
"the",
"source",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L450-L453 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexString | protected function lexString(int $line, int $column, Token $prev): Token
{
$start = $this->position;
$chunkStart = ++$this->position; // skip the quote
$value = '';
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
if (isLineTerminator($code)) {
break;
}
// Closing Quote (")
if (34 === $code) {
$value .= sliceString($this->body, $chunkStart, $this->position);
return new Token(TokenKindEnum::STRING, $start, $this->position + 1, $line, $column, $prev, $value);
}
if (isSourceCharacter($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character within String: %s.', printCharCode($code))
);
}
++$this->position;
if (92 === $code) {
// \
$value .= sliceString($this->body, $chunkStart, $this->position - 1);
$code = $this->readCharCode($this->position);
switch ($code) {
case 34: // "
$value .= '"';
break;
case 47: // /
$value .= '/';
break;
case 92: // \
$value .= '\\';
break;
case 98: // b
$value .= '\b';
break;
case 102: // f
$value .= '\f';
break;
case 110: // n
$value .= '\n';
break;
case 114: // r
$value .= '\r';
break;
case 116: // t
$value .= '\t';
break;
case 117: // u
$unicodeString = sliceString($this->body, $this->position + 1, $this->position + 5);
if (!\preg_match('/[0-9A-Fa-f]{4}/', $unicodeString)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character escape sequence: \\u%s.', $unicodeString)
);
}
$value .= '\\u' . $unicodeString;
$this->position += 4;
break;
default:
throw $this->createSyntaxErrorException(
\sprintf('Invalid character escape sequence: \\%s.', \chr($code))
);
}
++$this->position;
$chunkStart = $this->position;
}
}
throw $this->createSyntaxErrorException('Unterminated string.');
} | php | protected function lexString(int $line, int $column, Token $prev): Token
{
$start = $this->position;
$chunkStart = ++$this->position; // skip the quote
$value = '';
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
if (isLineTerminator($code)) {
break;
}
// Closing Quote (")
if (34 === $code) {
$value .= sliceString($this->body, $chunkStart, $this->position);
return new Token(TokenKindEnum::STRING, $start, $this->position + 1, $line, $column, $prev, $value);
}
if (isSourceCharacter($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character within String: %s.', printCharCode($code))
);
}
++$this->position;
if (92 === $code) {
// \
$value .= sliceString($this->body, $chunkStart, $this->position - 1);
$code = $this->readCharCode($this->position);
switch ($code) {
case 34: // "
$value .= '"';
break;
case 47: // /
$value .= '/';
break;
case 92: // \
$value .= '\\';
break;
case 98: // b
$value .= '\b';
break;
case 102: // f
$value .= '\f';
break;
case 110: // n
$value .= '\n';
break;
case 114: // r
$value .= '\r';
break;
case 116: // t
$value .= '\t';
break;
case 117: // u
$unicodeString = sliceString($this->body, $this->position + 1, $this->position + 5);
if (!\preg_match('/[0-9A-Fa-f]{4}/', $unicodeString)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character escape sequence: \\u%s.', $unicodeString)
);
}
$value .= '\\u' . $unicodeString;
$this->position += 4;
break;
default:
throw $this->createSyntaxErrorException(
\sprintf('Invalid character escape sequence: \\%s.', \chr($code))
);
}
++$this->position;
$chunkStart = $this->position;
}
}
throw $this->createSyntaxErrorException('Unterminated string.');
} | [
"protected",
"function",
"lexString",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"position",
";",
"$",
"chunkStart",
"=",
"++",
"$",
"this",
"->",
"po... | Reads a string token from the source.
@param int $line
@param int $column
@param Token $prev
@return Token
@throws SyntaxErrorException | [
"Reads",
"a",
"string",
"token",
"from",
"the",
"source",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L464-L549 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.lexBlockString | protected function lexBlockString(int $line, int $column, Token $prev): Token
{
$start = $this->position;
$this->position = $start + 3; // skip the triple-quote
$chunkStart = $this->position;
$rawValue = '';
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
// Closing Triple-Quote (""")
if ($this->isTripleQuote($code)) {
$rawValue .= sliceString($this->body, $chunkStart, $this->position);
return new Token(
TokenKindEnum::BLOCK_STRING,
$start,
$this->position + 3,
$line,
$column,
$prev,
blockStringValue($rawValue)
);
}
if (isSourceCharacter($code) && !isLineTerminator($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character within String: %s.', printCharCode($code))
);
}
if ($this->isEscapedTripleQuote($code)) {
$rawValue .= sliceString($this->body, $chunkStart, $this->position) . '"""';
$this->position += 4;
$chunkStart = $this->position;
} else {
++$this->position;
}
}
throw $this->createSyntaxErrorException('Unterminated string.');
} | php | protected function lexBlockString(int $line, int $column, Token $prev): Token
{
$start = $this->position;
$this->position = $start + 3; // skip the triple-quote
$chunkStart = $this->position;
$rawValue = '';
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
// Closing Triple-Quote (""")
if ($this->isTripleQuote($code)) {
$rawValue .= sliceString($this->body, $chunkStart, $this->position);
return new Token(
TokenKindEnum::BLOCK_STRING,
$start,
$this->position + 3,
$line,
$column,
$prev,
blockStringValue($rawValue)
);
}
if (isSourceCharacter($code) && !isLineTerminator($code)) {
throw $this->createSyntaxErrorException(
\sprintf('Invalid character within String: %s.', printCharCode($code))
);
}
if ($this->isEscapedTripleQuote($code)) {
$rawValue .= sliceString($this->body, $chunkStart, $this->position) . '"""';
$this->position += 4;
$chunkStart = $this->position;
} else {
++$this->position;
}
}
throw $this->createSyntaxErrorException('Unterminated string.');
} | [
"protected",
"function",
"lexBlockString",
"(",
"int",
"$",
"line",
",",
"int",
"$",
"column",
",",
"Token",
"$",
"prev",
")",
":",
"Token",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"position",
";",
"$",
"this",
"->",
"position",
"=",
"$",
"start",... | Reads a block string token from the source file.
@param int $line
@param int $column
@param Token $prev
@return Token
@throws SyntaxErrorException | [
"Reads",
"a",
"block",
"string",
"token",
"from",
"the",
"source",
"file",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L560-L600 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.skipWhitespace | protected function skipWhitespace(): void
{
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
if (9 === $code || 32 === $code || 44 === $code || 0xfeff === $code) {
// tab | space | comma | BOM
++$this->position;
} elseif (10 === $code) {
// new line (\n)
++$this->position;
++$this->line;
$this->lineStart = $this->position;
} elseif (13 === $code) {
// carriage return (\r)
if (10 === $this->readCharCode($this->position + 1)) {
// carriage return and new line (\r\n)
$this->position += 2;
} else {
++$this->position;
}
++$this->line;
$this->lineStart = $this->position;
} else {
break;
}
}
} | php | protected function skipWhitespace(): void
{
while ($this->position < $this->bodyLength) {
$code = $this->readCharCode($this->position);
if (9 === $code || 32 === $code || 44 === $code || 0xfeff === $code) {
// tab | space | comma | BOM
++$this->position;
} elseif (10 === $code) {
// new line (\n)
++$this->position;
++$this->line;
$this->lineStart = $this->position;
} elseif (13 === $code) {
// carriage return (\r)
if (10 === $this->readCharCode($this->position + 1)) {
// carriage return and new line (\r\n)
$this->position += 2;
} else {
++$this->position;
}
++$this->line;
$this->lineStart = $this->position;
} else {
break;
}
}
} | [
"protected",
"function",
"skipWhitespace",
"(",
")",
":",
"void",
"{",
"while",
"(",
"$",
"this",
"->",
"position",
"<",
"$",
"this",
"->",
"bodyLength",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"readCharCode",
"(",
"$",
"this",
"->",
"position",... | Skips whitespace at the current position. | [
"Skips",
"whitespace",
"at",
"the",
"current",
"position",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L605-L632 |
digiaonline/graphql-php | src/Language/Lexer.php | Lexer.unexpectedCharacterMessage | protected function unexpectedCharacterMessage(int $code): string
{
if (isSourceCharacter($code) && !isLineTerminator($code)) {
return \sprintf('Cannot contain the invalid character %s.', printCharCode($code));
}
if ($code === 39) {
// '
return 'Unexpected single quote character (\'), did you mean to use a double quote (")?';
}
return \sprintf('Cannot parse the unexpected character %s.', printCharCode($code));
} | php | protected function unexpectedCharacterMessage(int $code): string
{
if (isSourceCharacter($code) && !isLineTerminator($code)) {
return \sprintf('Cannot contain the invalid character %s.', printCharCode($code));
}
if ($code === 39) {
// '
return 'Unexpected single quote character (\'), did you mean to use a double quote (")?';
}
return \sprintf('Cannot parse the unexpected character %s.', printCharCode($code));
} | [
"protected",
"function",
"unexpectedCharacterMessage",
"(",
"int",
"$",
"code",
")",
":",
"string",
"{",
"if",
"(",
"isSourceCharacter",
"(",
"$",
"code",
")",
"&&",
"!",
"isLineTerminator",
"(",
"$",
"code",
")",
")",
"{",
"return",
"\\",
"sprintf",
"(",
... | Report a message that an unexpected character was encountered.
@param int $code
@return string | [
"Report",
"a",
"message",
"that",
"an",
"unexpected",
"character",
"was",
"encountered",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Lexer.php#L665-L677 |
digiaonline/graphql-php | src/Language/FileSourceBuilder.php | FileSourceBuilder.build | public function build(): Source
{
if (!\file_exists($this->filePath) || !\is_readable($this->filePath)) {
throw new FileNotFoundException(sprintf('The file %s cannot be found or is not readable', $this->filePath));
}
return new Source(\file_get_contents($this->filePath));
} | php | public function build(): Source
{
if (!\file_exists($this->filePath) || !\is_readable($this->filePath)) {
throw new FileNotFoundException(sprintf('The file %s cannot be found or is not readable', $this->filePath));
}
return new Source(\file_get_contents($this->filePath));
} | [
"public",
"function",
"build",
"(",
")",
":",
"Source",
"{",
"if",
"(",
"!",
"\\",
"file_exists",
"(",
"$",
"this",
"->",
"filePath",
")",
"||",
"!",
"\\",
"is_readable",
"(",
"$",
"this",
"->",
"filePath",
")",
")",
"{",
"throw",
"new",
"FileNotFoun... | @inheritdoc
@throws FileNotFoundException
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/FileSourceBuilder.php#L34-L41 |
digiaonline/graphql-php | src/Validation/Rule/PossibleFragmentSpreadsRule.php | PossibleFragmentSpreadsRule.enterInlineFragment | protected function enterInlineFragment(InlineFragmentNode $node): VisitorResult
{
$fragmentType = $this->context->getType();
$parentType = $this->context->getParentType();
if ($fragmentType instanceof CompositeTypeInterface &&
$parentType instanceof CompositeTypeInterface &&
!TypeHelper::doTypesOverlap($this->context->getSchema(), $fragmentType, $parentType)
) {
$this->context->reportError(
new ValidationException(
typeIncompatibleAnonymousSpreadMessage((string)$parentType, (string)$fragmentType),
[$node]
)
);
}
return new VisitorResult($node);
} | php | protected function enterInlineFragment(InlineFragmentNode $node): VisitorResult
{
$fragmentType = $this->context->getType();
$parentType = $this->context->getParentType();
if ($fragmentType instanceof CompositeTypeInterface &&
$parentType instanceof CompositeTypeInterface &&
!TypeHelper::doTypesOverlap($this->context->getSchema(), $fragmentType, $parentType)
) {
$this->context->reportError(
new ValidationException(
typeIncompatibleAnonymousSpreadMessage((string)$parentType, (string)$fragmentType),
[$node]
)
);
}
return new VisitorResult($node);
} | [
"protected",
"function",
"enterInlineFragment",
"(",
"InlineFragmentNode",
"$",
"node",
")",
":",
"VisitorResult",
"{",
"$",
"fragmentType",
"=",
"$",
"this",
"->",
"context",
"->",
"getType",
"(",
")",
";",
"$",
"parentType",
"=",
"$",
"this",
"->",
"contex... | @inheritdoc
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/PossibleFragmentSpreadsRule.php#L32-L50 |
digiaonline/graphql-php | src/Validation/Rule/PossibleFragmentSpreadsRule.php | PossibleFragmentSpreadsRule.enterFragmentSpread | protected function enterFragmentSpread(FragmentSpreadNode $node): VisitorResult
{
$fragmentName = $node->getNameValue();
$fragmentType = $this->getFragmentType($fragmentName);
$parentType = $this->context->getParentType();
if (null !== $fragmentType &&
null !== $parentType &&
!TypeHelper::doTypesOverlap($this->context->getSchema(), $fragmentType, $parentType)
) {
$this->context->reportError(
new ValidationException(
typeIncompatibleSpreadMessage($fragmentName, (string)$parentType, (string)$fragmentType),
[$node]
)
);
}
return new VisitorResult($node);
} | php | protected function enterFragmentSpread(FragmentSpreadNode $node): VisitorResult
{
$fragmentName = $node->getNameValue();
$fragmentType = $this->getFragmentType($fragmentName);
$parentType = $this->context->getParentType();
if (null !== $fragmentType &&
null !== $parentType &&
!TypeHelper::doTypesOverlap($this->context->getSchema(), $fragmentType, $parentType)
) {
$this->context->reportError(
new ValidationException(
typeIncompatibleSpreadMessage($fragmentName, (string)$parentType, (string)$fragmentType),
[$node]
)
);
}
return new VisitorResult($node);
} | [
"protected",
"function",
"enterFragmentSpread",
"(",
"FragmentSpreadNode",
"$",
"node",
")",
":",
"VisitorResult",
"{",
"$",
"fragmentName",
"=",
"$",
"node",
"->",
"getNameValue",
"(",
")",
";",
"$",
"fragmentType",
"=",
"$",
"this",
"->",
"getFragmentType",
... | @inheritdoc
@throws InvariantException
@throws ConversionException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/PossibleFragmentSpreadsRule.php#L58-L77 |
digiaonline/graphql-php | src/Language/Visitor/TypeInfoVisitor.php | TypeInfoVisitor.enterNode | public function enterNode(NodeInterface $node): VisitorResult
{
$schema = $this->typeInfo->getSchema();
if ($node instanceof SelectionSetNode) {
$namedType = getNamedType($this->typeInfo->getType());
$this->typeInfo->pushParentType($namedType instanceof CompositeTypeInterface ? $namedType : null);
} elseif ($node instanceof FieldNode) {
$parentType = $this->typeInfo->getParentType();
$fieldDefinition = null;
$fieldType = null;
if (null !== $parentType) {
$fieldDefinition = $this->typeInfo->resolveFieldDefinition($schema, $parentType, $node);
if (null !== $fieldDefinition) {
$fieldType = $fieldDefinition->getType();
}
}
$this->typeInfo->pushFieldDefinition($fieldDefinition);
$this->typeInfo->pushType(isOutputType($fieldType) ? $fieldType : null);
} elseif ($node instanceof DirectiveNode) {
$this->typeInfo->setDirective($schema->getDirective($node->getNameValue()));
} elseif ($node instanceof OperationDefinitionNode) {
$type = null;
$operation = $node->getOperation();
if ($operation === 'query') {
$type = $schema->getQueryType();
} elseif ($operation === 'mutation') {
$type = $schema->getMutationType();
} elseif ($operation === 'subscription') {
$type = $schema->getSubscriptionType();
}
$this->typeInfo->pushType($type instanceof ObjectType ? $type : null);
} elseif ($node instanceof InlineFragmentNode || $node instanceof FragmentDefinitionNode) {
$typeCondition = $node->getTypeCondition();
$outputType = null !== $typeCondition
? TypeASTConverter::convert($schema, $typeCondition)
: getNamedType($this->typeInfo->getType());
$this->typeInfo->pushType(isOutputType($outputType) ? $outputType : null);
} elseif ($node instanceof VariableDefinitionNode) {
$inputType = TypeASTConverter::convert($schema, $node->getType());
/** @noinspection PhpParamsInspection */
$this->typeInfo->pushInputType(isInputType($inputType) ? $inputType : null);
} elseif ($node instanceof ArgumentNode) {
$argumentType = null;
$argumentDefinition = null;
$fieldOrDirective = $this->typeInfo->getDirective() ?: $this->typeInfo->getFieldDefinition();
if (null !== $fieldOrDirective) {
$argumentDefinition = find(
$fieldOrDirective->getArguments(),
function (Argument $argument) use ($node) {
return $argument->getName() === $node->getNameValue();
}
);
if (null !== $argumentDefinition) {
$argumentType = $argumentDefinition->getType();
}
}
$this->typeInfo->setArgument($argumentDefinition);
$this->typeInfo->pushInputType(isInputType($argumentType) ? $argumentType : null);
} elseif ($node instanceof ListValueNode) {
$listType = getNullableType($this->typeInfo->getInputType());
$itemType = $listType instanceof ListType ? $listType->getOfType() : $listType;
$this->typeInfo->pushInputType(isInputType($itemType) ? $itemType : null);
} elseif ($node instanceof ObjectFieldNode) {
$objectType = getNamedType($this->typeInfo->getInputType());
$inputFieldType = null;
if ($objectType instanceof InputObjectType) {
$fields = $objectType->getFields();
$inputField = $fields[$node->getNameValue()] ?? null;
if (null !== $inputField) {
$inputFieldType = $inputField->getType();
}
}
/** @noinspection PhpParamsInspection */
$this->typeInfo->pushInputType(isInputType($inputFieldType) ? $inputFieldType : null);
} elseif ($node instanceof EnumValueNode) {
$enumType = getNamedType($this->typeInfo->getInputType());
$enumValue = null;
if ($enumType instanceof EnumType) {
$enumValue = $enumType->getValue($node->getValue());
}
$this->typeInfo->setEnumValue($enumValue);
}
return $this->visitor->enterNode($node);
} | php | public function enterNode(NodeInterface $node): VisitorResult
{
$schema = $this->typeInfo->getSchema();
if ($node instanceof SelectionSetNode) {
$namedType = getNamedType($this->typeInfo->getType());
$this->typeInfo->pushParentType($namedType instanceof CompositeTypeInterface ? $namedType : null);
} elseif ($node instanceof FieldNode) {
$parentType = $this->typeInfo->getParentType();
$fieldDefinition = null;
$fieldType = null;
if (null !== $parentType) {
$fieldDefinition = $this->typeInfo->resolveFieldDefinition($schema, $parentType, $node);
if (null !== $fieldDefinition) {
$fieldType = $fieldDefinition->getType();
}
}
$this->typeInfo->pushFieldDefinition($fieldDefinition);
$this->typeInfo->pushType(isOutputType($fieldType) ? $fieldType : null);
} elseif ($node instanceof DirectiveNode) {
$this->typeInfo->setDirective($schema->getDirective($node->getNameValue()));
} elseif ($node instanceof OperationDefinitionNode) {
$type = null;
$operation = $node->getOperation();
if ($operation === 'query') {
$type = $schema->getQueryType();
} elseif ($operation === 'mutation') {
$type = $schema->getMutationType();
} elseif ($operation === 'subscription') {
$type = $schema->getSubscriptionType();
}
$this->typeInfo->pushType($type instanceof ObjectType ? $type : null);
} elseif ($node instanceof InlineFragmentNode || $node instanceof FragmentDefinitionNode) {
$typeCondition = $node->getTypeCondition();
$outputType = null !== $typeCondition
? TypeASTConverter::convert($schema, $typeCondition)
: getNamedType($this->typeInfo->getType());
$this->typeInfo->pushType(isOutputType($outputType) ? $outputType : null);
} elseif ($node instanceof VariableDefinitionNode) {
$inputType = TypeASTConverter::convert($schema, $node->getType());
/** @noinspection PhpParamsInspection */
$this->typeInfo->pushInputType(isInputType($inputType) ? $inputType : null);
} elseif ($node instanceof ArgumentNode) {
$argumentType = null;
$argumentDefinition = null;
$fieldOrDirective = $this->typeInfo->getDirective() ?: $this->typeInfo->getFieldDefinition();
if (null !== $fieldOrDirective) {
$argumentDefinition = find(
$fieldOrDirective->getArguments(),
function (Argument $argument) use ($node) {
return $argument->getName() === $node->getNameValue();
}
);
if (null !== $argumentDefinition) {
$argumentType = $argumentDefinition->getType();
}
}
$this->typeInfo->setArgument($argumentDefinition);
$this->typeInfo->pushInputType(isInputType($argumentType) ? $argumentType : null);
} elseif ($node instanceof ListValueNode) {
$listType = getNullableType($this->typeInfo->getInputType());
$itemType = $listType instanceof ListType ? $listType->getOfType() : $listType;
$this->typeInfo->pushInputType(isInputType($itemType) ? $itemType : null);
} elseif ($node instanceof ObjectFieldNode) {
$objectType = getNamedType($this->typeInfo->getInputType());
$inputFieldType = null;
if ($objectType instanceof InputObjectType) {
$fields = $objectType->getFields();
$inputField = $fields[$node->getNameValue()] ?? null;
if (null !== $inputField) {
$inputFieldType = $inputField->getType();
}
}
/** @noinspection PhpParamsInspection */
$this->typeInfo->pushInputType(isInputType($inputFieldType) ? $inputFieldType : null);
} elseif ($node instanceof EnumValueNode) {
$enumType = getNamedType($this->typeInfo->getInputType());
$enumValue = null;
if ($enumType instanceof EnumType) {
$enumValue = $enumType->getValue($node->getValue());
}
$this->typeInfo->setEnumValue($enumValue);
}
return $this->visitor->enterNode($node);
} | [
"public",
"function",
"enterNode",
"(",
"NodeInterface",
"$",
"node",
")",
":",
"VisitorResult",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"typeInfo",
"->",
"getSchema",
"(",
")",
";",
"if",
"(",
"$",
"node",
"instanceof",
"SelectionSetNode",
")",
"{",
... | @inheritdoc
@throws ConversionException
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Visitor/TypeInfoVisitor.php#L62-L147 |
digiaonline/graphql-php | src/Validation/Rule/VariablesAreInputTypesRule.php | VariablesAreInputTypesRule.enterVariableDefinition | protected function enterVariableDefinition(VariableDefinitionNode $node): VisitorResult
{
$type = TypeASTConverter::convert($this->context->getSchema(), $node->getType());
if (!isInputType($type)) {
$variableName = $node->getVariable()->getNameValue();
$this->context->reportError(
new ValidationException(
nonInputTypeOnVariableMessage($variableName, printNode($node->getType())),
[$node->getType()]
)
);
}
return new VisitorResult($node);
} | php | protected function enterVariableDefinition(VariableDefinitionNode $node): VisitorResult
{
$type = TypeASTConverter::convert($this->context->getSchema(), $node->getType());
if (!isInputType($type)) {
$variableName = $node->getVariable()->getNameValue();
$this->context->reportError(
new ValidationException(
nonInputTypeOnVariableMessage($variableName, printNode($node->getType())),
[$node->getType()]
)
);
}
return new VisitorResult($node);
} | [
"protected",
"function",
"enterVariableDefinition",
"(",
"VariableDefinitionNode",
"$",
"node",
")",
":",
"VisitorResult",
"{",
"$",
"type",
"=",
"TypeASTConverter",
"::",
"convert",
"(",
"$",
"this",
"->",
"context",
"->",
"getSchema",
"(",
")",
",",
"$",
"no... | @inheritdoc
@throws ConversionException
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/VariablesAreInputTypesRule.php#L29-L45 |
digiaonline/graphql-php | src/Validation/Rule/NoFragmentCyclesRule.php | NoFragmentCyclesRule.detectFragmentCycle | protected function detectFragmentCycle(FragmentDefinitionNode $fragment): void
{
$fragmentName = $fragment->getNameValue();
$this->visitedFragments[$fragmentName] = true;
$spreadNodes = $this->context->getFragmentSpreads($fragment->getSelectionSet());
if (empty($spreadNodes)) {
return;
}
$this->spreadPathIndexByName[$fragmentName] = \count($this->spreadPath);
foreach ($spreadNodes as $spreadNode) {
$spreadName = $spreadNode->getNameValue();
$cycleIndex = $this->spreadPathIndexByName[$spreadName] ?? null;
if (null === $cycleIndex) {
$this->spreadPath[] = $spreadNode;
if (!isset($this->visitedFragments[$spreadName])) {
$spreadFragment = $this->context->getFragment($spreadName);
if (null !== $spreadFragment) {
$this->detectFragmentCycle($spreadFragment);
}
}
\array_pop($this->spreadPath);
} else {
$cyclePath = \array_slice($this->spreadPath, $cycleIndex);
$this->context->reportError(
new ValidationException(
fragmentCycleMessage($spreadName, \array_map(function (FragmentSpreadNode $spread) {
return $spread->getNameValue();
}, $cyclePath)),
\array_merge($cyclePath, [$spreadNode])
)
);
}
}
$this->spreadPathIndexByName[$fragmentName] = null;
} | php | protected function detectFragmentCycle(FragmentDefinitionNode $fragment): void
{
$fragmentName = $fragment->getNameValue();
$this->visitedFragments[$fragmentName] = true;
$spreadNodes = $this->context->getFragmentSpreads($fragment->getSelectionSet());
if (empty($spreadNodes)) {
return;
}
$this->spreadPathIndexByName[$fragmentName] = \count($this->spreadPath);
foreach ($spreadNodes as $spreadNode) {
$spreadName = $spreadNode->getNameValue();
$cycleIndex = $this->spreadPathIndexByName[$spreadName] ?? null;
if (null === $cycleIndex) {
$this->spreadPath[] = $spreadNode;
if (!isset($this->visitedFragments[$spreadName])) {
$spreadFragment = $this->context->getFragment($spreadName);
if (null !== $spreadFragment) {
$this->detectFragmentCycle($spreadFragment);
}
}
\array_pop($this->spreadPath);
} else {
$cyclePath = \array_slice($this->spreadPath, $cycleIndex);
$this->context->reportError(
new ValidationException(
fragmentCycleMessage($spreadName, \array_map(function (FragmentSpreadNode $spread) {
return $spread->getNameValue();
}, $cyclePath)),
\array_merge($cyclePath, [$spreadNode])
)
);
}
}
$this->spreadPathIndexByName[$fragmentName] = null;
} | [
"protected",
"function",
"detectFragmentCycle",
"(",
"FragmentDefinitionNode",
"$",
"fragment",
")",
":",
"void",
"{",
"$",
"fragmentName",
"=",
"$",
"fragment",
"->",
"getNameValue",
"(",
")",
";",
"$",
"this",
"->",
"visitedFragments",
"[",
"$",
"fragmentName"... | This does a straight-forward DFS to find cycles.
It does not terminate when a cycle was found but continues to explore
the graph to find all possible cycles.
@param FragmentDefinitionNode $fragment | [
"This",
"does",
"a",
"straight",
"-",
"forward",
"DFS",
"to",
"find",
"cycles",
".",
"It",
"does",
"not",
"terminate",
"when",
"a",
"cycle",
"was",
"found",
"but",
"continues",
"to",
"explore",
"the",
"graph",
"to",
"find",
"all",
"possible",
"cycles",
"... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/NoFragmentCyclesRule.php#L69-L114 |
digiaonline/graphql-php | src/Util/NameHelper.php | NameHelper.isValidError | public static function isValidError(string $name, $node = null): ?ValidationException
{
if (\strlen($name) > 1 && $name{0} === '_' && $name{1} === '_') {
return new ValidationException(
sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.', $name),
$node instanceof NodeInterface ? [$node] : null
);
}
if (preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*$/", $name) === 0) {
return new ValidationException(
sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name),
$node instanceof NodeInterface ? [$node] : null
);
}
return null;
} | php | public static function isValidError(string $name, $node = null): ?ValidationException
{
if (\strlen($name) > 1 && $name{0} === '_' && $name{1} === '_') {
return new ValidationException(
sprintf('Name "%s" must not begin with "__", which is reserved by GraphQL introspection.', $name),
$node instanceof NodeInterface ? [$node] : null
);
}
if (preg_match("/^[_a-zA-Z][_a-zA-Z0-9]*$/", $name) === 0) {
return new ValidationException(
sprintf('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "%s" does not.', $name),
$node instanceof NodeInterface ? [$node] : null
);
}
return null;
} | [
"public",
"static",
"function",
"isValidError",
"(",
"string",
"$",
"name",
",",
"$",
"node",
"=",
"null",
")",
":",
"?",
"ValidationException",
"{",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"name",
")",
">",
"1",
"&&",
"$",
"name",
"{",
"0",
"}",
"===... | Returns an Error if a name is invalid.
@param string $name
@param mixed|null $node
@return ValidationException | [
"Returns",
"an",
"Error",
"if",
"a",
"name",
"is",
"invalid",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/NameHelper.php#L18-L35 |
digiaonline/graphql-php | src/GraphQL.php | GraphQL.registerProviders | protected function registerProviders(Container $container): void
{
foreach (self::$providers as $className) {
$container->addServiceProvider($className);
}
} | php | protected function registerProviders(Container $container): void
{
foreach (self::$providers as $className) {
$container->addServiceProvider($className);
}
} | [
"protected",
"function",
"registerProviders",
"(",
"Container",
"$",
"container",
")",
":",
"void",
"{",
"foreach",
"(",
"self",
"::",
"$",
"providers",
"as",
"$",
"className",
")",
"{",
"$",
"container",
"->",
"addServiceProvider",
"(",
"$",
"className",
")... | Registers the service provides with the container.
@param Container $container | [
"Registers",
"the",
"service",
"provides",
"with",
"the",
"container",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/GraphQL.php#L364-L369 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.getOperationType | protected function getOperationType(Schema $schema, OperationDefinitionNode $operation): ?ObjectType
{
switch ($operation->getOperation()) {
case 'query':
return $schema->getQueryType();
case 'mutation':
$mutationType = $schema->getMutationType();
if (null === $mutationType) {
throw new ExecutionException('Schema is not configured for mutations.', [$operation]);
}
return $mutationType;
case 'subscription':
$subscriptionType = $schema->getSubscriptionType();
if (null === $subscriptionType) {
throw new ExecutionException('Schema is not configured for subscriptions.', [$operation]);
}
return $subscriptionType;
default:
throw new ExecutionException('Can only execute queries, mutations and subscriptions.', [$operation]);
}
} | php | protected function getOperationType(Schema $schema, OperationDefinitionNode $operation): ?ObjectType
{
switch ($operation->getOperation()) {
case 'query':
return $schema->getQueryType();
case 'mutation':
$mutationType = $schema->getMutationType();
if (null === $mutationType) {
throw new ExecutionException('Schema is not configured for mutations.', [$operation]);
}
return $mutationType;
case 'subscription':
$subscriptionType = $schema->getSubscriptionType();
if (null === $subscriptionType) {
throw new ExecutionException('Schema is not configured for subscriptions.', [$operation]);
}
return $subscriptionType;
default:
throw new ExecutionException('Can only execute queries, mutations and subscriptions.', [$operation]);
}
} | [
"protected",
"function",
"getOperationType",
"(",
"Schema",
"$",
"schema",
",",
"OperationDefinitionNode",
"$",
"operation",
")",
":",
"?",
"ObjectType",
"{",
"switch",
"(",
"$",
"operation",
"->",
"getOperation",
"(",
")",
")",
"{",
"case",
"'query'",
":",
... | @param Schema $schema
@param OperationDefinitionNode $operation
@return ObjectType|null
@throws ExecutionException | [
"@param",
"Schema",
"$schema",
"@param",
"OperationDefinitionNode",
"$operation"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L149-L173 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.resolveField | protected function resolveField(ObjectType $parentType, $rootValue, array $fieldNodes, array $path)
{
$fieldNode = $fieldNodes[0];
$fieldName = $fieldNode->getNameValue();
$field = $this->getFieldDefinition($this->context->getSchema(), $parentType, $fieldName);
if (null === $field) {
throw new UndefinedFieldException($fieldName);
}
$info = $this->createResolveInfo($fieldNodes, $fieldNode, $field, $parentType, $path, $this->context);
$resolveCallback = $this->determineResolveCallback($field, $parentType);
$result = $this->resolveFieldValueOrError(
$field,
$fieldNode,
$resolveCallback,
$rootValue,
$this->context,
$info
);
$result = $this->completeValueCatchingError(
$field->getType(),
$fieldNodes,
$info,
$path,
$result
);
return $result;
} | php | protected function resolveField(ObjectType $parentType, $rootValue, array $fieldNodes, array $path)
{
$fieldNode = $fieldNodes[0];
$fieldName = $fieldNode->getNameValue();
$field = $this->getFieldDefinition($this->context->getSchema(), $parentType, $fieldName);
if (null === $field) {
throw new UndefinedFieldException($fieldName);
}
$info = $this->createResolveInfo($fieldNodes, $fieldNode, $field, $parentType, $path, $this->context);
$resolveCallback = $this->determineResolveCallback($field, $parentType);
$result = $this->resolveFieldValueOrError(
$field,
$fieldNode,
$resolveCallback,
$rootValue,
$this->context,
$info
);
$result = $this->completeValueCatchingError(
$field->getType(),
$fieldNodes,
$info,
$path,
$result
);
return $result;
} | [
"protected",
"function",
"resolveField",
"(",
"ObjectType",
"$",
"parentType",
",",
"$",
"rootValue",
",",
"array",
"$",
"fieldNodes",
",",
"array",
"$",
"path",
")",
"{",
"$",
"fieldNode",
"=",
"$",
"fieldNodes",
"[",
"0",
"]",
";",
"$",
"fieldName",
"=... | Resolves the field on the given source object. In particular, this
figures out the value that the field returns by calling its resolve function,
then calls completeValue to complete promises, serialize scalars, or execute
the sub-selection-set for objects.
@param ObjectType $parentType
@param mixed $rootValue
@param FieldNode[] $fieldNodes
@param string[] $path
@return mixed
@throws \Throwable
@throws UndefinedFieldException | [
"Resolves",
"the",
"field",
"on",
"the",
"given",
"source",
"object",
".",
"In",
"particular",
"this",
"figures",
"out",
"the",
"value",
"that",
"the",
"field",
"returns",
"by",
"calling",
"its",
"resolve",
"function",
"then",
"calls",
"completeValue",
"to",
... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L190-L223 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.resolveFieldValueOrError | protected function resolveFieldValueOrError(
Field $field,
FieldNode $fieldNode,
?callable $resolveCallback,
$rootValue,
ExecutionContext $context,
ResolveInfo $info
) {
try {
// Build an associative array of arguments from the field.arguments AST, using the
// variables scope to fulfill any variable references.
$result = $resolveCallback(
$rootValue,
$this->valuesResolver->coerceArgumentValues($field, $fieldNode, $context->getVariableValues()),
$context->getContextValue(),
$info
);
if ($result instanceof PromiseInterface) {
return $result->then(null, function ($exception) use ($fieldNode, $info) {
return !$exception instanceof ExecutionException
? $this->normalizeException($exception, [$fieldNode], $info->getPath())
: $exception;
});
}
return $result;
} catch (\Throwable $exception) {
return $exception;
}
} | php | protected function resolveFieldValueOrError(
Field $field,
FieldNode $fieldNode,
?callable $resolveCallback,
$rootValue,
ExecutionContext $context,
ResolveInfo $info
) {
try {
// Build an associative array of arguments from the field.arguments AST, using the
// variables scope to fulfill any variable references.
$result = $resolveCallback(
$rootValue,
$this->valuesResolver->coerceArgumentValues($field, $fieldNode, $context->getVariableValues()),
$context->getContextValue(),
$info
);
if ($result instanceof PromiseInterface) {
return $result->then(null, function ($exception) use ($fieldNode, $info) {
return !$exception instanceof ExecutionException
? $this->normalizeException($exception, [$fieldNode], $info->getPath())
: $exception;
});
}
return $result;
} catch (\Throwable $exception) {
return $exception;
}
} | [
"protected",
"function",
"resolveFieldValueOrError",
"(",
"Field",
"$",
"field",
",",
"FieldNode",
"$",
"fieldNode",
",",
"?",
"callable",
"$",
"resolveCallback",
",",
"$",
"rootValue",
",",
"ExecutionContext",
"$",
"context",
",",
"ResolveInfo",
"$",
"info",
")... | @param Field $field
@param FieldNode $fieldNode
@param callable $resolveCallback
@param mixed $rootValue
@param ExecutionContext $context
@param ResolveInfo $info
@return array|\Throwable | [
"@param",
"Field",
"$field",
"@param",
"FieldNode",
"$fieldNode",
"@param",
"callable",
"$resolveCallback",
"@param",
"mixed",
"$rootValue",
"@param",
"ExecutionContext",
"$context",
"@param",
"ResolveInfo",
"$info"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L235-L265 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.normalizeException | protected function normalizeException($exception, array $nodes, array $path = []): ExecutionException
{
if ($exception instanceof \Throwable) {
return new ExecutionException(
$exception->getMessage(),
$nodes,
null,
null,
$path,
null,
$exception
);
}
if (\is_string($exception)) {
return new ExecutionException(
$exception,
$nodes,
null,
null,
$path
);
}
return new ExecutionException(
'',
$nodes,
null,
null,
$path
);
} | php | protected function normalizeException($exception, array $nodes, array $path = []): ExecutionException
{
if ($exception instanceof \Throwable) {
return new ExecutionException(
$exception->getMessage(),
$nodes,
null,
null,
$path,
null,
$exception
);
}
if (\is_string($exception)) {
return new ExecutionException(
$exception,
$nodes,
null,
null,
$path
);
}
return new ExecutionException(
'',
$nodes,
null,
null,
$path
);
} | [
"protected",
"function",
"normalizeException",
"(",
"$",
"exception",
",",
"array",
"$",
"nodes",
",",
"array",
"$",
"path",
"=",
"[",
"]",
")",
":",
"ExecutionException",
"{",
"if",
"(",
"$",
"exception",
"instanceof",
"\\",
"Throwable",
")",
"{",
"return... | Normalizes exceptions which are usually a \Throwable,
but can even be a string or null when resolving promises.
@param mixed $exception
@param NodeInterface[] $nodes
@param array $path
@return ExecutionException | [
"Normalizes",
"exceptions",
"which",
"are",
"usually",
"a",
"\\",
"Throwable",
"but",
"can",
"even",
"be",
"a",
"string",
"or",
"null",
"when",
"resolving",
"promises",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L276-L307 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeValueCatchingError | public function completeValueCatchingError(
TypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
try {
$completed = $result instanceof PromiseInterface
? $result->then(function ($resolvedResult) use ($returnType, $fieldNodes, $info, $path) {
return $this->completeValue($returnType, $fieldNodes, $info, $path, $resolvedResult);
})
: $this->completeValue($returnType, $fieldNodes, $info, $path, $result);
if ($completed instanceof PromiseInterface) {
// Note: we don't rely on a `catch` method, but we do expect "thenable"
// to take a second callback for the error case.
return $completed->then(null, function ($exception) use ($fieldNodes, $path, $returnType) {
$this->handleFieldError($exception, $fieldNodes, $path, $returnType);
});
}
return $completed;
} catch (\Throwable $exception) {
$this->handleFieldError($exception, $fieldNodes, $path, $returnType);
return null;
}
} | php | public function completeValueCatchingError(
TypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
try {
$completed = $result instanceof PromiseInterface
? $result->then(function ($resolvedResult) use ($returnType, $fieldNodes, $info, $path) {
return $this->completeValue($returnType, $fieldNodes, $info, $path, $resolvedResult);
})
: $this->completeValue($returnType, $fieldNodes, $info, $path, $result);
if ($completed instanceof PromiseInterface) {
// Note: we don't rely on a `catch` method, but we do expect "thenable"
// to take a second callback for the error case.
return $completed->then(null, function ($exception) use ($fieldNodes, $path, $returnType) {
$this->handleFieldError($exception, $fieldNodes, $path, $returnType);
});
}
return $completed;
} catch (\Throwable $exception) {
$this->handleFieldError($exception, $fieldNodes, $path, $returnType);
return null;
}
} | [
"public",
"function",
"completeValueCatchingError",
"(",
"TypeInterface",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"ResolveInfo",
"$",
"info",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"try",
"{",
"$",
"completed",
"=",
... | This is a small wrapper around completeValue which detects and logs error in the execution context.
@param TypeInterface $returnType
@param FieldNode[] $fieldNodes
@param ResolveInfo $info
@param array $path
@param mixed $result
@return array|null|PromiseInterface
@throws \Throwable | [
"This",
"is",
"a",
"small",
"wrapper",
"around",
"completeValue",
"which",
"detects",
"and",
"logs",
"error",
"in",
"the",
"execution",
"context",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L321-L348 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeValue | protected function completeValue(
TypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
// If result is an Error, throw a located error.
if ($result instanceof \Throwable) {
throw $result;
}
// If field type is NonNull, complete for inner type, and throw field error if result is null.
if ($returnType instanceof NonNullType) {
$completed = $this->completeValue(
$returnType->getOfType(),
$fieldNodes,
$info,
$path,
$result
);
if (null !== $completed) {
return $completed;
}
throw new ExecutionException(
\sprintf(
'Cannot return null for non-nullable field %s.%s.',
(string)$info->getParentType(),
$info->getFieldName()
)
);
}
// If result is null, return null.
if (null === $result) {
return null;
}
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if ($returnType instanceof ListType) {
return $this->completeListValue($returnType, $fieldNodes, $info, $path, $result);
}
// If field type is Scalar or Enum, serialize to a valid value, returning
// null if serialization is not possible.
if ($returnType instanceof LeafTypeInterface) {
return $this->completeLeafValue($returnType, $result);
}
// If field type is an abstract type, Interface or Union, determine the
// runtime Object type and complete for that type.
if ($returnType instanceof AbstractTypeInterface) {
return $this->completeAbstractValue($returnType, $fieldNodes, $info, $path, $result);
}
// If field type is Object, execute and complete all sub-selections.
if ($returnType instanceof ObjectType) {
return $this->completeObjectValue($returnType, $fieldNodes, $info, $path, $result);
}
throw new ExecutionException(\sprintf('Cannot complete value of unexpected type "%s".', (string)$returnType));
} | php | protected function completeValue(
TypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
// If result is an Error, throw a located error.
if ($result instanceof \Throwable) {
throw $result;
}
// If field type is NonNull, complete for inner type, and throw field error if result is null.
if ($returnType instanceof NonNullType) {
$completed = $this->completeValue(
$returnType->getOfType(),
$fieldNodes,
$info,
$path,
$result
);
if (null !== $completed) {
return $completed;
}
throw new ExecutionException(
\sprintf(
'Cannot return null for non-nullable field %s.%s.',
(string)$info->getParentType(),
$info->getFieldName()
)
);
}
// If result is null, return null.
if (null === $result) {
return null;
}
// If field type is a leaf type, Scalar or Enum, serialize to a valid value,
// returning null if serialization is not possible.
if ($returnType instanceof ListType) {
return $this->completeListValue($returnType, $fieldNodes, $info, $path, $result);
}
// If field type is Scalar or Enum, serialize to a valid value, returning
// null if serialization is not possible.
if ($returnType instanceof LeafTypeInterface) {
return $this->completeLeafValue($returnType, $result);
}
// If field type is an abstract type, Interface or Union, determine the
// runtime Object type and complete for that type.
if ($returnType instanceof AbstractTypeInterface) {
return $this->completeAbstractValue($returnType, $fieldNodes, $info, $path, $result);
}
// If field type is Object, execute and complete all sub-selections.
if ($returnType instanceof ObjectType) {
return $this->completeObjectValue($returnType, $fieldNodes, $info, $path, $result);
}
throw new ExecutionException(\sprintf('Cannot complete value of unexpected type "%s".', (string)$returnType));
} | [
"protected",
"function",
"completeValue",
"(",
"TypeInterface",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"ResolveInfo",
"$",
"info",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"// If result is an Error, throw a located error.",
"... | Implements the instructions for completeValue as defined in the
"Field entries" section of the spec.
If the field type is Non-Null, then this recursively completes the value
for the inner type. It throws a field error if that completion returns null,
as per the "Nullability" section of the spec.
If the field type is a List, then this recursively completes the value
for the inner type on each item in the list.
If the field type is a Scalar or Enum, ensures the completed value is a legal
value of the type by calling the `serialize` method of GraphQL type
definition.
If the field is an abstract type, determine the runtime type of the value
and then complete based on that type
Otherwise, the field type expects a sub-selection set, and will complete the
value by evaluating all sub-selections.
@param TypeInterface $returnType
@param FieldNode[] $fieldNodes
@param ResolveInfo $info
@param array $path
@param mixed $result
@return array|null|PromiseInterface
@throws \Throwable | [
"Implements",
"the",
"instructions",
"for",
"completeValue",
"as",
"defined",
"in",
"the",
"Field",
"entries",
"section",
"of",
"the",
"spec",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L380-L444 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeListValue | protected function completeListValue(
ListType $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
if (!\is_array($result) && !$result instanceof \Traversable) {
throw new InvariantException(
\sprintf(
'Expected Array or Traversable, but did not find one for field %s.%s.',
(string)$info->getParentType(),
$info->getFieldName()
)
);
}
$itemType = $returnType->getOfType();
$completedItems = [];
$containsPromise = false;
foreach ($result as $key => $item) {
$fieldPath = $path;
$fieldPath[] = $key;
$completedItem = $this->completeValueCatchingError($itemType, $fieldNodes, $info, $fieldPath, $item);
$completedItems[] = $completedItem;
$containsPromise = $containsPromise || $completedItem instanceof PromiseInterface;
}
return $containsPromise
? \React\Promise\all($completedItems)
: $completedItems;
} | php | protected function completeListValue(
ListType $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
if (!\is_array($result) && !$result instanceof \Traversable) {
throw new InvariantException(
\sprintf(
'Expected Array or Traversable, but did not find one for field %s.%s.',
(string)$info->getParentType(),
$info->getFieldName()
)
);
}
$itemType = $returnType->getOfType();
$completedItems = [];
$containsPromise = false;
foreach ($result as $key => $item) {
$fieldPath = $path;
$fieldPath[] = $key;
$completedItem = $this->completeValueCatchingError($itemType, $fieldNodes, $info, $fieldPath, $item);
$completedItems[] = $completedItem;
$containsPromise = $containsPromise || $completedItem instanceof PromiseInterface;
}
return $containsPromise
? \React\Promise\all($completedItems)
: $completedItems;
} | [
"protected",
"function",
"completeListValue",
"(",
"ListType",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"ResolveInfo",
"$",
"info",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
... | @param ListType $returnType
@param FieldNode[] $fieldNodes
@param ResolveInfo $info
@param array $path
@param mixed $result
@return array|\React\Promise\Promise
@throws \Throwable | [
"@param",
"ListType",
"$returnType",
"@param",
"FieldNode",
"[]",
"$fieldNodes",
"@param",
"ResolveInfo",
"$info",
"@param",
"array",
"$path",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L456-L488 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeLeafValue | protected function completeLeafValue($returnType, &$result)
{
$result = $returnType->serialize($result);
if (null === $result) {
throw new InvalidReturnTypeException($returnType, $result);
}
return $result;
} | php | protected function completeLeafValue($returnType, &$result)
{
$result = $returnType->serialize($result);
if (null === $result) {
throw new InvalidReturnTypeException($returnType, $result);
}
return $result;
} | [
"protected",
"function",
"completeLeafValue",
"(",
"$",
"returnType",
",",
"&",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"$",
"returnType",
"->",
"serialize",
"(",
"$",
"result",
")",
";",
"if",
"(",
"null",
"===",
"$",
"result",
")",
"{",
"throw",... | @param LeafTypeInterface|SerializableTypeInterface $returnType
@param mixed $result
@return array|PromiseInterface
@throws InvalidReturnTypeException | [
"@param",
"LeafTypeInterface|SerializableTypeInterface",
"$returnType",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L497-L506 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeAbstractValue | protected function completeAbstractValue(
AbstractTypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
$runtimeType = $returnType->hasResolveTypeCallback()
? $returnType->resolveType($result, $this->context->getContextValue(), $info)
: \call_user_func(
$this->typeResolverCallback,
$result,
$this->context->getContextValue(),
$info,
$returnType
);
if ($runtimeType instanceof PromiseInterface) {
return $runtimeType->then(function ($resolvedRuntimeType) use (
$returnType,
$fieldNodes,
$info,
$path,
&$result
) {
return $this->completeObjectValue(
$this->ensureValidRuntimeType($resolvedRuntimeType, $returnType, $info, $result),
$fieldNodes,
$info,
$path,
$result
);
});
}
$returnType = $this->ensureValidRuntimeType($runtimeType, $returnType, $info, $result);
return $this->completeObjectValue(
$returnType,
$fieldNodes,
$info,
$path,
$result
);
} | php | protected function completeAbstractValue(
AbstractTypeInterface $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
$runtimeType = $returnType->hasResolveTypeCallback()
? $returnType->resolveType($result, $this->context->getContextValue(), $info)
: \call_user_func(
$this->typeResolverCallback,
$result,
$this->context->getContextValue(),
$info,
$returnType
);
if ($runtimeType instanceof PromiseInterface) {
return $runtimeType->then(function ($resolvedRuntimeType) use (
$returnType,
$fieldNodes,
$info,
$path,
&$result
) {
return $this->completeObjectValue(
$this->ensureValidRuntimeType($resolvedRuntimeType, $returnType, $info, $result),
$fieldNodes,
$info,
$path,
$result
);
});
}
$returnType = $this->ensureValidRuntimeType($runtimeType, $returnType, $info, $result);
return $this->completeObjectValue(
$returnType,
$fieldNodes,
$info,
$path,
$result
);
} | [
"protected",
"function",
"completeAbstractValue",
"(",
"AbstractTypeInterface",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"ResolveInfo",
"$",
"info",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"$",
"runtimeType",
"=",
"$",
"... | @param AbstractTypeInterface $returnType
@param FieldNode[] $fieldNodes
@param ResolveInfo $info
@param string[] $path
@param mixed $result
@return array|PromiseInterface
@throws \Throwable | [
"@param",
"AbstractTypeInterface",
"$returnType",
"@param",
"FieldNode",
"[]",
"$fieldNodes",
"@param",
"ResolveInfo",
"$info",
"@param",
"string",
"[]",
"$path",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L518-L562 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.completeObjectValue | protected function completeObjectValue(
ObjectType $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
// If there is an isTypeOfCallback predicate function, call it with the
// current result. If isTypeOfCallback returns false, then raise an error rather
// than continuing execution.
if ($returnType->hasIsTypeOfCallback()) {
$isTypeOf = $returnType->isTypeOf($result, $this->context->getContextValue(), $info);
if ($isTypeOf instanceof PromiseInterface) {
return $isTypeOf->then(function ($resolvedIsTypeOf) use ($returnType, $result, $fieldNodes, $path) {
if (true === $resolvedIsTypeOf) {
return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
}
throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
});
}
if (false === $isTypeOf) {
throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
}
}
return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
} | php | protected function completeObjectValue(
ObjectType $returnType,
array $fieldNodes,
ResolveInfo $info,
array $path,
&$result
) {
// If there is an isTypeOfCallback predicate function, call it with the
// current result. If isTypeOfCallback returns false, then raise an error rather
// than continuing execution.
if ($returnType->hasIsTypeOfCallback()) {
$isTypeOf = $returnType->isTypeOf($result, $this->context->getContextValue(), $info);
if ($isTypeOf instanceof PromiseInterface) {
return $isTypeOf->then(function ($resolvedIsTypeOf) use ($returnType, $result, $fieldNodes, $path) {
if (true === $resolvedIsTypeOf) {
return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
}
throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
});
}
if (false === $isTypeOf) {
throw new InvalidReturnTypeException($returnType, $result, $fieldNodes);
}
}
return $this->executeSubFields($returnType, $fieldNodes, $path, $result);
} | [
"protected",
"function",
"completeObjectValue",
"(",
"ObjectType",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"ResolveInfo",
"$",
"info",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"// If there is an isTypeOfCallback predicate functi... | @param ObjectType $returnType
@param array $fieldNodes
@param ResolveInfo $info
@param array $path
@param mixed $result
@return array|PromiseInterface
@throws ExecutionException
@throws InvalidReturnTypeException
@throws \Throwable | [
"@param",
"ObjectType",
"$returnType",
"@param",
"array",
"$fieldNodes",
"@param",
"ResolveInfo",
"$info",
"@param",
"array",
"$path",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L576-L605 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.executeSubFields | protected function executeSubFields(ObjectType $returnType, array $fieldNodes, array $path, &$result)
{
$subFields = [];
$visitedFragmentNames = [];
foreach ($fieldNodes as $fieldNode) {
if (null !== $fieldNode->getSelectionSet()) {
$subFields = $this->fieldCollector->collectFields(
$returnType,
$fieldNode->getSelectionSet(),
$subFields,
$visitedFragmentNames
);
}
}
if (!empty($subFields)) {
return $this->executeFields($returnType, $result, $path, $subFields);
}
return $result;
} | php | protected function executeSubFields(ObjectType $returnType, array $fieldNodes, array $path, &$result)
{
$subFields = [];
$visitedFragmentNames = [];
foreach ($fieldNodes as $fieldNode) {
if (null !== $fieldNode->getSelectionSet()) {
$subFields = $this->fieldCollector->collectFields(
$returnType,
$fieldNode->getSelectionSet(),
$subFields,
$visitedFragmentNames
);
}
}
if (!empty($subFields)) {
return $this->executeFields($returnType, $result, $path, $subFields);
}
return $result;
} | [
"protected",
"function",
"executeSubFields",
"(",
"ObjectType",
"$",
"returnType",
",",
"array",
"$",
"fieldNodes",
",",
"array",
"$",
"path",
",",
"&",
"$",
"result",
")",
"{",
"$",
"subFields",
"=",
"[",
"]",
";",
"$",
"visitedFragmentNames",
"=",
"[",
... | @param ObjectType $returnType
@param FieldNode[] $fieldNodes
@param array $path
@param mixed $result
@return array|PromiseInterface
@throws \Throwable | [
"@param",
"ObjectType",
"$returnType",
"@param",
"FieldNode",
"[]",
"$fieldNodes",
"@param",
"array",
"$path",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L616-L637 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.ensureValidRuntimeType | protected function ensureValidRuntimeType(
$runtimeTypeOrName,
NamedTypeInterface $returnType,
ResolveInfo $info,
&$result
) {
/** @var NamedTypeInterface $runtimeType */
$runtimeType = \is_string($runtimeTypeOrName)
? $this->context->getSchema()->getType($runtimeTypeOrName)
: $runtimeTypeOrName;
$runtimeTypeName = $runtimeType->getName();
$returnTypeName = $returnType->getName();
if (!$runtimeType instanceof ObjectType) {
$parentTypeName = $info->getParentType()->getName();
$fieldName = $info->getFieldName();
throw new ExecutionException(
\sprintf(
'Abstract type %s must resolve to an Object type at runtime for field %s.%s ' .
'with value "%s", received "%s".',
$returnTypeName,
$parentTypeName,
$fieldName,
$result,
$runtimeTypeName
)
);
}
if (!$this->context->getSchema()->isPossibleType($returnType, $runtimeType)) {
throw new ExecutionException(
\sprintf('Runtime Object type "%s" is not a possible type for "%s".', $runtimeTypeName, $returnTypeName)
);
}
if ($runtimeType !== $this->context->getSchema()->getType($runtimeType->getName())) {
throw new ExecutionException(
\sprintf(
'Schema must contain unique named types but contains multiple types named "%s". ' .
'Make sure that `resolveType` function of abstract type "%s" returns the same ' .
'type instance as referenced anywhere else within the schema.',
$runtimeTypeName,
$returnTypeName
)
);
}
return $runtimeType;
} | php | protected function ensureValidRuntimeType(
$runtimeTypeOrName,
NamedTypeInterface $returnType,
ResolveInfo $info,
&$result
) {
/** @var NamedTypeInterface $runtimeType */
$runtimeType = \is_string($runtimeTypeOrName)
? $this->context->getSchema()->getType($runtimeTypeOrName)
: $runtimeTypeOrName;
$runtimeTypeName = $runtimeType->getName();
$returnTypeName = $returnType->getName();
if (!$runtimeType instanceof ObjectType) {
$parentTypeName = $info->getParentType()->getName();
$fieldName = $info->getFieldName();
throw new ExecutionException(
\sprintf(
'Abstract type %s must resolve to an Object type at runtime for field %s.%s ' .
'with value "%s", received "%s".',
$returnTypeName,
$parentTypeName,
$fieldName,
$result,
$runtimeTypeName
)
);
}
if (!$this->context->getSchema()->isPossibleType($returnType, $runtimeType)) {
throw new ExecutionException(
\sprintf('Runtime Object type "%s" is not a possible type for "%s".', $runtimeTypeName, $returnTypeName)
);
}
if ($runtimeType !== $this->context->getSchema()->getType($runtimeType->getName())) {
throw new ExecutionException(
\sprintf(
'Schema must contain unique named types but contains multiple types named "%s". ' .
'Make sure that `resolveType` function of abstract type "%s" returns the same ' .
'type instance as referenced anywhere else within the schema.',
$runtimeTypeName,
$returnTypeName
)
);
}
return $runtimeType;
} | [
"protected",
"function",
"ensureValidRuntimeType",
"(",
"$",
"runtimeTypeOrName",
",",
"NamedTypeInterface",
"$",
"returnType",
",",
"ResolveInfo",
"$",
"info",
",",
"&",
"$",
"result",
")",
"{",
"/** @var NamedTypeInterface $runtimeType */",
"$",
"runtimeType",
"=",
... | @param NamedTypeInterface|string $runtimeTypeOrName
@param NamedTypeInterface $returnType
@param ResolveInfo $info
@param mixed $result
@return TypeInterface|ObjectType|null
@throws ExecutionException
@throws InvariantException | [
"@param",
"NamedTypeInterface|string",
"$runtimeTypeOrName",
"@param",
"NamedTypeInterface",
"$returnType",
"@param",
"ResolveInfo",
"$info",
"@param",
"mixed",
"$result"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L649-L699 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.getFieldDefinition | public function getFieldDefinition(Schema $schema, ObjectType $parentType, string $fieldName): ?Field
{
if ($fieldName === '__schema' && $schema->getQueryType() === $parentType) {
return SchemaMetaFieldDefinition();
}
if ($fieldName === '__type' && $schema->getQueryType() === $parentType) {
return TypeMetaFieldDefinition();
}
if ($fieldName === '__typename') {
return TypeNameMetaFieldDefinition();
}
$fields = $parentType->getFields();
return $fields[$fieldName] ?? null;
} | php | public function getFieldDefinition(Schema $schema, ObjectType $parentType, string $fieldName): ?Field
{
if ($fieldName === '__schema' && $schema->getQueryType() === $parentType) {
return SchemaMetaFieldDefinition();
}
if ($fieldName === '__type' && $schema->getQueryType() === $parentType) {
return TypeMetaFieldDefinition();
}
if ($fieldName === '__typename') {
return TypeNameMetaFieldDefinition();
}
$fields = $parentType->getFields();
return $fields[$fieldName] ?? null;
} | [
"public",
"function",
"getFieldDefinition",
"(",
"Schema",
"$",
"schema",
",",
"ObjectType",
"$",
"parentType",
",",
"string",
"$",
"fieldName",
")",
":",
"?",
"Field",
"{",
"if",
"(",
"$",
"fieldName",
"===",
"'__schema'",
"&&",
"$",
"schema",
"->",
"getQ... | @param Schema $schema
@param ObjectType $parentType
@param string $fieldName
@return Field|null
@throws InvariantException | [
"@param",
"Schema",
"$schema",
"@param",
"ObjectType",
"$parentType",
"@param",
"string",
"$fieldName"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L709-L726 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.determineResolveCallback | protected function determineResolveCallback(Field $field, ObjectType $parentType): callable
{
if ($field->hasResolveCallback()) {
return $field->getResolveCallback();
}
if ($parentType->hasResolveCallback()) {
return $parentType->getResolveCallback();
}
if ($this->context->hasFieldResolver()) {
return $this->context->getFieldResolver();
}
return $this->fieldResolverCallback;
} | php | protected function determineResolveCallback(Field $field, ObjectType $parentType): callable
{
if ($field->hasResolveCallback()) {
return $field->getResolveCallback();
}
if ($parentType->hasResolveCallback()) {
return $parentType->getResolveCallback();
}
if ($this->context->hasFieldResolver()) {
return $this->context->getFieldResolver();
}
return $this->fieldResolverCallback;
} | [
"protected",
"function",
"determineResolveCallback",
"(",
"Field",
"$",
"field",
",",
"ObjectType",
"$",
"parentType",
")",
":",
"callable",
"{",
"if",
"(",
"$",
"field",
"->",
"hasResolveCallback",
"(",
")",
")",
"{",
"return",
"$",
"field",
"->",
"getResol... | @param Field $field
@param ObjectType $parentType
@return callable | [
"@param",
"Field",
"$field",
"@param",
"ObjectType",
"$parentType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L734-L749 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.buildLocatedError | protected function buildLocatedError(
\Throwable $originalException,
array $nodes = [],
array $path = []
): ExecutionException {
return new ExecutionException(
$originalException->getMessage(),
$originalException instanceof GraphQLException
? $originalException->getNodes()
: $nodes,
$originalException instanceof GraphQLException
? $originalException->getSource()
: null,
$originalException instanceof GraphQLException
? $originalException->getPositions()
: null,
$originalException instanceof GraphQLException
? ($originalException->getPath() ?? $path)
: $path,
null,
$originalException
);
} | php | protected function buildLocatedError(
\Throwable $originalException,
array $nodes = [],
array $path = []
): ExecutionException {
return new ExecutionException(
$originalException->getMessage(),
$originalException instanceof GraphQLException
? $originalException->getNodes()
: $nodes,
$originalException instanceof GraphQLException
? $originalException->getSource()
: null,
$originalException instanceof GraphQLException
? $originalException->getPositions()
: null,
$originalException instanceof GraphQLException
? ($originalException->getPath() ?? $path)
: $path,
null,
$originalException
);
} | [
"protected",
"function",
"buildLocatedError",
"(",
"\\",
"Throwable",
"$",
"originalException",
",",
"array",
"$",
"nodes",
"=",
"[",
"]",
",",
"array",
"$",
"path",
"=",
"[",
"]",
")",
":",
"ExecutionException",
"{",
"return",
"new",
"ExecutionException",
"... | @param \Throwable $originalException
@param NodeInterface[] $nodes
@param string[] $path
@return ExecutionException | [
"@param",
"\\",
"Throwable",
"$originalException",
"@param",
"NodeInterface",
"[]",
"$nodes",
"@param",
"string",
"[]",
"$path"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L784-L806 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.createResolveInfo | protected function createResolveInfo(
array $fieldNodes,
FieldNode $fieldNode,
Field $field,
ObjectType $parentType,
?array $path,
ExecutionContext $context
): ResolveInfo {
return new ResolveInfo(
$fieldNode->getNameValue(),
$fieldNodes,
$field->getType(),
$parentType,
$path,
$context->getSchema(),
$context->getFragments(),
$context->getRootValue(),
$context->getOperation(),
$context->getVariableValues()
);
} | php | protected function createResolveInfo(
array $fieldNodes,
FieldNode $fieldNode,
Field $field,
ObjectType $parentType,
?array $path,
ExecutionContext $context
): ResolveInfo {
return new ResolveInfo(
$fieldNode->getNameValue(),
$fieldNodes,
$field->getType(),
$parentType,
$path,
$context->getSchema(),
$context->getFragments(),
$context->getRootValue(),
$context->getOperation(),
$context->getVariableValues()
);
} | [
"protected",
"function",
"createResolveInfo",
"(",
"array",
"$",
"fieldNodes",
",",
"FieldNode",
"$",
"fieldNode",
",",
"Field",
"$",
"field",
",",
"ObjectType",
"$",
"parentType",
",",
"?",
"array",
"$",
"path",
",",
"ExecutionContext",
"$",
"context",
")",
... | @param FieldNode[] $fieldNodes
@param FieldNode $fieldNode
@param Field $field
@param ObjectType $parentType
@param array|null $path
@param ExecutionContext $context
@return ResolveInfo | [
"@param",
"FieldNode",
"[]",
"$fieldNodes",
"@param",
"FieldNode",
"$fieldNode",
"@param",
"Field",
"$field",
"@param",
"ObjectType",
"$parentType",
"@param",
"array|null",
"$path",
"@param",
"ExecutionContext",
"$context"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L818-L838 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.defaultTypeResolver | public static function defaultTypeResolver(
$value,
$context,
ResolveInfo $info,
AbstractTypeInterface $abstractType
) {
// First, look for `__typename`.
if (\is_array($value) && isset($value['__typename'])) {
return $value['__typename'];
}
// Otherwise, test each possible type.
/** @var ObjectType[] $possibleTypes */
$possibleTypes = $info->getSchema()->getPossibleTypes($abstractType);
$promises = [];
foreach ($possibleTypes as $index => $type) {
$isTypeOf = $type->isTypeOf($value, $context, $info);
if ($isTypeOf instanceof PromiseInterface) {
$promises[$index] = $isTypeOf;
}
if (true === $isTypeOf) {
return $type;
}
}
if (!empty($promises)) {
return \React\Promise\all($promises)->then(function ($resolvedPromises) use ($possibleTypes) {
foreach ($resolvedPromises as $index => $result) {
if (true === $result) {
return $possibleTypes[$index];
}
}
return null;
});
}
return null;
} | php | public static function defaultTypeResolver(
$value,
$context,
ResolveInfo $info,
AbstractTypeInterface $abstractType
) {
// First, look for `__typename`.
if (\is_array($value) && isset($value['__typename'])) {
return $value['__typename'];
}
// Otherwise, test each possible type.
/** @var ObjectType[] $possibleTypes */
$possibleTypes = $info->getSchema()->getPossibleTypes($abstractType);
$promises = [];
foreach ($possibleTypes as $index => $type) {
$isTypeOf = $type->isTypeOf($value, $context, $info);
if ($isTypeOf instanceof PromiseInterface) {
$promises[$index] = $isTypeOf;
}
if (true === $isTypeOf) {
return $type;
}
}
if (!empty($promises)) {
return \React\Promise\all($promises)->then(function ($resolvedPromises) use ($possibleTypes) {
foreach ($resolvedPromises as $index => $result) {
if (true === $result) {
return $possibleTypes[$index];
}
}
return null;
});
}
return null;
} | [
"public",
"static",
"function",
"defaultTypeResolver",
"(",
"$",
"value",
",",
"$",
"context",
",",
"ResolveInfo",
"$",
"info",
",",
"AbstractTypeInterface",
"$",
"abstractType",
")",
"{",
"// First, look for `__typename`.",
"if",
"(",
"\\",
"is_array",
"(",
"$",
... | @param mixed $value
@param mixed $context
@param ResolveInfo $info
@param AbstractTypeInterface $abstractType
@return mixed
@throws InvariantException | [
"@param",
"mixed",
"$value",
"@param",
"mixed",
"$context",
"@param",
"ResolveInfo",
"$info",
"@param",
"AbstractTypeInterface",
"$abstractType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L849-L891 |
digiaonline/graphql-php | src/Execution/Strategy/AbstractExecutionStrategy.php | AbstractExecutionStrategy.defaultFieldResolver | public static function defaultFieldResolver($rootValue, array $arguments, $contextValues, ResolveInfo $info)
{
$fieldName = $info->getFieldName();
$property = null;
if (\is_array($rootValue) && isset($rootValue[$fieldName])) {
$property = $rootValue[$fieldName];
}
if (\is_object($rootValue)) {
$getter = 'get' . \ucfirst($fieldName);
if (\method_exists($rootValue, $getter)) {
$property = $rootValue->{$getter}();
} elseif (\method_exists($rootValue, $fieldName)) {
$property = $rootValue->{$fieldName}($rootValue, $arguments, $contextValues, $info);
} elseif (\property_exists($rootValue, $fieldName)) {
$property = $rootValue->{$fieldName};
}
}
return $property instanceof \Closure
? $property($rootValue, $arguments, $contextValues, $info)
: $property;
} | php | public static function defaultFieldResolver($rootValue, array $arguments, $contextValues, ResolveInfo $info)
{
$fieldName = $info->getFieldName();
$property = null;
if (\is_array($rootValue) && isset($rootValue[$fieldName])) {
$property = $rootValue[$fieldName];
}
if (\is_object($rootValue)) {
$getter = 'get' . \ucfirst($fieldName);
if (\method_exists($rootValue, $getter)) {
$property = $rootValue->{$getter}();
} elseif (\method_exists($rootValue, $fieldName)) {
$property = $rootValue->{$fieldName}($rootValue, $arguments, $contextValues, $info);
} elseif (\property_exists($rootValue, $fieldName)) {
$property = $rootValue->{$fieldName};
}
}
return $property instanceof \Closure
? $property($rootValue, $arguments, $contextValues, $info)
: $property;
} | [
"public",
"static",
"function",
"defaultFieldResolver",
"(",
"$",
"rootValue",
",",
"array",
"$",
"arguments",
",",
"$",
"contextValues",
",",
"ResolveInfo",
"$",
"info",
")",
"{",
"$",
"fieldName",
"=",
"$",
"info",
"->",
"getFieldName",
"(",
")",
";",
"$... | Try to resolve a field without any field resolver function.
@param array|object $rootValue
@param array $arguments
@param mixed $contextValues
@param ResolveInfo $info
@return mixed|null | [
"Try",
"to",
"resolve",
"a",
"field",
"without",
"any",
"field",
"resolver",
"function",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/Strategy/AbstractExecutionStrategy.php#L903-L926 |
digiaonline/graphql-php | src/Execution/ValuesResolver.php | ValuesResolver.coerceArgumentValues | public function coerceArgumentValues($definition, ArgumentsAwareInterface $node, array $variableValues = []): array
{
$coercedValues = [];
$argumentDefinitions = $definition->getArguments();
$argumentNodes = $node->getArguments();
if (empty($argumentDefinitions)) {
return $coercedValues;
}
/** @var ArgumentNode[] $argumentNodeMap */
$argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $value) {
return $value->getNameValue();
});
foreach ($argumentDefinitions as $argumentDefinition) {
$argumentName = $argumentDefinition->getName();
$argumentType = $argumentDefinition->getType();
$argumentNode = $argumentNodeMap[$argumentName] ?? null;
$defaultValue = $argumentDefinition->getDefaultValue();
$argumentValue = null !== $argumentNode ? $argumentNode->getValue() : null;
if (null === $argumentNode) {
if (null !== $defaultValue) {
$coercedValues[$argumentName] = $defaultValue;
} elseif ($argumentType instanceof NonNullType) {
throw new ExecutionException(
sprintf(
'Argument "%s" of required type "%s" was not provided.',
$argumentName,
$argumentType
),
[$node]
);
}
} elseif ($argumentValue instanceof VariableNode) {
$coercedValues[$argumentName] = $this->coerceValueForVariableNode(
$argumentValue,
$argumentType,
$argumentName,
$variableValues,
$defaultValue
);
} else {
try {
$coercedValues[$argumentName] = ValueASTConverter::convert(
$argumentNode->getValue(),
$argumentType,
$variableValues
);
} catch (\Exception $ex) {
// Value nodes that cannot be resolved should be treated as invalid values
// because there is no undefined value in PHP so that we throw an exception
throw new ExecutionException(
sprintf(
'Argument "%s" has invalid value %s.',
$argumentName,
(string)$argumentNode->getValue()
),
[$argumentNode->getValue()],
null,
null,
null,
null,
$ex
);
}
}
}
return $coercedValues;
} | php | public function coerceArgumentValues($definition, ArgumentsAwareInterface $node, array $variableValues = []): array
{
$coercedValues = [];
$argumentDefinitions = $definition->getArguments();
$argumentNodes = $node->getArguments();
if (empty($argumentDefinitions)) {
return $coercedValues;
}
/** @var ArgumentNode[] $argumentNodeMap */
$argumentNodeMap = keyMap($argumentNodes, function (ArgumentNode $value) {
return $value->getNameValue();
});
foreach ($argumentDefinitions as $argumentDefinition) {
$argumentName = $argumentDefinition->getName();
$argumentType = $argumentDefinition->getType();
$argumentNode = $argumentNodeMap[$argumentName] ?? null;
$defaultValue = $argumentDefinition->getDefaultValue();
$argumentValue = null !== $argumentNode ? $argumentNode->getValue() : null;
if (null === $argumentNode) {
if (null !== $defaultValue) {
$coercedValues[$argumentName] = $defaultValue;
} elseif ($argumentType instanceof NonNullType) {
throw new ExecutionException(
sprintf(
'Argument "%s" of required type "%s" was not provided.',
$argumentName,
$argumentType
),
[$node]
);
}
} elseif ($argumentValue instanceof VariableNode) {
$coercedValues[$argumentName] = $this->coerceValueForVariableNode(
$argumentValue,
$argumentType,
$argumentName,
$variableValues,
$defaultValue
);
} else {
try {
$coercedValues[$argumentName] = ValueASTConverter::convert(
$argumentNode->getValue(),
$argumentType,
$variableValues
);
} catch (\Exception $ex) {
// Value nodes that cannot be resolved should be treated as invalid values
// because there is no undefined value in PHP so that we throw an exception
throw new ExecutionException(
sprintf(
'Argument "%s" has invalid value %s.',
$argumentName,
(string)$argumentNode->getValue()
),
[$argumentNode->getValue()],
null,
null,
null,
null,
$ex
);
}
}
}
return $coercedValues;
} | [
"public",
"function",
"coerceArgumentValues",
"(",
"$",
"definition",
",",
"ArgumentsAwareInterface",
"$",
"node",
",",
"array",
"$",
"variableValues",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"coercedValues",
"=",
"[",
"]",
";",
"$",
"argumentDefinitions",... | Prepares an object map of argument values given a list of argument
definitions and list of argument AST nodes.
@see https://facebook.github.io/graphql/October2016/#CoerceArgumentValues()
@param Field|Directive $definition
@param ArgumentsAwareInterface $node
@param array $variableValues
@return array
@throws ExecutionException
@throws InvalidTypeException
@throws InvariantException | [
"Prepares",
"an",
"object",
"map",
"of",
"argument",
"values",
"given",
"a",
"list",
"of",
"argument",
"definitions",
"and",
"list",
"of",
"argument",
"AST",
"nodes",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/ValuesResolver.php#L52-L123 |
digiaonline/graphql-php | src/Execution/ValuesResolver.php | ValuesResolver.coerceDirectiveValues | public function coerceDirectiveValues(
Directive $directive,
$node,
array $variableValues = []
): ?array {
$directiveNode = $node->hasDirectives()
? find($node->getDirectives(), function (NameAwareInterface $value) use ($directive) {
return $value->getNameValue() === $directive->getName();
}) : null;
if (null !== $directiveNode) {
return $this->coerceArgumentValues($directive, $directiveNode, $variableValues);
}
return null;
} | php | public function coerceDirectiveValues(
Directive $directive,
$node,
array $variableValues = []
): ?array {
$directiveNode = $node->hasDirectives()
? find($node->getDirectives(), function (NameAwareInterface $value) use ($directive) {
return $value->getNameValue() === $directive->getName();
}) : null;
if (null !== $directiveNode) {
return $this->coerceArgumentValues($directive, $directiveNode, $variableValues);
}
return null;
} | [
"public",
"function",
"coerceDirectiveValues",
"(",
"Directive",
"$",
"directive",
",",
"$",
"node",
",",
"array",
"$",
"variableValues",
"=",
"[",
"]",
")",
":",
"?",
"array",
"{",
"$",
"directiveNode",
"=",
"$",
"node",
"->",
"hasDirectives",
"(",
")",
... | Prepares an object map of argument values given a directive definition
and a AST node which may contain directives. Optionally also accepts a map
of variable values.
If the directive does not exist on the node, returns null.
@param Directive $directive
@param mixed $node
@param array $variableValues
@return array|null
@throws ExecutionException
@throws InvalidTypeException
@throws InvariantException | [
"Prepares",
"an",
"object",
"map",
"of",
"argument",
"values",
"given",
"a",
"directive",
"definition",
"and",
"a",
"AST",
"node",
"which",
"may",
"contain",
"directives",
".",
"Optionally",
"also",
"accepts",
"a",
"map",
"of",
"variable",
"values",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/ValuesResolver.php#L140-L155 |
digiaonline/graphql-php | src/Execution/ValuesResolver.php | ValuesResolver.coerceVariableValues | public function coerceVariableValues(Schema $schema, array $variableDefinitionNodes, array $inputs): CoercedValue
{
$coercedValues = [];
$errors = [];
foreach ($variableDefinitionNodes as $variableDefinitionNode) {
$variableName = $variableDefinitionNode->getVariable()->getNameValue();
$variableType = TypeASTConverter::convert($schema, $variableDefinitionNode->getType());
if (!$this->isInputType($variableType)) {
$variableTypeName = (string)$variableType;
if ($variableTypeName === '') {
$variableTypeName = (string)$variableDefinitionNode;
}
$errors[] = $this->buildCoerceException(
sprintf(
'Variable "$%s" expected value of type "%s" which cannot be used as an input type',
$variableName,
$variableTypeName
),
$variableDefinitionNode,
null
);
} else {
if (!array_key_exists($variableName, $inputs)) {
if ($variableType instanceof NonNullType) {
$errors[] = $this->buildCoerceException(
sprintf(
'Variable "$%s" of required type "%s" was not provided',
$variableName,
(string)$variableType
),
$variableDefinitionNode,
null
);
} elseif ($variableDefinitionNode->getDefaultValue() !== null) {
$coercedValues[$variableName] = ValueASTConverter::convert(
$variableDefinitionNode->getDefaultValue(),
$variableType
);
}
} else {
$value = $inputs[$variableName];
$coercedValue = $this->coerceValue($value, $variableType, $variableDefinitionNode);
if ($coercedValue->hasErrors()) {
$messagePrelude = sprintf(
'Variable "$%s" got invalid value %s',
$variableName, json_encode($value)
);
foreach ($coercedValue->getErrors() as $error) {
$errors[] = $this->buildCoerceException(
$messagePrelude,
$variableDefinitionNode,
null,
$error->getMessage(),
$error
);
}
} else {
$coercedValues[$variableName] = $coercedValue->getValue();
}
}
}
}
return new CoercedValue($coercedValues, $errors);
} | php | public function coerceVariableValues(Schema $schema, array $variableDefinitionNodes, array $inputs): CoercedValue
{
$coercedValues = [];
$errors = [];
foreach ($variableDefinitionNodes as $variableDefinitionNode) {
$variableName = $variableDefinitionNode->getVariable()->getNameValue();
$variableType = TypeASTConverter::convert($schema, $variableDefinitionNode->getType());
if (!$this->isInputType($variableType)) {
$variableTypeName = (string)$variableType;
if ($variableTypeName === '') {
$variableTypeName = (string)$variableDefinitionNode;
}
$errors[] = $this->buildCoerceException(
sprintf(
'Variable "$%s" expected value of type "%s" which cannot be used as an input type',
$variableName,
$variableTypeName
),
$variableDefinitionNode,
null
);
} else {
if (!array_key_exists($variableName, $inputs)) {
if ($variableType instanceof NonNullType) {
$errors[] = $this->buildCoerceException(
sprintf(
'Variable "$%s" of required type "%s" was not provided',
$variableName,
(string)$variableType
),
$variableDefinitionNode,
null
);
} elseif ($variableDefinitionNode->getDefaultValue() !== null) {
$coercedValues[$variableName] = ValueASTConverter::convert(
$variableDefinitionNode->getDefaultValue(),
$variableType
);
}
} else {
$value = $inputs[$variableName];
$coercedValue = $this->coerceValue($value, $variableType, $variableDefinitionNode);
if ($coercedValue->hasErrors()) {
$messagePrelude = sprintf(
'Variable "$%s" got invalid value %s',
$variableName, json_encode($value)
);
foreach ($coercedValue->getErrors() as $error) {
$errors[] = $this->buildCoerceException(
$messagePrelude,
$variableDefinitionNode,
null,
$error->getMessage(),
$error
);
}
} else {
$coercedValues[$variableName] = $coercedValue->getValue();
}
}
}
}
return new CoercedValue($coercedValues, $errors);
} | [
"public",
"function",
"coerceVariableValues",
"(",
"Schema",
"$",
"schema",
",",
"array",
"$",
"variableDefinitionNodes",
",",
"array",
"$",
"inputs",
")",
":",
"CoercedValue",
"{",
"$",
"coercedValues",
"=",
"[",
"]",
";",
"$",
"errors",
"=",
"[",
"]",
";... | Prepares an object map of variableValues of the correct type based on the
provided variable definitions and arbitrary input. If the input cannot be
parsed to match the variable definitions, a GraphQLError will be thrown.
@param Schema $schema
@param array|VariableDefinitionNode[] $variableDefinitionNodes
@param array $inputs
@return CoercedValue
@throws GraphQLException
@throws InvariantException
@throws ConversionException | [
"Prepares",
"an",
"object",
"map",
"of",
"variableValues",
"of",
"the",
"correct",
"type",
"based",
"on",
"the",
"provided",
"variable",
"definitions",
"and",
"arbitrary",
"input",
".",
"If",
"the",
"input",
"cannot",
"be",
"parsed",
"to",
"match",
"the",
"v... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/ValuesResolver.php#L170-L238 |
digiaonline/graphql-php | src/Execution/ValuesResolver.php | ValuesResolver.coerceValue | private function coerceValue($value, $type, $blameNode, ?Path $path = null): CoercedValue
{
if ($type instanceof NonNullType) {
return $this->coerceValueForNonNullType($value, $type, $blameNode, $path);
}
if (null === $value) {
return new CoercedValue(null);
}
if ($type instanceof ScalarType) {
return $this->coerceValueForScalarType($value, $type, $blameNode, $path);
}
if ($type instanceof EnumType) {
return $this->coerceValueForEnumType($value, $type, $blameNode, $path);
}
if ($type instanceof ListType) {
return $this->coerceValueForListType($value, $type, $blameNode, $path);
}
if ($type instanceof InputObjectType) {
return $this->coerceValueForInputObjectType($value, $type, $blameNode, $path);
}
throw new GraphQLException('Unexpected type.');
} | php | private function coerceValue($value, $type, $blameNode, ?Path $path = null): CoercedValue
{
if ($type instanceof NonNullType) {
return $this->coerceValueForNonNullType($value, $type, $blameNode, $path);
}
if (null === $value) {
return new CoercedValue(null);
}
if ($type instanceof ScalarType) {
return $this->coerceValueForScalarType($value, $type, $blameNode, $path);
}
if ($type instanceof EnumType) {
return $this->coerceValueForEnumType($value, $type, $blameNode, $path);
}
if ($type instanceof ListType) {
return $this->coerceValueForListType($value, $type, $blameNode, $path);
}
if ($type instanceof InputObjectType) {
return $this->coerceValueForInputObjectType($value, $type, $blameNode, $path);
}
throw new GraphQLException('Unexpected type.');
} | [
"private",
"function",
"coerceValue",
"(",
"$",
"value",
",",
"$",
"type",
",",
"$",
"blameNode",
",",
"?",
"Path",
"$",
"path",
"=",
"null",
")",
":",
"CoercedValue",
"{",
"if",
"(",
"$",
"type",
"instanceof",
"NonNullType",
")",
"{",
"return",
"$",
... | Returns either a value which is valid for the provided type or a list of
encountered coercion errors.
@param mixed|array $value
@param mixed $type
@param NodeInterface $blameNode
@param Path|null $path
@return CoercedValue
@throws GraphQLException
@throws InvariantException | [
"Returns",
"either",
"a",
"value",
"which",
"is",
"valid",
"for",
"the",
"provided",
"type",
"or",
"a",
"list",
"of",
"encountered",
"coercion",
"errors",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/ValuesResolver.php#L265-L292 |
digiaonline/graphql-php | src/Execution/ValuesResolver.php | ValuesResolver.coerceValueForScalarType | protected function coerceValueForScalarType(
$value,
ScalarType $type,
NodeInterface $blameNode,
?Path $path
): CoercedValue {
try {
$parseResult = $type->parseValue($value);
if (null === $parseResult) {
return new CoercedValue(null, [
new GraphQLException(sprintf('Expected type %s', (string)$type))
]);
}
return new CoercedValue($parseResult);
} catch (InvalidTypeException|CoercingException $ex) {
return new CoercedValue(null, [
$this->buildCoerceException(
sprintf('Expected type %s', (string)$type),
$blameNode,
$path,
$ex->getMessage(),
$ex
)
]);
}
} | php | protected function coerceValueForScalarType(
$value,
ScalarType $type,
NodeInterface $blameNode,
?Path $path
): CoercedValue {
try {
$parseResult = $type->parseValue($value);
if (null === $parseResult) {
return new CoercedValue(null, [
new GraphQLException(sprintf('Expected type %s', (string)$type))
]);
}
return new CoercedValue($parseResult);
} catch (InvalidTypeException|CoercingException $ex) {
return new CoercedValue(null, [
$this->buildCoerceException(
sprintf('Expected type %s', (string)$type),
$blameNode,
$path,
$ex->getMessage(),
$ex
)
]);
}
} | [
"protected",
"function",
"coerceValueForScalarType",
"(",
"$",
"value",
",",
"ScalarType",
"$",
"type",
",",
"NodeInterface",
"$",
"blameNode",
",",
"?",
"Path",
"$",
"path",
")",
":",
"CoercedValue",
"{",
"try",
"{",
"$",
"parseResult",
"=",
"$",
"type",
... | Scalars determine if a value is valid via parseValue(), which can
throw to indicate failure. If it throws, maintain a reference to
the original error.
@param mixed $value
@param ScalarType $type
@param NodeInterface $blameNode
@param Path|null $path
@return CoercedValue | [
"Scalars",
"determine",
"if",
"a",
"value",
"is",
"valid",
"via",
"parseValue",
"()",
"which",
"can",
"throw",
"to",
"indicate",
"failure",
".",
"If",
"it",
"throws",
"maintain",
"a",
"reference",
"to",
"the",
"original",
"error",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Execution/ValuesResolver.php#L332-L357 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.parse | public function parse(Source $source, array $options = []): DocumentNode
{
$this->lexer = $this->createLexer($source, $options);
return $this->lexDocument();
} | php | public function parse(Source $source, array $options = []): DocumentNode
{
$this->lexer = $this->createLexer($source, $options);
return $this->lexDocument();
} | [
"public",
"function",
"parse",
"(",
"Source",
"$",
"source",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"DocumentNode",
"{",
"$",
"this",
"->",
"lexer",
"=",
"$",
"this",
"->",
"createLexer",
"(",
"$",
"source",
",",
"$",
"options",
")",
... | Given a GraphQL source, parses it into a Document.
Throws GraphQLError if a syntax error is encountered.
@inheritdoc
@throws SyntaxErrorException
@throws \ReflectionException
@throws InvariantException | [
"Given",
"a",
"GraphQL",
"source",
"parses",
"it",
"into",
"a",
"Document",
".",
"Throws",
"GraphQLError",
"if",
"a",
"syntax",
"error",
"is",
"encountered",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L99-L104 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexName | protected function lexName(): NameNode
{
$token = $this->expect(TokenKindEnum::NAME);
return new NameNode($token->getValue(), $this->createLocation($token));
} | php | protected function lexName(): NameNode
{
$token = $this->expect(TokenKindEnum::NAME);
return new NameNode($token->getValue(), $this->createLocation($token));
} | [
"protected",
"function",
"lexName",
"(",
")",
":",
"NameNode",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"NAME",
")",
";",
"return",
"new",
"NameNode",
"(",
"$",
"token",
"->",
"getValue",
"(",
")",
",",
"$",
"t... | Converts a name lex token into a name parse node.
@return NameNode
@throws SyntaxErrorException | [
"Converts",
"a",
"name",
"lex",
"token",
"into",
"a",
"name",
"parse",
"node",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L130-L135 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDocument | protected function lexDocument(): DocumentNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::SOF);
$definitions = [];
do {
$definitions[] = $this->lexDefinition();
} while (!$this->skip(TokenKindEnum::EOF));
return new DocumentNode($definitions, $this->createLocation($start));
} | php | protected function lexDocument(): DocumentNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::SOF);
$definitions = [];
do {
$definitions[] = $this->lexDefinition();
} while (!$this->skip(TokenKindEnum::EOF));
return new DocumentNode($definitions, $this->createLocation($start));
} | [
"protected",
"function",
"lexDocument",
"(",
")",
":",
"DocumentNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"SOF",
")",
";",
"$",
"definitions",
"=... | Document : Definition+
@return DocumentNode
@throws SyntaxErrorException
@throws \ReflectionException | [
"Document",
":",
"Definition",
"+"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L146-L159 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDefinition | protected function lexDefinition(): NodeInterface
{
if ($this->peek(TokenKindEnum::NAME)) {
$token = $this->lexer->getToken();
switch ($token->getValue()) {
case KeywordEnum::QUERY:
case KeywordEnum::MUTATION:
case KeywordEnum::SUBSCRIPTION:
case KeywordEnum::FRAGMENT:
return $this->lexExecutableDefinition();
case KeywordEnum::SCHEMA:
case KeywordEnum::SCALAR:
case KeywordEnum::TYPE:
case KeywordEnum::INTERFACE:
case KeywordEnum::UNION:
case KeywordEnum::ENUM:
case KeywordEnum::INPUT:
case KeywordEnum::DIRECTIVE:
return $this->lexTypeSystemDefinition();
case KeywordEnum::EXTEND:
return $this->lexTypeSystemExtension();
}
} elseif ($this->peek(TokenKindEnum::BRACE_L)) {
return $this->lexExecutableDefinition();
} elseif ($this->peekDescription()) {
return $this->lexTypeSystemDefinition();
}
throw $this->unexpected();
} | php | protected function lexDefinition(): NodeInterface
{
if ($this->peek(TokenKindEnum::NAME)) {
$token = $this->lexer->getToken();
switch ($token->getValue()) {
case KeywordEnum::QUERY:
case KeywordEnum::MUTATION:
case KeywordEnum::SUBSCRIPTION:
case KeywordEnum::FRAGMENT:
return $this->lexExecutableDefinition();
case KeywordEnum::SCHEMA:
case KeywordEnum::SCALAR:
case KeywordEnum::TYPE:
case KeywordEnum::INTERFACE:
case KeywordEnum::UNION:
case KeywordEnum::ENUM:
case KeywordEnum::INPUT:
case KeywordEnum::DIRECTIVE:
return $this->lexTypeSystemDefinition();
case KeywordEnum::EXTEND:
return $this->lexTypeSystemExtension();
}
} elseif ($this->peek(TokenKindEnum::BRACE_L)) {
return $this->lexExecutableDefinition();
} elseif ($this->peekDescription()) {
return $this->lexTypeSystemDefinition();
}
throw $this->unexpected();
} | [
"protected",
"function",
"lexDefinition",
"(",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"NAME",
")",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"s... | Definition :
- ExecutableDefinition
- TypeSystemDefinition
@return NodeInterface
@throws SyntaxErrorException
@throws \ReflectionException | [
"Definition",
":",
"-",
"ExecutableDefinition",
"-",
"TypeSystemDefinition"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L170-L201 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexExecutableDefinition | protected function lexExecutableDefinition(): ExecutableDefinitionNodeInterface
{
if ($this->peek(TokenKindEnum::NAME)) {
// Valid names are: query, mutation, subscription and fragment
$token = $this->lexer->getToken();
switch ($token->getValue()) {
case KeywordEnum::QUERY:
case KeywordEnum::MUTATION:
case KeywordEnum::SUBSCRIPTION:
return $this->lexOperationDefinition();
case KeywordEnum::FRAGMENT:
return $this->lexFragmentDefinition();
}
} elseif ($this->peek(TokenKindEnum::BRACE_L)) {
// Anonymous query
return $this->lexOperationDefinition();
}
throw $this->unexpected();
} | php | protected function lexExecutableDefinition(): ExecutableDefinitionNodeInterface
{
if ($this->peek(TokenKindEnum::NAME)) {
// Valid names are: query, mutation, subscription and fragment
$token = $this->lexer->getToken();
switch ($token->getValue()) {
case KeywordEnum::QUERY:
case KeywordEnum::MUTATION:
case KeywordEnum::SUBSCRIPTION:
return $this->lexOperationDefinition();
case KeywordEnum::FRAGMENT:
return $this->lexFragmentDefinition();
}
} elseif ($this->peek(TokenKindEnum::BRACE_L)) {
// Anonymous query
return $this->lexOperationDefinition();
}
throw $this->unexpected();
} | [
"protected",
"function",
"lexExecutableDefinition",
"(",
")",
":",
"ExecutableDefinitionNodeInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"NAME",
")",
")",
"{",
"// Valid names are: query, mutation, subscription and fragment",
"$",
"... | ExecutableDefinition :
- OperationDefinition
- FragmentDefinition
@return ExecutableDefinitionNodeInterface
@throws SyntaxErrorException | [
"ExecutableDefinition",
":",
"-",
"OperationDefinition",
"-",
"FragmentDefinition"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L211-L231 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexOperationDefinition | protected function lexOperationDefinition(): OperationDefinitionNode
{
$start = $this->lexer->getToken();
if ($this->peek(TokenKindEnum::BRACE_L)) {
// Anonymous query
return new OperationDefinitionNode(
KeywordEnum::QUERY,
null,
[],
[],
$this->lexSelectionSet(),
$this->createLocation($start)
);
}
$operation = $this->lexOperationType();
if ($this->peek(TokenKindEnum::NAME)) {
$name = $this->lexName();
}
return new OperationDefinitionNode(
$operation,
$name ?? null,
$this->lexVariableDefinitions(),
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | php | protected function lexOperationDefinition(): OperationDefinitionNode
{
$start = $this->lexer->getToken();
if ($this->peek(TokenKindEnum::BRACE_L)) {
// Anonymous query
return new OperationDefinitionNode(
KeywordEnum::QUERY,
null,
[],
[],
$this->lexSelectionSet(),
$this->createLocation($start)
);
}
$operation = $this->lexOperationType();
if ($this->peek(TokenKindEnum::NAME)) {
$name = $this->lexName();
}
return new OperationDefinitionNode(
$operation,
$name ?? null,
$this->lexVariableDefinitions(),
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexOperationDefinition",
"(",
")",
":",
"OperationDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
"... | OperationDefinition :
- SelectionSet
- OperationType Name? VariableDefinitions? Directives? SelectionSet
@return OperationDefinitionNode
@throws SyntaxErrorException | [
"OperationDefinition",
":",
"-",
"SelectionSet",
"-",
"OperationType",
"Name?",
"VariableDefinitions?",
"Directives?",
"SelectionSet"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L243-L273 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexOperationType | protected function lexOperationType(): ?string
{
$token = $this->expect(TokenKindEnum::NAME);
$value = $token->getValue();
if (isOperation($value)) {
return $value;
}
throw $this->unexpected($token);
} | php | protected function lexOperationType(): ?string
{
$token = $this->expect(TokenKindEnum::NAME);
$value = $token->getValue();
if (isOperation($value)) {
return $value;
}
throw $this->unexpected($token);
} | [
"protected",
"function",
"lexOperationType",
"(",
")",
":",
"?",
"string",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"NAME",
")",
";",
"$",
"value",
"=",
"$",
"token",
"->",
"getValue",
"(",
")",
";",
"if",
"(",... | OperationType : one of query mutation subscription
@return null|string
@throws SyntaxErrorException | [
"OperationType",
":",
"one",
"of",
"query",
"mutation",
"subscription"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L281-L291 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexVariableDefinitions | protected function lexVariableDefinitions(): array
{
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
[$this, 'lexVariableDefinition'],
TokenKindEnum::PAREN_R
)
: [];
} | php | protected function lexVariableDefinitions(): array
{
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
[$this, 'lexVariableDefinition'],
TokenKindEnum::PAREN_R
)
: [];
} | [
"protected",
"function",
"lexVariableDefinitions",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"PAREN_L",
")",
"?",
"$",
"this",
"->",
"many",
"(",
"TokenKindEnum",
"::",
"PAREN_L",
",",
"[",
"$",
"this",
... | VariableDefinitions : ( VariableDefinition+ )
@return array
@throws SyntaxErrorException | [
"VariableDefinitions",
":",
"(",
"VariableDefinition",
"+",
")"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L299-L308 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexVariableDefinition | protected function lexVariableDefinition(): VariableDefinitionNode
{
$start = $this->lexer->getToken();
/**
* @return TypeNodeInterface
*/
$parseType = function (): TypeNodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexType();
};
return new VariableDefinitionNode(
$this->lexVariable(),
$parseType(),
$this->skip(TokenKindEnum::EQUALS)
? $this->lexValue(true)
: null,
$this->createLocation($start)
);
} | php | protected function lexVariableDefinition(): VariableDefinitionNode
{
$start = $this->lexer->getToken();
/**
* @return TypeNodeInterface
*/
$parseType = function (): TypeNodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexType();
};
return new VariableDefinitionNode(
$this->lexVariable(),
$parseType(),
$this->skip(TokenKindEnum::EQUALS)
? $this->lexValue(true)
: null,
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexVariableDefinition",
"(",
")",
":",
"VariableDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"/**\n * @return TypeNodeInterface\n */",
"$",
"parseType",
"=",
"function",... | VariableDefinition : Variable : Type DefaultValue?
@return VariableDefinitionNode
@throws SyntaxErrorException | [
"VariableDefinition",
":",
"Variable",
":",
"Type",
"DefaultValue?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L316-L336 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexVariable | protected function lexVariable(): VariableNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::DOLLAR);
return new VariableNode($this->lexName(), $this->createLocation($start));
} | php | protected function lexVariable(): VariableNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::DOLLAR);
return new VariableNode($this->lexName(), $this->createLocation($start));
} | [
"protected",
"function",
"lexVariable",
"(",
")",
":",
"VariableNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"DOLLAR",
")",
";",
"return",
"new",
"V... | Variable : $ Name
@return VariableNode
@throws SyntaxErrorException | [
"Variable",
":",
"$",
"Name"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L344-L351 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexSelectionSet | protected function lexSelectionSet(): SelectionSetNode
{
$start = $this->lexer->getToken();
return new SelectionSetNode(
$this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexSelection'],
TokenKindEnum::BRACE_R
),
$this->createLocation($start)
);
} | php | protected function lexSelectionSet(): SelectionSetNode
{
$start = $this->lexer->getToken();
return new SelectionSetNode(
$this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexSelection'],
TokenKindEnum::BRACE_R
),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexSelectionSet",
"(",
")",
":",
"SelectionSetNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"return",
"new",
"SelectionSetNode",
"(",
"$",
"this",
"->",
"many",
"(",
"TokenKindEnum",
"... | SelectionSet : { Selection+ }
@return SelectionSetNode
@throws SyntaxErrorException | [
"SelectionSet",
":",
"{",
"Selection",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L359-L371 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexSelection | protected function lexSelection(): NodeInterface
{
return $this->peek(TokenKindEnum::SPREAD)
? $this->lexFragment()
: $this->lexField();
} | php | protected function lexSelection(): NodeInterface
{
return $this->peek(TokenKindEnum::SPREAD)
? $this->lexFragment()
: $this->lexField();
} | [
"protected",
"function",
"lexSelection",
"(",
")",
":",
"NodeInterface",
"{",
"return",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"SPREAD",
")",
"?",
"$",
"this",
"->",
"lexFragment",
"(",
")",
":",
"$",
"this",
"->",
"lexField",
"(",
")",
... | Selection :
- Field
- FragmentSpread
- InlineFragment
@return NodeInterface|FragmentNodeInterface|FieldNode
@throws SyntaxErrorException | [
"Selection",
":",
"-",
"Field",
"-",
"FragmentSpread",
"-",
"InlineFragment"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L382-L387 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexField | protected function lexField(): FieldNode
{
$start = $this->lexer->getToken();
$nameOrAlias = $this->lexName();
if ($this->skip(TokenKindEnum::COLON)) {
$alias = $nameOrAlias;
$name = $this->lexName();
} else {
$name = $nameOrAlias;
}
return new FieldNode(
$alias ?? null,
$name,
$this->lexArguments(false),
$this->lexDirectives(),
$this->peek(TokenKindEnum::BRACE_L)
? $this->lexSelectionSet()
: null,
$this->createLocation($start)
);
} | php | protected function lexField(): FieldNode
{
$start = $this->lexer->getToken();
$nameOrAlias = $this->lexName();
if ($this->skip(TokenKindEnum::COLON)) {
$alias = $nameOrAlias;
$name = $this->lexName();
} else {
$name = $nameOrAlias;
}
return new FieldNode(
$alias ?? null,
$name,
$this->lexArguments(false),
$this->lexDirectives(),
$this->peek(TokenKindEnum::BRACE_L)
? $this->lexSelectionSet()
: null,
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexField",
"(",
")",
":",
"FieldNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"nameOrAlias",
"=",
"$",
"this",
"->",
"lexName",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->"... | Field : Alias? Name Arguments? Directives? SelectionSet?
Alias : Name :
@return FieldNode
@throws SyntaxErrorException | [
"Field",
":",
"Alias?",
"Name",
"Arguments?",
"Directives?",
"SelectionSet?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L397-L420 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexArguments | protected function lexArguments(bool $isConst = false): ?array
{
/**
* @return ArgumentNode
*/
$parseFunction = function () use ($isConst): ArgumentNode {
return $this->lexArgument($isConst);
};
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
$parseFunction,
TokenKindEnum::PAREN_R
)
: [];
} | php | protected function lexArguments(bool $isConst = false): ?array
{
/**
* @return ArgumentNode
*/
$parseFunction = function () use ($isConst): ArgumentNode {
return $this->lexArgument($isConst);
};
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
$parseFunction,
TokenKindEnum::PAREN_R
)
: [];
} | [
"protected",
"function",
"lexArguments",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"?",
"array",
"{",
"/**\n * @return ArgumentNode\n */",
"$",
"parseFunction",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"isConst",
")",
":",
"Argument... | Arguments[Const] : ( Argument[?Const]+ )
@param bool $isConst
@return array
@throws SyntaxErrorException | [
"Arguments",
"[",
"Const",
"]",
":",
"(",
"Argument",
"[",
"?Const",
"]",
"+",
")"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L429-L445 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexArgument | protected function lexArgument(bool $isConst = false): ArgumentNode
{
$start = $this->lexer->getToken();
/**
* @return NodeInterface|TypeNodeInterface|ValueNodeInterface
*/
$parseValue = function () use ($isConst): NodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexValue($isConst);
};
return new ArgumentNode(
$this->lexName(),
$parseValue(),
$this->createLocation($start)
);
} | php | protected function lexArgument(bool $isConst = false): ArgumentNode
{
$start = $this->lexer->getToken();
/**
* @return NodeInterface|TypeNodeInterface|ValueNodeInterface
*/
$parseValue = function () use ($isConst): NodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexValue($isConst);
};
return new ArgumentNode(
$this->lexName(),
$parseValue(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexArgument",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"ArgumentNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"/**\n * @return NodeInterface|TypeNodeInterface|ValueNodeInterf... | Argument[Const] : Name : Value[?Const]
@param bool $isConst
@return ArgumentNode
@throws SyntaxErrorException | [
"Argument",
"[",
"Const",
"]",
":",
"Name",
":",
"Value",
"[",
"?Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L454-L471 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexFragment | protected function lexFragment(): FragmentNodeInterface
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::SPREAD);
$token = $this->lexer->getToken();
if (KeywordEnum::ON !== $token->getValue() && $this->peek(TokenKindEnum::NAME)) {
return new FragmentSpreadNode(
$this->lexFragmentName($token),
$this->lexDirectives(),
null,
$this->createLocation($start)
);
}
if (KeywordEnum::ON === $token->getValue()) {
$this->lexer->advance();
$typeCondition = $this->lexNamedType();
}
return new InlineFragmentNode(
$typeCondition ?? null,
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | php | protected function lexFragment(): FragmentNodeInterface
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::SPREAD);
$token = $this->lexer->getToken();
if (KeywordEnum::ON !== $token->getValue() && $this->peek(TokenKindEnum::NAME)) {
return new FragmentSpreadNode(
$this->lexFragmentName($token),
$this->lexDirectives(),
null,
$this->createLocation($start)
);
}
if (KeywordEnum::ON === $token->getValue()) {
$this->lexer->advance();
$typeCondition = $this->lexNamedType();
}
return new InlineFragmentNode(
$typeCondition ?? null,
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexFragment",
"(",
")",
":",
"FragmentNodeInterface",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"SPREAD",
")",
";",
"$",
"token"... | Corresponds to both FragmentSpread and InlineFragment in the spec.
FragmentSpread : ... FragmentName Directives?
InlineFragment : ... TypeCondition? Directives? SelectionSet
@return FragmentNodeInterface
@throws SyntaxErrorException | [
"Corresponds",
"to",
"both",
"FragmentSpread",
"and",
"InlineFragment",
"in",
"the",
"spec",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L485-L513 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexFragmentDefinition | protected function lexFragmentDefinition(): FragmentDefinitionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::FRAGMENT);
$parseTypeCondition = function () {
$this->expectKeyword(KeywordEnum::ON);
return $this->lexNamedType();
};
return new FragmentDefinitionNode(
$this->lexFragmentName(),
$this->lexVariableDefinitions(),
$parseTypeCondition(),
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | php | protected function lexFragmentDefinition(): FragmentDefinitionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::FRAGMENT);
$parseTypeCondition = function () {
$this->expectKeyword(KeywordEnum::ON);
return $this->lexNamedType();
};
return new FragmentDefinitionNode(
$this->lexFragmentName(),
$this->lexVariableDefinitions(),
$parseTypeCondition(),
$this->lexDirectives(),
$this->lexSelectionSet(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexFragmentDefinition",
"(",
")",
":",
"FragmentDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"FRAGMENT",
")",
";"... | FragmentDefinition :
- fragment FragmentName on TypeCondition Directives? SelectionSet
TypeCondition : NamedType
@return FragmentDefinitionNode
@throws SyntaxErrorException | [
"FragmentDefinition",
":",
"-",
"fragment",
"FragmentName",
"on",
"TypeCondition",
"Directives?",
"SelectionSet"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L524-L543 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexFragmentName | protected function lexFragmentName(?Token $token = null): NameNode
{
if (null === $token) {
$token = $this->lexer->getToken();
}
if (KeywordEnum::ON === $token->getValue()) {
throw $this->unexpected();
}
return $this->lexName();
} | php | protected function lexFragmentName(?Token $token = null): NameNode
{
if (null === $token) {
$token = $this->lexer->getToken();
}
if (KeywordEnum::ON === $token->getValue()) {
throw $this->unexpected();
}
return $this->lexName();
} | [
"protected",
"function",
"lexFragmentName",
"(",
"?",
"Token",
"$",
"token",
"=",
"null",
")",
":",
"NameNode",
"{",
"if",
"(",
"null",
"===",
"$",
"token",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"... | FragmentName : Name but not `on`
@param Token|null $token
@return NameNode
@throws SyntaxErrorException | [
"FragmentName",
":",
"Name",
"but",
"not",
"on"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L552-L563 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexValue | protected function lexValue(bool $isConst = false): NodeInterface
{
$token = $this->lexer->getToken();
$value = $token->getValue();
switch ($token->getKind()) {
case TokenKindEnum::BRACKET_L:
return $this->lexList($isConst);
case TokenKindEnum::BRACE_L:
return $this->lexObject($isConst);
case TokenKindEnum::INT:
$this->lexer->advance();
return new IntValueNode($value, $this->createLocation($token));
case TokenKindEnum::FLOAT:
$this->lexer->advance();
return new FloatValueNode($value, $this->createLocation($token));
case TokenKindEnum::STRING:
case TokenKindEnum::BLOCK_STRING:
return $this->lexStringLiteral();
case TokenKindEnum::NAME:
if ($value === 'true' || $value === 'false') {
$this->lexer->advance();
return new BooleanValueNode($value === 'true', $this->createLocation($token));
}
if ($value === 'null') {
$this->lexer->advance();
return new NullValueNode($this->createLocation($token));
}
$this->lexer->advance();
return new EnumValueNode($value, $this->createLocation($token));
case TokenKindEnum::DOLLAR:
if (!$isConst) {
return $this->lexVariable();
}
break;
}
throw $this->unexpected();
} | php | protected function lexValue(bool $isConst = false): NodeInterface
{
$token = $this->lexer->getToken();
$value = $token->getValue();
switch ($token->getKind()) {
case TokenKindEnum::BRACKET_L:
return $this->lexList($isConst);
case TokenKindEnum::BRACE_L:
return $this->lexObject($isConst);
case TokenKindEnum::INT:
$this->lexer->advance();
return new IntValueNode($value, $this->createLocation($token));
case TokenKindEnum::FLOAT:
$this->lexer->advance();
return new FloatValueNode($value, $this->createLocation($token));
case TokenKindEnum::STRING:
case TokenKindEnum::BLOCK_STRING:
return $this->lexStringLiteral();
case TokenKindEnum::NAME:
if ($value === 'true' || $value === 'false') {
$this->lexer->advance();
return new BooleanValueNode($value === 'true', $this->createLocation($token));
}
if ($value === 'null') {
$this->lexer->advance();
return new NullValueNode($this->createLocation($token));
}
$this->lexer->advance();
return new EnumValueNode($value, $this->createLocation($token));
case TokenKindEnum::DOLLAR:
if (!$isConst) {
return $this->lexVariable();
}
break;
}
throw $this->unexpected();
} | [
"protected",
"function",
"lexValue",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"NodeInterface",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"value",
"=",
"$",
"token",
"->",
"getValue",
"(",
")... | Value[Const] :
- [~Const] Variable
- IntValue
- FloatValue
- StringValue
- BooleanValue
- NullValue
- EnumValue
- ListValue[?Const]
- ObjectValue[?Const]
BooleanValue : one of `true` `false`
NullValue : `null`
EnumValue : Name but not `true`, `false` or `null`
@param bool $isConst
@return NodeInterface|ValueNodeInterface|TypeNodeInterface
@throws SyntaxErrorException | [
"Value",
"[",
"Const",
"]",
":",
"-",
"[",
"~Const",
"]",
"Variable",
"-",
"IntValue",
"-",
"FloatValue",
"-",
"StringValue",
"-",
"BooleanValue",
"-",
"NullValue",
"-",
"EnumValue",
"-",
"ListValue",
"[",
"?Const",
"]",
"-",
"ObjectValue",
"[",
"?Const",
... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L589-L629 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexList | protected function lexList(bool $isConst): ListValueNode
{
$start = $this->lexer->getToken();
$parseFunction = function () use ($isConst) {
return $this->lexValue($isConst);
};
return new ListValueNode(
$this->any(
TokenKindEnum::BRACKET_L,
$parseFunction,
TokenKindEnum::BRACKET_R
),
$this->createLocation($start)
);
} | php | protected function lexList(bool $isConst): ListValueNode
{
$start = $this->lexer->getToken();
$parseFunction = function () use ($isConst) {
return $this->lexValue($isConst);
};
return new ListValueNode(
$this->any(
TokenKindEnum::BRACKET_L,
$parseFunction,
TokenKindEnum::BRACKET_R
),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexList",
"(",
"bool",
"$",
"isConst",
")",
":",
"ListValueNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"parseFunction",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"isConst"... | ListValue[Const] :
- [ ]
- [ Value[?Const]+ ]
@param bool $isConst
@return ListValueNode
@throws SyntaxErrorException | [
"ListValue",
"[",
"Const",
"]",
":",
"-",
"[",
"]",
"-",
"[",
"Value",
"[",
"?Const",
"]",
"+",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L656-L672 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexObject | protected function lexObject(bool $isConst): ObjectValueNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::BRACE_L);
$fields = [];
while (!$this->skip(TokenKindEnum::BRACE_R)) {
$fields[] = $this->lexObjectField($isConst);
}
return new ObjectValueNode($fields, $this->createLocation($start));
} | php | protected function lexObject(bool $isConst): ObjectValueNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::BRACE_L);
$fields = [];
while (!$this->skip(TokenKindEnum::BRACE_R)) {
$fields[] = $this->lexObjectField($isConst);
}
return new ObjectValueNode($fields, $this->createLocation($start));
} | [
"protected",
"function",
"lexObject",
"(",
"bool",
"$",
"isConst",
")",
":",
"ObjectValueNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
")",
... | ObjectValue[Const] :
- { }
- { ObjectField[?Const]+ }
@param bool $isConst
@return ObjectValueNode
@throws SyntaxErrorException | [
"ObjectValue",
"[",
"Const",
"]",
":",
"-",
"{",
"}",
"-",
"{",
"ObjectField",
"[",
"?Const",
"]",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L683-L696 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexObjectField | protected function lexObjectField(bool $isConst): ObjectFieldNode
{
$start = $this->lexer->getToken();
/**
* @param bool $isConst
* @return NodeInterface|TypeNodeInterface|ValueNodeInterface
*/
$parseValue = function (bool $isConst): NodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexValue($isConst);
};
return new ObjectFieldNode(
$this->lexName(),
$parseValue($isConst),
$this->createLocation($start)
);
} | php | protected function lexObjectField(bool $isConst): ObjectFieldNode
{
$start = $this->lexer->getToken();
/**
* @param bool $isConst
* @return NodeInterface|TypeNodeInterface|ValueNodeInterface
*/
$parseValue = function (bool $isConst): NodeInterface {
$this->expect(TokenKindEnum::COLON);
return $this->lexValue($isConst);
};
return new ObjectFieldNode(
$this->lexName(),
$parseValue($isConst),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexObjectField",
"(",
"bool",
"$",
"isConst",
")",
":",
"ObjectFieldNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"/**\n * @param bool $isConst\n * @return NodeInterface|TypeNodeInte... | ObjectField[Const] : Name : Value[?Const]
@param bool $isConst
@return ObjectFieldNode
@throws SyntaxErrorException | [
"ObjectField",
"[",
"Const",
"]",
":",
"Name",
":",
"Value",
"[",
"?Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L705-L723 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDirectives | protected function lexDirectives(bool $isConst = false): array
{
$directives = [];
while ($this->peek(TokenKindEnum::AT)) {
$directives[] = $this->lexDirective($isConst);
}
return $directives;
} | php | protected function lexDirectives(bool $isConst = false): array
{
$directives = [];
while ($this->peek(TokenKindEnum::AT)) {
$directives[] = $this->lexDirective($isConst);
}
return $directives;
} | [
"protected",
"function",
"lexDirectives",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"array",
"{",
"$",
"directives",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"AT",
")",
")",
"{",
"$",
"direct... | Directives[Const] : Directive[?Const]+
@param bool $isConst
@return array
@throws SyntaxErrorException | [
"Directives",
"[",
"Const",
"]",
":",
"Directive",
"[",
"?Const",
"]",
"+"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L734-L743 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDirective | protected function lexDirective(bool $isConst = false): DirectiveNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::AT);
return new DirectiveNode(
$this->lexName(),
$this->lexArguments($isConst),
$this->createLocation($start)
);
} | php | protected function lexDirective(bool $isConst = false): DirectiveNode
{
$start = $this->lexer->getToken();
$this->expect(TokenKindEnum::AT);
return new DirectiveNode(
$this->lexName(),
$this->lexArguments($isConst),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexDirective",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"DirectiveNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expect",
"(",
"TokenKindEnum",
"::",
... | Directive[Const] : @ Name Arguments[?Const]?
@param bool $isConst
@return DirectiveNode
@throws SyntaxErrorException | [
"Directive",
"[",
"Const",
"]",
":",
"@",
"Name",
"Arguments",
"[",
"?Const",
"]",
"?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L752-L763 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexType | protected function lexType(): TypeNodeInterface
{
$start = $this->lexer->getToken();
if ($this->skip(TokenKindEnum::BRACKET_L)) {
$type = $this->lexType();
$this->expect(TokenKindEnum::BRACKET_R);
$type = new ListTypeNode($type, $this->createLocation($start));
} else {
$type = $this->lexNamedType();
}
if ($this->skip(TokenKindEnum::BANG)) {
return new NonNullTypeNode($type, $this->createLocation($start));
}
return $type;
} | php | protected function lexType(): TypeNodeInterface
{
$start = $this->lexer->getToken();
if ($this->skip(TokenKindEnum::BRACKET_L)) {
$type = $this->lexType();
$this->expect(TokenKindEnum::BRACKET_R);
$type = new ListTypeNode($type, $this->createLocation($start));
} else {
$type = $this->lexNamedType();
}
if ($this->skip(TokenKindEnum::BANG)) {
return new NonNullTypeNode($type, $this->createLocation($start));
}
return $type;
} | [
"protected",
"function",
"lexType",
"(",
")",
":",
"TypeNodeInterface",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"skip",
"(",
"TokenKindEnum",
"::",
"BRACKET_L",
")",
")",
"{",
... | Type :
- NamedType
- ListType
- NonNullType
@return TypeNodeInterface
@throws SyntaxErrorException | [
"Type",
":",
"-",
"NamedType",
"-",
"ListType",
"-",
"NonNullType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L776-L795 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexNamedType | protected function lexNamedType(): NamedTypeNode
{
$start = $this->lexer->getToken();
return new NamedTypeNode($this->lexName(), $this->createLocation($start));
} | php | protected function lexNamedType(): NamedTypeNode
{
$start = $this->lexer->getToken();
return new NamedTypeNode($this->lexName(), $this->createLocation($start));
} | [
"protected",
"function",
"lexNamedType",
"(",
")",
":",
"NamedTypeNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"return",
"new",
"NamedTypeNode",
"(",
"$",
"this",
"->",
"lexName",
"(",
")",
",",
"$",
"this... | NamedType : Name
@return NamedTypeNode
@throws SyntaxErrorException | [
"NamedType",
":",
"Name"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L803-L808 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexTypeSystemDefinition | protected function lexTypeSystemDefinition(): TypeSystemDefinitionNodeInterface
{
// Many definitions begin with a description and require a lookahead.
$token = $this->peekDescription()
? $this->lexer->lookahead()
: $this->lexer->getToken();
if (TokenKindEnum::NAME === $token->getKind()) {
switch ($token->getValue()) {
case KeywordEnum::SCHEMA:
return $this->lexSchemaDefinition();
case KeywordEnum::SCALAR:
return $this->lexScalarTypeDefinition();
case KeywordEnum::TYPE:
return $this->lexObjectTypeDefinition();
case KeywordEnum::INTERFACE:
return $this->lexInterfaceTypeDefinition();
case KeywordEnum::UNION:
return $this->lexUnionTypeDefinition();
case KeywordEnum::ENUM:
return $this->lexEnumTypeDefinition();
case KeywordEnum::INPUT:
return $this->lexInputObjectTypeDefinition();
case KeywordEnum::DIRECTIVE:
return $this->lexDirectiveDefinition();
}
}
throw $this->unexpected($token);
} | php | protected function lexTypeSystemDefinition(): TypeSystemDefinitionNodeInterface
{
// Many definitions begin with a description and require a lookahead.
$token = $this->peekDescription()
? $this->lexer->lookahead()
: $this->lexer->getToken();
if (TokenKindEnum::NAME === $token->getKind()) {
switch ($token->getValue()) {
case KeywordEnum::SCHEMA:
return $this->lexSchemaDefinition();
case KeywordEnum::SCALAR:
return $this->lexScalarTypeDefinition();
case KeywordEnum::TYPE:
return $this->lexObjectTypeDefinition();
case KeywordEnum::INTERFACE:
return $this->lexInterfaceTypeDefinition();
case KeywordEnum::UNION:
return $this->lexUnionTypeDefinition();
case KeywordEnum::ENUM:
return $this->lexEnumTypeDefinition();
case KeywordEnum::INPUT:
return $this->lexInputObjectTypeDefinition();
case KeywordEnum::DIRECTIVE:
return $this->lexDirectiveDefinition();
}
}
throw $this->unexpected($token);
} | [
"protected",
"function",
"lexTypeSystemDefinition",
"(",
")",
":",
"TypeSystemDefinitionNodeInterface",
"{",
"// Many definitions begin with a description and require a lookahead.",
"$",
"token",
"=",
"$",
"this",
"->",
"peekDescription",
"(",
")",
"?",
"$",
"this",
"->",
... | TypeSystemDefinition :
- SchemaDefinition
- TypeDefinition
- TypeExtension
- DirectiveDefinition
TypeDefinition :
- ScalarTypeDefinition
- ObjectTypeDefinition
- InterfaceTypeDefinition
- UnionTypeDefinition
- EnumTypeDefinition
- InputObjectTypeDefinition
@return TypeSystemDefinitionNodeInterface
@throws SyntaxErrorException
@throws \ReflectionException | [
"TypeSystemDefinition",
":",
"-",
"SchemaDefinition",
"-",
"TypeDefinition",
"-",
"TypeExtension",
"-",
"DirectiveDefinition"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L831-L860 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexSchemaDefinition | protected function lexSchemaDefinition(): SchemaDefinitionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::SCHEMA);
return new SchemaDefinitionNode(
$this->lexDirectives(),
$this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexOperationTypeDefinition'],
TokenKindEnum::BRACE_R
),
$this->createLocation($start)
);
} | php | protected function lexSchemaDefinition(): SchemaDefinitionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::SCHEMA);
return new SchemaDefinitionNode(
$this->lexDirectives(),
$this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexOperationTypeDefinition'],
TokenKindEnum::BRACE_R
),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexSchemaDefinition",
"(",
")",
":",
"SchemaDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"SCHEMA",
")",
";",
"r... | SchemaDefinition : schema Directives[Const]? { OperationTypeDefinition+ }
@return SchemaDefinitionNode
@throws SyntaxErrorException | [
"SchemaDefinition",
":",
"schema",
"Directives",
"[",
"Const",
"]",
"?",
"{",
"OperationTypeDefinition",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L888-L903 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexOperationTypeDefinition | protected function lexOperationTypeDefinition(): OperationTypeDefinitionNode
{
$start = $this->lexer->getToken();
$operation = $this->lexOperationType();
$this->expect(TokenKindEnum::COLON);
return new OperationTypeDefinitionNode(
$operation,
$this->lexNamedType(),
$this->createLocation($start)
);
} | php | protected function lexOperationTypeDefinition(): OperationTypeDefinitionNode
{
$start = $this->lexer->getToken();
$operation = $this->lexOperationType();
$this->expect(TokenKindEnum::COLON);
return new OperationTypeDefinitionNode(
$operation,
$this->lexNamedType(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexOperationTypeDefinition",
"(",
")",
":",
"OperationTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"operation",
"=",
"$",
"this",
"->",
"lexOperationType",
"(",
")",
... | OperationTypeDefinition : OperationType : NamedType
@return OperationTypeDefinitionNode
@throws SyntaxErrorException | [
"OperationTypeDefinition",
":",
"OperationType",
":",
"NamedType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L911-L924 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexScalarTypeDefinition | protected function lexScalarTypeDefinition(): ScalarTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::SCALAR);
return new ScalarTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | php | protected function lexScalarTypeDefinition(): ScalarTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::SCALAR);
return new ScalarTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexScalarTypeDefinition",
"(",
")",
":",
"ScalarTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
... | ScalarTypeDefinition : Description? scalar Name Directives[Const]?
@return ScalarTypeDefinitionNode
@throws SyntaxErrorException | [
"ScalarTypeDefinition",
":",
"Description?",
"scalar",
"Name",
"Directives",
"[",
"Const",
"]",
"?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L932-L946 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexObjectTypeDefinition | protected function lexObjectTypeDefinition(): ObjectTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::TYPE);
return new ObjectTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexImplementsInterfaces(),
$this->lexDirectives(),
$this->lexFieldsDefinition(),
$this->createLocation($start)
);
} | php | protected function lexObjectTypeDefinition(): ObjectTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::TYPE);
return new ObjectTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexImplementsInterfaces(),
$this->lexDirectives(),
$this->lexFieldsDefinition(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexObjectTypeDefinition",
"(",
")",
":",
"ObjectTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
... | ObjectTypeDefinition :
Description?
type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition?
@return ObjectTypeDefinitionNode
@throws SyntaxErrorException | [
"ObjectTypeDefinition",
":",
"Description?",
"type",
"Name",
"ImplementsInterfaces?",
"Directives",
"[",
"Const",
"]",
"?",
"FieldsDefinition?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L956-L972 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexImplementsInterfaces | protected function lexImplementsInterfaces(): array
{
$types = [];
$token = $this->lexer->getToken();
if ('implements' === $token->getValue()) {
$this->lexer->advance();
// Optional leading ampersand
$this->skip(TokenKindEnum::AMP);
do {
$types[] = $this->lexNamedType();
} while ($this->skip(TokenKindEnum::AMP));
}
return $types;
} | php | protected function lexImplementsInterfaces(): array
{
$types = [];
$token = $this->lexer->getToken();
if ('implements' === $token->getValue()) {
$this->lexer->advance();
// Optional leading ampersand
$this->skip(TokenKindEnum::AMP);
do {
$types[] = $this->lexNamedType();
} while ($this->skip(TokenKindEnum::AMP));
}
return $types;
} | [
"protected",
"function",
"lexImplementsInterfaces",
"(",
")",
":",
"array",
"{",
"$",
"types",
"=",
"[",
"]",
";",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"if",
"(",
"'implements'",
"===",
"$",
"token",
"->",
"... | ImplementsInterfaces :
- implements `&`? NamedType
- ImplementsInterfaces & NamedType
@return array
@throws SyntaxErrorException | [
"ImplementsInterfaces",
":",
"-",
"implements",
"&",
"?",
"NamedType",
"-",
"ImplementsInterfaces",
"&",
"NamedType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L982-L1000 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexFieldsDefinition | protected function lexFieldsDefinition(): array
{
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexFieldDefinition'],
TokenKindEnum::BRACE_R
)
: [];
} | php | protected function lexFieldsDefinition(): array
{
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexFieldDefinition'],
TokenKindEnum::BRACE_R
)
: [];
} | [
"protected",
"function",
"lexFieldsDefinition",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
")",
"?",
"$",
"this",
"->",
"many",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
",",
"[",
"$",
"this",
",... | FieldsDefinition : { FieldDefinition+ }
@return array
@throws SyntaxErrorException | [
"FieldsDefinition",
":",
"{",
"FieldDefinition",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1008-L1017 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.