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 |
|---|---|---|---|---|---|---|---|---|---|---|
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexFieldDefinition | protected function lexFieldDefinition(): FieldDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$name = $this->lexName();
$arguments = $this->lexArgumentsDefinition();
$this->expect(TokenKindEnum::COLON);
return new FieldDefinitionNode(
$description,
$name,
$arguments,
$this->lexType(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | php | protected function lexFieldDefinition(): FieldDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$name = $this->lexName();
$arguments = $this->lexArgumentsDefinition();
$this->expect(TokenKindEnum::COLON);
return new FieldDefinitionNode(
$description,
$name,
$arguments,
$this->lexType(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexFieldDefinition",
"(",
")",
":",
"FieldDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
"$",
"n... | FieldDefinition :
- Description? Name ArgumentsDefinition? : Type Directives[Const]?
@return FieldDefinitionNode
@throws SyntaxErrorException | [
"FieldDefinition",
":",
"-",
"Description?",
"Name",
"ArgumentsDefinition?",
":",
"Type",
"Directives",
"[",
"Const",
"]",
"?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1026-L1044 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexArgumentsDefinition | protected function lexArgumentsDefinition(): array
{
$parseFunction = function (): InputValueDefinitionNode {
return $this->lexInputValueDefinition();
};
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
$parseFunction,
TokenKindEnum::PAREN_R
)
: [];
} | php | protected function lexArgumentsDefinition(): array
{
$parseFunction = function (): InputValueDefinitionNode {
return $this->lexInputValueDefinition();
};
return $this->peek(TokenKindEnum::PAREN_L)
? $this->many(
TokenKindEnum::PAREN_L,
$parseFunction,
TokenKindEnum::PAREN_R
)
: [];
} | [
"protected",
"function",
"lexArgumentsDefinition",
"(",
")",
":",
"array",
"{",
"$",
"parseFunction",
"=",
"function",
"(",
")",
":",
"InputValueDefinitionNode",
"{",
"return",
"$",
"this",
"->",
"lexInputValueDefinition",
"(",
")",
";",
"}",
";",
"return",
"$... | ArgumentsDefinition : ( InputValueDefinition+ )
@return InputValueDefinitionNode[]
@throws SyntaxErrorException | [
"ArgumentsDefinition",
":",
"(",
"InputValueDefinition",
"+",
")"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1052-L1065 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInputValueDefinition | protected function lexInputValueDefinition(): InputValueDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$name = $this->lexName();
$this->expect(TokenKindEnum::COLON);
return new InputValueDefinitionNode(
$description,
$name,
$this->lexType(),
$this->skip(TokenKindEnum::EQUALS)
? $this->lexValue(true)
: null,
$this->lexDirectives(true),
$this->createLocation($start)
);
} | php | protected function lexInputValueDefinition(): InputValueDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$name = $this->lexName();
$this->expect(TokenKindEnum::COLON);
return new InputValueDefinitionNode(
$description,
$name,
$this->lexType(),
$this->skip(TokenKindEnum::EQUALS)
? $this->lexValue(true)
: null,
$this->lexDirectives(true),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexInputValueDefinition",
"(",
")",
":",
"InputValueDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
... | InputValueDefinition :
- Description? Name : Type DefaultValue? Directives[Const]?
@return InputValueDefinitionNode
@throws SyntaxErrorException | [
"InputValueDefinition",
":",
"-",
"Description?",
"Name",
":",
"Type",
"DefaultValue?",
"Directives",
"[",
"Const",
"]",
"?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1074-L1093 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInterfaceTypeDefinition | protected function lexInterfaceTypeDefinition(): InterfaceTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::INTERFACE);
return new InterfaceTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexFieldsDefinition(),
$this->createLocation($start)
);
} | php | protected function lexInterfaceTypeDefinition(): InterfaceTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::INTERFACE);
return new InterfaceTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexFieldsDefinition(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexInterfaceTypeDefinition",
"(",
")",
":",
"InterfaceTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
... | InterfaceTypeDefinition :
- Description? interface Name Directives[Const]? FieldsDefinition?
@return InterfaceTypeDefinitionNode
@throws SyntaxErrorException | [
"InterfaceTypeDefinition",
":",
"-",
"Description?",
"interface",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"FieldsDefinition?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1102-L1117 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexUnionTypeDefinition | protected function lexUnionTypeDefinition(): UnionTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::UNION);
return new UnionTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexUnionMemberTypes(),
$this->createLocation($start)
);
} | php | protected function lexUnionTypeDefinition(): UnionTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::UNION);
return new UnionTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexUnionMemberTypes(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexUnionTypeDefinition",
"(",
")",
":",
"UnionTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
"... | UnionTypeDefinition :
- Description? union Name Directives[Const]? UnionMemberTypes?
@return UnionTypeDefinitionNode
@throws SyntaxErrorException | [
"UnionTypeDefinition",
":",
"-",
"Description?",
"union",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"UnionMemberTypes?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1126-L1141 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexUnionMemberTypes | protected function lexUnionMemberTypes(): array
{
$types = [];
if ($this->skip(TokenKindEnum::EQUALS)) {
// Optional leading pipe
$this->skip(TokenKindEnum::PIPE);
do {
$types[] = $this->lexNamedType();
} while ($this->skip(TokenKindEnum::PIPE));
}
return $types;
} | php | protected function lexUnionMemberTypes(): array
{
$types = [];
if ($this->skip(TokenKindEnum::EQUALS)) {
// Optional leading pipe
$this->skip(TokenKindEnum::PIPE);
do {
$types[] = $this->lexNamedType();
} while ($this->skip(TokenKindEnum::PIPE));
}
return $types;
} | [
"protected",
"function",
"lexUnionMemberTypes",
"(",
")",
":",
"array",
"{",
"$",
"types",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"skip",
"(",
"TokenKindEnum",
"::",
"EQUALS",
")",
")",
"{",
"// Optional leading pipe",
"$",
"this",
"->",
"skip... | UnionMemberTypes :
- = `|`? NamedType
- UnionMemberTypes | NamedType
@return array
@throws SyntaxErrorException | [
"UnionMemberTypes",
":",
"-",
"=",
"|",
"?",
"NamedType",
"-",
"UnionMemberTypes",
"|",
"NamedType"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1151-L1165 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexEnumTypeDefinition | protected function lexEnumTypeDefinition(): EnumTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::ENUM);
return new EnumTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexEnumValuesDefinition(),
$this->createLocation($start)
);
} | php | protected function lexEnumTypeDefinition(): EnumTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::ENUM);
return new EnumTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(),
$this->lexEnumValuesDefinition(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexEnumTypeDefinition",
"(",
")",
":",
"EnumTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
"$"... | EnumTypeDefinition :
- Description? enum Name Directives[Const]? EnumValuesDefinition?
@return EnumTypeDefinitionNode
@throws SyntaxErrorException | [
"EnumTypeDefinition",
":",
"-",
"Description?",
"enum",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"EnumValuesDefinition?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1174-L1189 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexEnumValuesDefinition | protected function lexEnumValuesDefinition(): array
{
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexEnumValueDefinition'],
TokenKindEnum::BRACE_R
)
: [];
} | php | protected function lexEnumValuesDefinition(): array
{
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
[$this, 'lexEnumValueDefinition'],
TokenKindEnum::BRACE_R
)
: [];
} | [
"protected",
"function",
"lexEnumValuesDefinition",
"(",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"peek",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
")",
"?",
"$",
"this",
"->",
"many",
"(",
"TokenKindEnum",
"::",
"BRACE_L",
",",
"[",
"$",
"this",
... | EnumValuesDefinition : { EnumValueDefinition+ }
@return array
@throws SyntaxErrorException | [
"EnumValuesDefinition",
":",
"{",
"EnumValueDefinition",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1197-L1206 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexEnumValueDefinition | protected function lexEnumValueDefinition(): EnumValueDefinitionNode
{
$start = $this->lexer->getToken();
return new EnumValueDefinitionNode(
$this->lexDescription(),
$this->lexName(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | php | protected function lexEnumValueDefinition(): EnumValueDefinitionNode
{
$start = $this->lexer->getToken();
return new EnumValueDefinitionNode(
$this->lexDescription(),
$this->lexName(),
$this->lexDirectives(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexEnumValueDefinition",
"(",
")",
":",
"EnumValueDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"return",
"new",
"EnumValueDefinitionNode",
"(",
"$",
"this",
"->",
"lexDescription"... | EnumValueDefinition : Description? EnumValue Directives[Const]?
EnumValue : Name
@return EnumValueDefinitionNode
@throws SyntaxErrorException | [
"EnumValueDefinition",
":",
"Description?",
"EnumValue",
"Directives",
"[",
"Const",
"]",
"?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1216-L1226 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInputObjectTypeDefinition | protected function lexInputObjectTypeDefinition(): InputObjectTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::INPUT);
return new InputObjectTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(true),
$this->lexInputFieldsDefinition(),
$this->createLocation($start)
);
} | php | protected function lexInputObjectTypeDefinition(): InputObjectTypeDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::INPUT);
return new InputObjectTypeDefinitionNode(
$description,
$this->lexName(),
$this->lexDirectives(true),
$this->lexInputFieldsDefinition(),
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexInputObjectTypeDefinition",
"(",
")",
":",
"InputObjectTypeDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")"... | InputObjectTypeDefinition :
- Description? input Name Directives[Const]? InputFieldsDefinition?
@return InputObjectTypeDefinitionNode
@throws SyntaxErrorException | [
"InputObjectTypeDefinition",
":",
"-",
"Description?",
"input",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"InputFieldsDefinition?"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1235-L1250 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInputFieldsDefinition | protected function lexInputFieldsDefinition(): array
{
$parseFunction = function (): InputValueDefinitionNode {
return $this->lexInputValueDefinition();
};
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
$parseFunction,
TokenKindEnum::BRACE_R
)
: [];
} | php | protected function lexInputFieldsDefinition(): array
{
$parseFunction = function (): InputValueDefinitionNode {
return $this->lexInputValueDefinition();
};
return $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
$parseFunction,
TokenKindEnum::BRACE_R
)
: [];
} | [
"protected",
"function",
"lexInputFieldsDefinition",
"(",
")",
":",
"array",
"{",
"$",
"parseFunction",
"=",
"function",
"(",
")",
":",
"InputValueDefinitionNode",
"{",
"return",
"$",
"this",
"->",
"lexInputValueDefinition",
"(",
")",
";",
"}",
";",
"return",
... | InputFieldsDefinition : { InputValueDefinition+ }
@return array
@throws SyntaxErrorException | [
"InputFieldsDefinition",
":",
"{",
"InputValueDefinition",
"+",
"}"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1258-L1271 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexTypeSystemExtension | protected function lexTypeSystemExtension(): TypeSystemExtensionNodeInterface
{
$token = $this->lexer->lookahead();
if (TokenKindEnum::NAME === $token->getKind()) {
switch ($token->getValue()) {
case KeywordEnum::SCHEMA:
return $this->lexSchemaExtension();
case KeywordEnum::SCALAR:
return $this->lexScalarTypeExtension(false);
case KeywordEnum::TYPE:
return $this->lexObjectTypeExtension();
case KeywordEnum::INTERFACE:
return $this->lexInterfaceTypeExtension();
case KeywordEnum::UNION:
return $this->lexUnionTypeExtension();
case KeywordEnum::ENUM:
return $this->lexEnumTypeExtension();
case KeywordEnum::INPUT:
return $this->lexInputObjectTypeExtension();
}
}
throw $this->unexpected($token);
} | php | protected function lexTypeSystemExtension(): TypeSystemExtensionNodeInterface
{
$token = $this->lexer->lookahead();
if (TokenKindEnum::NAME === $token->getKind()) {
switch ($token->getValue()) {
case KeywordEnum::SCHEMA:
return $this->lexSchemaExtension();
case KeywordEnum::SCALAR:
return $this->lexScalarTypeExtension(false);
case KeywordEnum::TYPE:
return $this->lexObjectTypeExtension();
case KeywordEnum::INTERFACE:
return $this->lexInterfaceTypeExtension();
case KeywordEnum::UNION:
return $this->lexUnionTypeExtension();
case KeywordEnum::ENUM:
return $this->lexEnumTypeExtension();
case KeywordEnum::INPUT:
return $this->lexInputObjectTypeExtension();
}
}
throw $this->unexpected($token);
} | [
"protected",
"function",
"lexTypeSystemExtension",
"(",
")",
":",
"TypeSystemExtensionNodeInterface",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"lookahead",
"(",
")",
";",
"if",
"(",
"TokenKindEnum",
"::",
"NAME",
"===",
"$",
"token",
"->",
"... | TypeExtension :
- ScalarTypeExtension
- ObjectTypeExtension
- InterfaceTypeExtension
- UnionTypeExtension
- EnumTypeExtension
- InputObjectTypeDefinition
@return TypeSystemExtensionNodeInterface
@throws SyntaxErrorException | [
"TypeExtension",
":",
"-",
"ScalarTypeExtension",
"-",
"ObjectTypeExtension",
"-",
"InterfaceTypeExtension",
"-",
"UnionTypeExtension",
"-",
"EnumTypeExtension",
"-",
"InputObjectTypeDefinition"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1285-L1309 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexSchemaExtension | protected function lexSchemaExtension(): SchemaExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::SCHEMA);
$directives = $this->lexDirectives(true);
$parseFunction = function (): OperationTypeDefinitionNode {
return $this->lexOperationTypeDefinition();
};
$operationTypes = $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
$parseFunction,
TokenKindEnum::BRACE_R
)
: [];
if (empty($directives) && empty($operationTypes)) {
$this->unexpected();
}
return new SchemaExtensionNode($directives, $operationTypes, $this->createLocation($start));
} | php | protected function lexSchemaExtension(): SchemaExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::SCHEMA);
$directives = $this->lexDirectives(true);
$parseFunction = function (): OperationTypeDefinitionNode {
return $this->lexOperationTypeDefinition();
};
$operationTypes = $this->peek(TokenKindEnum::BRACE_L)
? $this->many(
TokenKindEnum::BRACE_L,
$parseFunction,
TokenKindEnum::BRACE_R
)
: [];
if (empty($directives) && empty($operationTypes)) {
$this->unexpected();
}
return new SchemaExtensionNode($directives, $operationTypes, $this->createLocation($start));
} | [
"protected",
"function",
"lexSchemaExtension",
"(",
")",
":",
"SchemaExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
")",
";",
"$",... | SchemaExtension :
- extend schema Directives[Const]? { OperationTypeDefinition+ }
- extend schema Directives[Const]
@return SchemaExtensionNode
@throws SyntaxErrorException | [
"SchemaExtension",
":",
"-",
"extend",
"schema",
"Directives",
"[",
"Const",
"]",
"?",
"{",
"OperationTypeDefinition",
"+",
"}",
"-",
"extend",
"schema",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1319-L1345 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexScalarTypeExtension | protected function lexScalarTypeExtension(bool $isConst = false): ScalarTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::SCALAR);
$name = $this->lexName();
$directives = $this->lexDirectives($isConst);
if (empty($directives)) {
throw $this->unexpected();
}
return new ScalarTypeExtensionNode($name, $directives, $this->createLocation($start));
} | php | protected function lexScalarTypeExtension(bool $isConst = false): ScalarTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::SCALAR);
$name = $this->lexName();
$directives = $this->lexDirectives($isConst);
if (empty($directives)) {
throw $this->unexpected();
}
return new ScalarTypeExtensionNode($name, $directives, $this->createLocation($start));
} | [
"protected",
"function",
"lexScalarTypeExtension",
"(",
"bool",
"$",
"isConst",
"=",
"false",
")",
":",
"ScalarTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
... | ScalarTypeExtension :
- extend scalar Name Directives[Const]
@param bool $isConst
@return ScalarTypeExtensionNode
@throws SyntaxErrorException | [
"ScalarTypeExtension",
":",
"-",
"extend",
"scalar",
"Name",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1355-L1370 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexObjectTypeExtension | protected function lexObjectTypeExtension(): ObjectTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::TYPE);
$name = $this->lexName();
$interfaces = $this->lexImplementsInterfaces();
$directives = $this->lexDirectives();
$fields = $this->lexFieldsDefinition();
if (empty($interfaces) && empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new ObjectTypeExtensionNode(
$name,
$interfaces,
$directives,
$fields,
$this->createLocation($start)
);
} | php | protected function lexObjectTypeExtension(): ObjectTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::TYPE);
$name = $this->lexName();
$interfaces = $this->lexImplementsInterfaces();
$directives = $this->lexDirectives();
$fields = $this->lexFieldsDefinition();
if (empty($interfaces) && empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new ObjectTypeExtensionNode(
$name,
$interfaces,
$directives,
$fields,
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexObjectTypeExtension",
"(",
")",
":",
"ObjectTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
")",
";"... | ObjectTypeExtension :
- extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
- extend type Name ImplementsInterfaces? Directives[Const]
- extend type Name ImplementsInterfaces
@return ObjectTypeExtensionNode
@throws SyntaxErrorException | [
"ObjectTypeExtension",
":",
"-",
"extend",
"type",
"Name",
"ImplementsInterfaces?",
"Directives",
"[",
"Const",
"]",
"?",
"FieldsDefinition",
"-",
"extend",
"type",
"Name",
"ImplementsInterfaces?",
"Directives",
"[",
"Const",
"]",
"-",
"extend",
"type",
"Name",
"I... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1381-L1404 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInterfaceTypeExtension | protected function lexInterfaceTypeExtension(): InterfaceTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::INTERFACE);
$name = $this->lexName();
$directives = $this->lexDirectives();
$fields = $this->lexFieldsDefinition();
if (empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new InterfaceTypeExtensionNode($name, $directives, $fields, $this->createLocation($start));
} | php | protected function lexInterfaceTypeExtension(): InterfaceTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::INTERFACE);
$name = $this->lexName();
$directives = $this->lexDirectives();
$fields = $this->lexFieldsDefinition();
if (empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new InterfaceTypeExtensionNode($name, $directives, $fields, $this->createLocation($start));
} | [
"protected",
"function",
"lexInterfaceTypeExtension",
"(",
")",
":",
"InterfaceTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
")",... | InterfaceTypeExtension :
- extend interface Name Directives[Const]? FieldsDefinition
- extend interface Name Directives[Const]
@return InterfaceTypeExtensionNode
@throws SyntaxErrorException | [
"InterfaceTypeExtension",
":",
"-",
"extend",
"interface",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"FieldsDefinition",
"-",
"extend",
"interface",
"Name",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1414-L1430 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexUnionTypeExtension | protected function lexUnionTypeExtension(): UnionTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::UNION);
$name = $this->lexName();
$directives = $this->lexDirectives();
$types = $this->lexUnionMemberTypes();
if (empty($directives) && empty($types)) {
throw $this->unexpected();
}
return new UnionTypeExtensionNode($name, $directives, $types, $this->createLocation($start));
} | php | protected function lexUnionTypeExtension(): UnionTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::UNION);
$name = $this->lexName();
$directives = $this->lexDirectives();
$types = $this->lexUnionMemberTypes();
if (empty($directives) && empty($types)) {
throw $this->unexpected();
}
return new UnionTypeExtensionNode($name, $directives, $types, $this->createLocation($start));
} | [
"protected",
"function",
"lexUnionTypeExtension",
"(",
")",
":",
"UnionTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
")",
";",
... | UnionTypeExtension :
- extend union Name Directives[Const]? UnionMemberTypes
- extend union Name Directives[Const]
@return UnionTypeExtensionNode
@throws SyntaxErrorException | [
"UnionTypeExtension",
":",
"-",
"extend",
"union",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"UnionMemberTypes",
"-",
"extend",
"union",
"Name",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1440-L1456 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexEnumTypeExtension | protected function lexEnumTypeExtension(): EnumTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::ENUM);
$name = $this->lexName();
$directives = $this->lexDirectives();
$values = $this->lexEnumValuesDefinition();
if (empty($directives) && empty($values)) {
throw $this->unexpected();
}
return new EnumTypeExtensionNode($name, $directives, $values, $this->createLocation($start));
} | php | protected function lexEnumTypeExtension(): EnumTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::ENUM);
$name = $this->lexName();
$directives = $this->lexDirectives();
$values = $this->lexEnumValuesDefinition();
if (empty($directives) && empty($values)) {
throw $this->unexpected();
}
return new EnumTypeExtensionNode($name, $directives, $values, $this->createLocation($start));
} | [
"protected",
"function",
"lexEnumTypeExtension",
"(",
")",
":",
"EnumTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
")",
";",
... | EnumTypeExtension :
- extend enum Name Directives[Const]? EnumValuesDefinition
- extend enum Name Directives[Const]
@return EnumTypeExtensionNode
@throws SyntaxErrorException | [
"EnumTypeExtension",
":",
"-",
"extend",
"enum",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"EnumValuesDefinition",
"-",
"extend",
"enum",
"Name",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1466-L1482 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexInputObjectTypeExtension | protected function lexInputObjectTypeExtension(): InputObjectTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::INPUT);
$name = $this->lexName();
$directives = $this->lexDirectives(true);
$fields = $this->lexInputFieldsDefinition();
if (empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new InputObjectTypeExtensionNode($name, $directives, $fields, $this->createLocation($start));
} | php | protected function lexInputObjectTypeExtension(): InputObjectTypeExtensionNode
{
$start = $this->lexer->getToken();
$this->expectKeyword(KeywordEnum::EXTEND);
$this->expectKeyword(KeywordEnum::INPUT);
$name = $this->lexName();
$directives = $this->lexDirectives(true);
$fields = $this->lexInputFieldsDefinition();
if (empty($directives) && empty($fields)) {
throw $this->unexpected();
}
return new InputObjectTypeExtensionNode($name, $directives, $fields, $this->createLocation($start));
} | [
"protected",
"function",
"lexInputObjectTypeExtension",
"(",
")",
":",
"InputObjectTypeExtensionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"this",
"->",
"expectKeyword",
"(",
"KeywordEnum",
"::",
"EXTEND",
... | InputObjectTypeExtension :
- extend input Name Directives[Const]? InputFieldsDefinition
- extend input Name Directives[Const]
@return InputObjectTypeExtensionNode
@throws SyntaxErrorException | [
"InputObjectTypeExtension",
":",
"-",
"extend",
"input",
"Name",
"Directives",
"[",
"Const",
"]",
"?",
"InputFieldsDefinition",
"-",
"extend",
"input",
"Name",
"Directives",
"[",
"Const",
"]"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1492-L1508 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDirectiveDefinition | protected function lexDirectiveDefinition(): DirectiveDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::DIRECTIVE);
$this->expect(TokenKindEnum::AT);
$name = $this->lexName();
$arguments = $this->lexArgumentsDefinition();
$this->expectKeyword(KeywordEnum::ON);
$locations = $this->lexDirectiveLocations();
return new DirectiveDefinitionNode(
$description,
$name,
$arguments,
$locations,
$this->createLocation($start)
);
} | php | protected function lexDirectiveDefinition(): DirectiveDefinitionNode
{
$start = $this->lexer->getToken();
$description = $this->lexDescription();
$this->expectKeyword(KeywordEnum::DIRECTIVE);
$this->expect(TokenKindEnum::AT);
$name = $this->lexName();
$arguments = $this->lexArgumentsDefinition();
$this->expectKeyword(KeywordEnum::ON);
$locations = $this->lexDirectiveLocations();
return new DirectiveDefinitionNode(
$description,
$name,
$arguments,
$locations,
$this->createLocation($start)
);
} | [
"protected",
"function",
"lexDirectiveDefinition",
"(",
")",
":",
"DirectiveDefinitionNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"description",
"=",
"$",
"this",
"->",
"lexDescription",
"(",
")",
";",
"... | DirectiveDefinition :
- Description? directive @ Name ArgumentsDefinition? on DirectiveLocations
@return DirectiveDefinitionNode
@throws SyntaxErrorException
@throws \ReflectionException | [
"DirectiveDefinition",
":",
"-",
"Description?",
"directive",
"@",
"Name",
"ArgumentsDefinition?",
"on",
"DirectiveLocations"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1518-L1541 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDirectiveLocations | protected function lexDirectiveLocations(): array
{
$this->skip(TokenKindEnum::PIPE);
$locations = [];
do {
$locations[] = $this->lexDirectiveLocation();
} while ($this->skip(TokenKindEnum::PIPE));
return $locations;
} | php | protected function lexDirectiveLocations(): array
{
$this->skip(TokenKindEnum::PIPE);
$locations = [];
do {
$locations[] = $this->lexDirectiveLocation();
} while ($this->skip(TokenKindEnum::PIPE));
return $locations;
} | [
"protected",
"function",
"lexDirectiveLocations",
"(",
")",
":",
"array",
"{",
"$",
"this",
"->",
"skip",
"(",
"TokenKindEnum",
"::",
"PIPE",
")",
";",
"$",
"locations",
"=",
"[",
"]",
";",
"do",
"{",
"$",
"locations",
"[",
"]",
"=",
"$",
"this",
"->... | DirectiveLocations :
- `|`? DirectiveLocation
- DirectiveLocations | DirectiveLocation
@return array
@throws SyntaxErrorException
@throws \ReflectionException | [
"DirectiveLocations",
":",
"-",
"|",
"?",
"DirectiveLocation",
"-",
"DirectiveLocations",
"|",
"DirectiveLocation"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1552-L1563 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.lexDirectiveLocation | protected function lexDirectiveLocation(): NameNode
{
$start = $this->lexer->getToken();
$name = $this->lexName();
if (arraySome(DirectiveLocationEnum::values(), function ($value) use ($name) {
return $name->getValue() === $value;
})) {
return $name;
}
throw $this->unexpected($start);
} | php | protected function lexDirectiveLocation(): NameNode
{
$start = $this->lexer->getToken();
$name = $this->lexName();
if (arraySome(DirectiveLocationEnum::values(), function ($value) use ($name) {
return $name->getValue() === $value;
})) {
return $name;
}
throw $this->unexpected($start);
} | [
"protected",
"function",
"lexDirectiveLocation",
"(",
")",
":",
"NameNode",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"$",
"name",
"=",
"$",
"this",
"->",
"lexName",
"(",
")",
";",
"if",
"(",
"arraySome",
"(... | DirectiveLocation :
- ExecutableDirectiveLocation
- TypeSystemDirectiveLocation
ExecutableDirectiveLocation : one of
`QUERY`
`MUTATION`
`SUBSCRIPTION`
`FIELD`
`FRAGMENT_DEFINITION`
`FRAGMENT_SPREAD`
`INLINE_FRAGMENT`
TypeSystemDirectiveLocation : one of
`SCHEMA`
`SCALAR`
`OBJECT`
`FIELD_DEFINITION`
`ARGUMENT_DEFINITION`
`INTERFACE`
`UNION`
`ENUM`
`ENUM_VALUE`
`INPUT_OBJECT`
`INPUT_FIELD_DEFINITION`
@return NameNode
@throws SyntaxErrorException
@throws \ReflectionException | [
"DirectiveLocation",
":",
"-",
"ExecutableDirectiveLocation",
"-",
"TypeSystemDirectiveLocation"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1596-L1609 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.createLocation | protected function createLocation(Token $start): ?Location
{
return !$this->lexer->getOption('noLocation', false)
? new Location(
$start->getStart(),
$this->lexer->getLastToken()->getEnd(),
$this->lexer->getSource()
)
: null;
} | php | protected function createLocation(Token $start): ?Location
{
return !$this->lexer->getOption('noLocation', false)
? new Location(
$start->getStart(),
$this->lexer->getLastToken()->getEnd(),
$this->lexer->getSource()
)
: null;
} | [
"protected",
"function",
"createLocation",
"(",
"Token",
"$",
"start",
")",
":",
"?",
"Location",
"{",
"return",
"!",
"$",
"this",
"->",
"lexer",
"->",
"getOption",
"(",
"'noLocation'",
",",
"false",
")",
"?",
"new",
"Location",
"(",
"$",
"start",
"->",
... | Returns a location object, used to identify the place in
the source that created a given parsed object.
@param Token $start
@return Location|null | [
"Returns",
"a",
"location",
"object",
"used",
"to",
"identify",
"the",
"place",
"in",
"the",
"source",
"that",
"created",
"a",
"given",
"parsed",
"object",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1618-L1627 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.skip | protected function skip(string $kind): bool
{
if ($match = $this->peek($kind)) {
$this->lexer->advance();
}
return $match;
} | php | protected function skip(string $kind): bool
{
if ($match = $this->peek($kind)) {
$this->lexer->advance();
}
return $match;
} | [
"protected",
"function",
"skip",
"(",
"string",
"$",
"kind",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"match",
"=",
"$",
"this",
"->",
"peek",
"(",
"$",
"kind",
")",
")",
"{",
"$",
"this",
"->",
"lexer",
"->",
"advance",
"(",
")",
";",
"}",
"retu... | If the next token is of the given kind, return true after advancing
the lexer. Otherwise, do not change the parser state and return false.
@param string $kind
@return bool | [
"If",
"the",
"next",
"token",
"is",
"of",
"the",
"given",
"kind",
"return",
"true",
"after",
"advancing",
"the",
"lexer",
".",
"Otherwise",
"do",
"not",
"change",
"the",
"parser",
"state",
"and",
"return",
"false",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1657-L1664 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.expect | protected function expect(string $kind): Token
{
$token = $this->lexer->getToken();
if ($kind === $token->getKind()) {
$this->lexer->advance();
return $token;
}
throw $this->lexer->createSyntaxErrorException(\sprintf('Expected %s, found %s.', $kind, $token));
} | php | protected function expect(string $kind): Token
{
$token = $this->lexer->getToken();
if ($kind === $token->getKind()) {
$this->lexer->advance();
return $token;
}
throw $this->lexer->createSyntaxErrorException(\sprintf('Expected %s, found %s.', $kind, $token));
} | [
"protected",
"function",
"expect",
"(",
"string",
"$",
"kind",
")",
":",
"Token",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"if",
"(",
"$",
"kind",
"===",
"$",
"token",
"->",
"getKind",
"(",
")",
")",
"{... | If the next token is of the given kind, return that token after advancing
the lexer. Otherwise, do not change the parser state and throw an error.
@param string $kind
@return Token
@throws SyntaxErrorException | [
"If",
"the",
"next",
"token",
"is",
"of",
"the",
"given",
"kind",
"return",
"that",
"token",
"after",
"advancing",
"the",
"lexer",
".",
"Otherwise",
"do",
"not",
"change",
"the",
"parser",
"state",
"and",
"throw",
"an",
"error",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1674-L1684 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.unexpected | protected function unexpected(?Token $atToken = null): SyntaxErrorException
{
$token = $atToken ?? $this->lexer->getToken();
return $this->lexer->createSyntaxErrorException(\sprintf('Unexpected %s', $token));
} | php | protected function unexpected(?Token $atToken = null): SyntaxErrorException
{
$token = $atToken ?? $this->lexer->getToken();
return $this->lexer->createSyntaxErrorException(\sprintf('Unexpected %s', $token));
} | [
"protected",
"function",
"unexpected",
"(",
"?",
"Token",
"$",
"atToken",
"=",
"null",
")",
":",
"SyntaxErrorException",
"{",
"$",
"token",
"=",
"$",
"atToken",
"??",
"$",
"this",
"->",
"lexer",
"->",
"getToken",
"(",
")",
";",
"return",
"$",
"this",
"... | Helper function for creating an error when an unexpected lexed token
is encountered.
@param Token|null $atToken
@return SyntaxErrorException | [
"Helper",
"function",
"for",
"creating",
"an",
"error",
"when",
"an",
"unexpected",
"lexed",
"token",
"is",
"encountered",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1710-L1715 |
digiaonline/graphql-php | src/Language/Parser.php | Parser.any | protected function any(string $openKind, callable $parseFunction, string $closeKind): array
{
$this->expect($openKind);
$nodes = [];
while (!$this->skip($closeKind)) {
$nodes[] = $parseFunction();
}
return $nodes;
} | php | protected function any(string $openKind, callable $parseFunction, string $closeKind): array
{
$this->expect($openKind);
$nodes = [];
while (!$this->skip($closeKind)) {
$nodes[] = $parseFunction();
}
return $nodes;
} | [
"protected",
"function",
"any",
"(",
"string",
"$",
"openKind",
",",
"callable",
"$",
"parseFunction",
",",
"string",
"$",
"closeKind",
")",
":",
"array",
"{",
"$",
"this",
"->",
"expect",
"(",
"$",
"openKind",
")",
";",
"$",
"nodes",
"=",
"[",
"]",
... | Returns a possibly empty list of parse nodes, determined by
the parseFn. This list begins with a lex token of openKind
and ends with a lex token of closeKind. Advances the parser
to the next lex token after the closing token.
@param string $openKind
@param callable $parseFunction
@param string $closeKind
@return array
@throws SyntaxErrorException | [
"Returns",
"a",
"possibly",
"empty",
"list",
"of",
"parse",
"nodes",
"determined",
"by",
"the",
"parseFn",
".",
"This",
"list",
"begins",
"with",
"a",
"lex",
"token",
"of",
"openKind",
"and",
"ends",
"with",
"a",
"lex",
"token",
"of",
"closeKind",
".",
"... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/Parser.php#L1729-L1740 |
digiaonline/graphql-php | src/Util/ValueConverter.php | ValueConverter.convert | public static function convert($value, TypeInterface $type): ?ValueNodeInterface
{
if ($type instanceof NonNullType) {
$node = self::convert($value, $type->getOfType());
return null !== $node && $node->getKind() === NodeKindEnum::NULL ? null : $node;
}
if (null === $value) {
return new NullValueNode(null);
}
// Convert PHP array to GraphQL list. If the GraphQLType is a list, but
// the value is not an array, convert the value using the list's item type.
if ($type instanceof ListType) {
return self::convertListType($value, $type);
}
// Populate the fields of the input object by creating ASTs from each value
// in the PHP object according to the fields in the input type.
if ($type instanceof InputObjectType) {
return self::convertInputObjectType($value, $type);
}
if ($type instanceof ScalarType || $type instanceof EnumType) {
return self::convertScalarOrEnum($value, $type);
}
throw new ConversionException(\sprintf('Unknown type: %s.', (string)$type));
} | php | public static function convert($value, TypeInterface $type): ?ValueNodeInterface
{
if ($type instanceof NonNullType) {
$node = self::convert($value, $type->getOfType());
return null !== $node && $node->getKind() === NodeKindEnum::NULL ? null : $node;
}
if (null === $value) {
return new NullValueNode(null);
}
// Convert PHP array to GraphQL list. If the GraphQLType is a list, but
// the value is not an array, convert the value using the list's item type.
if ($type instanceof ListType) {
return self::convertListType($value, $type);
}
// Populate the fields of the input object by creating ASTs from each value
// in the PHP object according to the fields in the input type.
if ($type instanceof InputObjectType) {
return self::convertInputObjectType($value, $type);
}
if ($type instanceof ScalarType || $type instanceof EnumType) {
return self::convertScalarOrEnum($value, $type);
}
throw new ConversionException(\sprintf('Unknown type: %s.', (string)$type));
} | [
"public",
"static",
"function",
"convert",
"(",
"$",
"value",
",",
"TypeInterface",
"$",
"type",
")",
":",
"?",
"ValueNodeInterface",
"{",
"if",
"(",
"$",
"type",
"instanceof",
"NonNullType",
")",
"{",
"$",
"node",
"=",
"self",
"::",
"convert",
"(",
"$",... | Produces a GraphQL Value AST given a PHP value.
A GraphQL type must be provided, which will be used to interpret different
PHP values.
| JSON Value | GraphQL Value |
| ------------- | -------------------- |
| Object | Input Object |
| Array | List |
| Boolean | Boolean |
| String | String / Enum Value |
| Number | Int / Float |
| Mixed | Enum Value |
| null | NullValue |
@param mixed $value
@param TypeInterface $type
@return ValueNodeInterface|null
@throws InvariantException
@throws SyntaxErrorException
@throws ConversionException | [
"Produces",
"a",
"GraphQL",
"Value",
"AST",
"given",
"a",
"PHP",
"value",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/ValueConverter.php#L55-L84 |
digiaonline/graphql-php | src/Validation/Rule/ValuesOfCorrectTypeRule.php | ValuesOfCorrectTypeRule.isValidScalar | protected function isValidScalar(ValueNodeInterface $node): void
{
$locationType = $this->context->getInputType();
if (null === $locationType) {
return;
}
$type = getNamedType($locationType);
if (!($type instanceof ScalarType)) {
$didYouMean = $this->getEnumTypeSuggestion($type, $node) ?? null;
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node), $didYouMean),
[$node]
)
);
return;
}
// Scalars determine if a literal value is valid via parseLiteral() which
// may throw or return an invalid value to indicate failure.
try {
$result = $type->parseLiteral($node, null/* $variables */);
if (null === $result) {
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node)),
[$node]
)
);
}
} catch (\Exception $ex) {
// Ensure a reference to the original error is maintained.
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node), $ex->getMessage()),
[$node],
null,
null,
null,
null,
$ex
)
);
}
} | php | protected function isValidScalar(ValueNodeInterface $node): void
{
$locationType = $this->context->getInputType();
if (null === $locationType) {
return;
}
$type = getNamedType($locationType);
if (!($type instanceof ScalarType)) {
$didYouMean = $this->getEnumTypeSuggestion($type, $node) ?? null;
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node), $didYouMean),
[$node]
)
);
return;
}
// Scalars determine if a literal value is valid via parseLiteral() which
// may throw or return an invalid value to indicate failure.
try {
$result = $type->parseLiteral($node, null/* $variables */);
if (null === $result) {
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node)),
[$node]
)
);
}
} catch (\Exception $ex) {
// Ensure a reference to the original error is maintained.
$this->context->reportError(
new ValidationException(
badValueMessage((string)$locationType, printNode($node), $ex->getMessage()),
[$node],
null,
null,
null,
null,
$ex
)
);
}
} | [
"protected",
"function",
"isValidScalar",
"(",
"ValueNodeInterface",
"$",
"node",
")",
":",
"void",
"{",
"$",
"locationType",
"=",
"$",
"this",
"->",
"context",
"->",
"getInputType",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"locationType",
")",
"{",
... | Any value literal may be a valid representation of a Scalar, depending on
that scalar type.
@param ValueNodeInterface $node
@throws InvariantException | [
"Any",
"value",
"literal",
"may",
"be",
"a",
"valid",
"representation",
"of",
"a",
"Scalar",
"depending",
"on",
"that",
"scalar",
"type",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/ValuesOfCorrectTypeRule.php#L209-L259 |
digiaonline/graphql-php | src/Util/ValueASTConverter.php | ValueASTConverter.convert | public static function convert(?NodeInterface $node, TypeInterface $type, array $variables = [])
{
if (null === $node) {
throw new ConversionException('Node is not defined.');
}
if ($type instanceof NonNullType) {
return self::convertNonNullType($node, $type, $variables);
}
if ($node instanceof NullValueNode) {
return null;
}
if ($node instanceof VariableNode) {
return self::convertVariable($node, $variables);
}
if ($type instanceof ListType) {
return self::convertListType($node, $type, $variables);
}
if ($type instanceof InputObjectType) {
return self::convertInputObjectType($node, $type, $variables);
}
if ($type instanceof EnumType) {
return self::convertEnumType($node, $type);
}
if ($type instanceof ScalarType) {
return self::convertScalarType($node, $type, $variables);
}
throw new InvalidTypeException(\sprintf('Unknown type: %s', (string)$type));
} | php | public static function convert(?NodeInterface $node, TypeInterface $type, array $variables = [])
{
if (null === $node) {
throw new ConversionException('Node is not defined.');
}
if ($type instanceof NonNullType) {
return self::convertNonNullType($node, $type, $variables);
}
if ($node instanceof NullValueNode) {
return null;
}
if ($node instanceof VariableNode) {
return self::convertVariable($node, $variables);
}
if ($type instanceof ListType) {
return self::convertListType($node, $type, $variables);
}
if ($type instanceof InputObjectType) {
return self::convertInputObjectType($node, $type, $variables);
}
if ($type instanceof EnumType) {
return self::convertEnumType($node, $type);
}
if ($type instanceof ScalarType) {
return self::convertScalarType($node, $type, $variables);
}
throw new InvalidTypeException(\sprintf('Unknown type: %s', (string)$type));
} | [
"public",
"static",
"function",
"convert",
"(",
"?",
"NodeInterface",
"$",
"node",
",",
"TypeInterface",
"$",
"type",
",",
"array",
"$",
"variables",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"node",
")",
"{",
"throw",
"new",
"ConversionE... | Produces a PHP value given a GraphQL Value AST.
A GraphQL type must be provided, which will be used to interpret different
GraphQL Value literals.
Throws a `ConversionException` when the value could not be validly converted according to
the provided type.
| GraphQL Value | JSON Value |
| -------------------- | ------------- |
| Input Object | Object |
| List | Array |
| Boolean | Boolean |
| String | String |
| Int / Float | Number |
| Enum Value | Mixed |
| NullValue | null |
@param NodeInterface|ValueNodeInterface|null $node
@param TypeInterface $type
@param array $variables
@return mixed|null
@throws InvalidTypeException
@throws InvariantException
@throws ConversionException | [
"Produces",
"a",
"PHP",
"value",
"given",
"a",
"GraphQL",
"Value",
"AST",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/ValueASTConverter.php#L52-L87 |
digiaonline/graphql-php | src/Type/IntrospectionProvider.php | IntrospectionProvider.registerIntrospectionTypes | protected function registerIntrospectionTypes()
{
$this->container
->share(GraphQL::SCHEMA_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::SCHEMA_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A GraphQL Schema defines the capabilities of a GraphQL server. It ' .
'exposes all available types and directives on the server, as well as ' .
'the entry points for query, mutation, and subscription operations.',
'fields' => function () {
return [
'types' => [
'description' => 'A list of all types supported by this server.',
'type' => newNonNull(newList(newNonNull(__Type()))),
'resolve' => function (Schema $schema): array {
return \array_values($schema->getTypeMap());
},
],
'queryType' => [
'description' => 'The type that query operations will be rooted at.',
'type' => newNonNull(__Type()),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getQueryType();
},
],
'mutationType' => [
'description' =>
'If this server supports mutation, the type that ' .
'mutation operations will be rooted at.',
'type' => __Type(),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getMutationType();
},
],
'subscriptionType' => [
'description' =>
'If this server support subscription, the type that ' .
'subscription operations will be rooted at.',
'type' => __Type(),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getSubscriptionType();
},
],
'directives' => [
'description' => 'A list of all directives supported by this server.',
'type' => newNonNull(newList(newNonNull(__Directive()))),
'resolve' => function (Schema $schema): array {
return $schema->getDirectives();
},
],
];
}
]);
});
$this->container
->share(GraphQL::DIRECTIVE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::DIRECTIVE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A Directive provides a way to describe alternate runtime execution and ' .
'type validation behavior in a GraphQL document.' .
"\n\nIn some cases, you need to provide options to alter GraphQL's " .
'execution behavior in ways field arguments will not suffice, such as ' .
'conditionally including or skipping a field. Directives provide this by ' .
'describing additional information to the executor.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'locations' => [
'type' => newNonNull(newList(newNonNull(__DirectiveLocation()))),
],
'args' => [
'type' => newNonNull(newList(newNonNull(__InputValue()))),
'resolve' => function (Directive $directive): array {
return $directive->getArguments() ?: [];
},
],
];
}
]);
});
$this->container
->share(GraphQL::DIRECTIVE_LOCATION_INTROSPECTION, function () {
return newEnumType([
'name' => GraphQL::DIRECTIVE_LOCATION_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A Directive can be adjacent to many parts of the GraphQL language, a ' .
'__DirectiveLocation describes one such possible adjacencies.',
'values' => [
DirectiveLocationEnum::QUERY => [
'description' => 'Location adjacent to a query operation.',
],
DirectiveLocationEnum::MUTATION => [
'description' => 'Location adjacent to a mutation operation.',
],
DirectiveLocationEnum::SUBSCRIPTION => [
'description' => 'Location adjacent to a subscription operation.',
],
DirectiveLocationEnum::FIELD => [
'description' => 'Location adjacent to a field.',
],
DirectiveLocationEnum::FRAGMENT_DEFINITION => [
'description' => 'Location adjacent to a fragment definition.',
],
DirectiveLocationEnum::FRAGMENT_SPREAD => [
'description' => 'Location adjacent to a fragment spread.',
],
DirectiveLocationEnum::INLINE_FRAGMENT => [
'description' => 'Location adjacent to an inline fragment.',
],
DirectiveLocationEnum::SCHEMA => [
'description' => 'Location adjacent to a schema definition.',
],
DirectiveLocationEnum::SCALAR => [
'description' => 'Location adjacent to a scalar definition.',
],
DirectiveLocationEnum::OBJECT => [
'description' => 'Location adjacent to an object type definition.',
],
DirectiveLocationEnum::FIELD_DEFINITION => [
'description' => 'Location adjacent to a field definition.',
],
DirectiveLocationEnum::ARGUMENT_DEFINITION => [
'description' => 'Location adjacent to an argument definition.',
],
DirectiveLocationEnum::INTERFACE => [
'description' => 'Location adjacent to an interface definition.',
],
DirectiveLocationEnum::UNION => [
'description' => 'Location adjacent to a union definition.',
],
DirectiveLocationEnum::ENUM => [
'description' => 'Location adjacent to an enum definition.',
],
DirectiveLocationEnum::ENUM_VALUE => [
'description' => 'Location adjacent to an enum value definition.',
],
DirectiveLocationEnum::INPUT_OBJECT => [
'description' => 'Location adjacent to an input object type definition.',
],
DirectiveLocationEnum::INPUT_FIELD_DEFINITION => [
'description' => 'Location adjacent to an input object field definition.',
],
],
]);
});
$this->container
->share(GraphQL::TYPE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::TYPE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'The fundamental unit of any GraphQL Schema is the type. There are ' .
'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' .
'\n\nDepending on the kind of a type, certain fields describe ' .
'information about that type. Scalar types provide no information ' .
'beyond a name and description, while Enum types provide their values. ' .
'Object and Interface types provide the fields they describe. Abstract ' .
'types, Union and Interface, provide the Object types possible ' .
'at runtime. List and NonNull types compose other types.',
'fields' => function () {
return [
'kind' => [
'type' => newNonNull(__TypeKind()),
'resolve' => function (TypeInterface $type) {
if ($type instanceof ScalarType) {
return TypeKindEnum::SCALAR;
}
if ($type instanceof ObjectType) {
return TypeKindEnum::OBJECT;
}
if ($type instanceof InterfaceType) {
return TypeKindEnum::INTERFACE;
}
if ($type instanceof UnionType) {
return TypeKindEnum::UNION;
}
if ($type instanceof EnumType) {
return TypeKindEnum::ENUM;
}
if ($type instanceof InputObjectType) {
return TypeKindEnum::INPUT_OBJECT;
}
if ($type instanceof ListType) {
return TypeKindEnum::LIST;
}
if ($type instanceof NonNullType) {
return TypeKindEnum::NON_NULL;
}
throw new InvalidTypeException(\sprintf('Unknown kind of type: %s', (string)$type));
},
],
'name' => ['type' => stringType()],
'description' => ['type' => stringType()],
'fields' => [
'type' => newList(newNonNull(__Field())),
'args' => [
'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false],
],
'resolve' => function (TypeInterface $type, array $args):
?array {
['includeDeprecated' => $includeDeprecated] = $args;
if ($type instanceof ObjectType || $type instanceof InterfaceType) {
$fields = \array_values($type->getFields());
if (!$includeDeprecated) {
$fields = \array_filter($fields, function (Field $field) {
return !$field->isDeprecated();
});
}
return $fields;
}
return null;
},
],
'interfaces' => [
'type' => newList(newNonNull(__Type())),
'resolve' => function (TypeInterface $type): ?array {
return $type instanceof ObjectType ? $type->getInterfaces() : null;
},
],
'possibleTypes' => [
'type' => newList(newNonNull(__Type())),
'resolve' => function (
TypeInterface $type,
array $args,
array $context,
ResolveInfo $info
):
?array {
/** @var Schema $schema */
$schema = $info->getSchema();
/** @noinspection PhpParamsInspection */
return $type instanceof AbstractTypeInterface ? $schema->getPossibleTypes($type) : null;
},
],
'enumValues' => [
'type' => newList(newNonNull(__EnumValue())),
'args' => [
'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false],
],
'resolve' => function (TypeInterface $type, array $args): ?array {
['includeDeprecated' => $includeDeprecated] = $args;
if ($type instanceof EnumType) {
$values = \array_values($type->getValues());
if (!$includeDeprecated) {
$values = \array_filter($values, function (Field $field) {
return !$field->isDeprecated();
});
}
return $values;
}
return null;
},
],
'inputFields' => [
'type' => newList(newNonNull(__InputValue())),
'resolve' => function (TypeInterface $type): ?array {
return $type instanceof InputObjectType ? $type->getFields() : null;
},
],
'ofType' => ['type' => __Type()],
];
}
]);
});
$this->container
->share(GraphQL::FIELD_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::FIELD_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'Object and Interface types are described by a list of Fields, each of ' .
'which has a name, potentially a list of arguments, and a return type.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'args' => [
'type' => newNonNull(newList(newNonNull(__InputValue()))),
'resolve' => function (ArgumentsAwareInterface $directive): array {
return $directive->getArguments() ?? [];
},
],
'type' => ['type' => newNonNull(__Type())],
'isDeprecated' => ['type' => newNonNull(booleanType())],
'deprecationReason' => ['type' => stringType()],
];
}
]);
});
$this->container
->share(GraphQL::INPUT_VALUE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::INPUT_VALUE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'Arguments provided to Fields or Directives and the input fields of an ' .
'InputObject are represented as Input Values which describe their type ' .
'and optionally a default value.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'type' => ['type' => newNonNull(__Type())],
'defaultValue' => [
'type' => stringType(),
'description' =>
'A GraphQL-formatted string representing the default value for this ' .
'input value.',
'resolve' => function (/*$inputValue*/) {
// TODO: Implement this when we have support for printing AST.
return null;
}
],
];
}
]);
});
$this->container
->share(GraphQL::ENUM_VALUE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::ENUM_VALUE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'One possible value for a given Enum. Enum values are unique values, not ' .
'a placeholder for a string or numeric value. However an Enum value is ' .
'returned in a JSON response as a string.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'isDeprecated' => ['type' => newNonNull(booleanType())],
'deprecationReason' => ['type' => stringType()],
];
}
]);
});
$this->container
->share(GraphQL::TYPE_KIND_INTROSPECTION, function () {
return newEnumType([
'name' => GraphQL::TYPE_KIND_INTROSPECTION,
'isIntrospection' => true,
'description' => 'An enum describing what kind of type a given `__Type` is.',
'values' => [
TypeKindEnum::SCALAR => [
'description' => 'Indicates this type is a scalar.',
],
TypeKindEnum::OBJECT => [
'description' => 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
],
TypeKindEnum::INTERFACE => [
'description' => 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
],
TypeKindEnum::UNION => [
'description' => 'Indicates this type is a union. `possibleTypes` is a valid field.',
],
TypeKindEnum::ENUM => [
'description' => 'Indicates this type is an enum. `enumValues` is a valid field.',
],
TypeKindEnum::INPUT_OBJECT => [
'description' => 'Indicates this type is an input object. `inputFields` is a valid field.',
],
TypeKindEnum::LIST => [
'description' => 'Indicates this type is a list. `ofType` is a valid field.',
],
TypeKindEnum::NON_NULL => [
'description' => 'Indicates this type is a non-null. `ofType` is a valid field.',
],
],
]);
});
} | php | protected function registerIntrospectionTypes()
{
$this->container
->share(GraphQL::SCHEMA_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::SCHEMA_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A GraphQL Schema defines the capabilities of a GraphQL server. It ' .
'exposes all available types and directives on the server, as well as ' .
'the entry points for query, mutation, and subscription operations.',
'fields' => function () {
return [
'types' => [
'description' => 'A list of all types supported by this server.',
'type' => newNonNull(newList(newNonNull(__Type()))),
'resolve' => function (Schema $schema): array {
return \array_values($schema->getTypeMap());
},
],
'queryType' => [
'description' => 'The type that query operations will be rooted at.',
'type' => newNonNull(__Type()),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getQueryType();
},
],
'mutationType' => [
'description' =>
'If this server supports mutation, the type that ' .
'mutation operations will be rooted at.',
'type' => __Type(),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getMutationType();
},
],
'subscriptionType' => [
'description' =>
'If this server support subscription, the type that ' .
'subscription operations will be rooted at.',
'type' => __Type(),
'resolve' => function (Schema $schema): ?TypeInterface {
return $schema->getSubscriptionType();
},
],
'directives' => [
'description' => 'A list of all directives supported by this server.',
'type' => newNonNull(newList(newNonNull(__Directive()))),
'resolve' => function (Schema $schema): array {
return $schema->getDirectives();
},
],
];
}
]);
});
$this->container
->share(GraphQL::DIRECTIVE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::DIRECTIVE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A Directive provides a way to describe alternate runtime execution and ' .
'type validation behavior in a GraphQL document.' .
"\n\nIn some cases, you need to provide options to alter GraphQL's " .
'execution behavior in ways field arguments will not suffice, such as ' .
'conditionally including or skipping a field. Directives provide this by ' .
'describing additional information to the executor.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'locations' => [
'type' => newNonNull(newList(newNonNull(__DirectiveLocation()))),
],
'args' => [
'type' => newNonNull(newList(newNonNull(__InputValue()))),
'resolve' => function (Directive $directive): array {
return $directive->getArguments() ?: [];
},
],
];
}
]);
});
$this->container
->share(GraphQL::DIRECTIVE_LOCATION_INTROSPECTION, function () {
return newEnumType([
'name' => GraphQL::DIRECTIVE_LOCATION_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'A Directive can be adjacent to many parts of the GraphQL language, a ' .
'__DirectiveLocation describes one such possible adjacencies.',
'values' => [
DirectiveLocationEnum::QUERY => [
'description' => 'Location adjacent to a query operation.',
],
DirectiveLocationEnum::MUTATION => [
'description' => 'Location adjacent to a mutation operation.',
],
DirectiveLocationEnum::SUBSCRIPTION => [
'description' => 'Location adjacent to a subscription operation.',
],
DirectiveLocationEnum::FIELD => [
'description' => 'Location adjacent to a field.',
],
DirectiveLocationEnum::FRAGMENT_DEFINITION => [
'description' => 'Location adjacent to a fragment definition.',
],
DirectiveLocationEnum::FRAGMENT_SPREAD => [
'description' => 'Location adjacent to a fragment spread.',
],
DirectiveLocationEnum::INLINE_FRAGMENT => [
'description' => 'Location adjacent to an inline fragment.',
],
DirectiveLocationEnum::SCHEMA => [
'description' => 'Location adjacent to a schema definition.',
],
DirectiveLocationEnum::SCALAR => [
'description' => 'Location adjacent to a scalar definition.',
],
DirectiveLocationEnum::OBJECT => [
'description' => 'Location adjacent to an object type definition.',
],
DirectiveLocationEnum::FIELD_DEFINITION => [
'description' => 'Location adjacent to a field definition.',
],
DirectiveLocationEnum::ARGUMENT_DEFINITION => [
'description' => 'Location adjacent to an argument definition.',
],
DirectiveLocationEnum::INTERFACE => [
'description' => 'Location adjacent to an interface definition.',
],
DirectiveLocationEnum::UNION => [
'description' => 'Location adjacent to a union definition.',
],
DirectiveLocationEnum::ENUM => [
'description' => 'Location adjacent to an enum definition.',
],
DirectiveLocationEnum::ENUM_VALUE => [
'description' => 'Location adjacent to an enum value definition.',
],
DirectiveLocationEnum::INPUT_OBJECT => [
'description' => 'Location adjacent to an input object type definition.',
],
DirectiveLocationEnum::INPUT_FIELD_DEFINITION => [
'description' => 'Location adjacent to an input object field definition.',
],
],
]);
});
$this->container
->share(GraphQL::TYPE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::TYPE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'The fundamental unit of any GraphQL Schema is the type. There are ' .
'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' .
'\n\nDepending on the kind of a type, certain fields describe ' .
'information about that type. Scalar types provide no information ' .
'beyond a name and description, while Enum types provide their values. ' .
'Object and Interface types provide the fields they describe. Abstract ' .
'types, Union and Interface, provide the Object types possible ' .
'at runtime. List and NonNull types compose other types.',
'fields' => function () {
return [
'kind' => [
'type' => newNonNull(__TypeKind()),
'resolve' => function (TypeInterface $type) {
if ($type instanceof ScalarType) {
return TypeKindEnum::SCALAR;
}
if ($type instanceof ObjectType) {
return TypeKindEnum::OBJECT;
}
if ($type instanceof InterfaceType) {
return TypeKindEnum::INTERFACE;
}
if ($type instanceof UnionType) {
return TypeKindEnum::UNION;
}
if ($type instanceof EnumType) {
return TypeKindEnum::ENUM;
}
if ($type instanceof InputObjectType) {
return TypeKindEnum::INPUT_OBJECT;
}
if ($type instanceof ListType) {
return TypeKindEnum::LIST;
}
if ($type instanceof NonNullType) {
return TypeKindEnum::NON_NULL;
}
throw new InvalidTypeException(\sprintf('Unknown kind of type: %s', (string)$type));
},
],
'name' => ['type' => stringType()],
'description' => ['type' => stringType()],
'fields' => [
'type' => newList(newNonNull(__Field())),
'args' => [
'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false],
],
'resolve' => function (TypeInterface $type, array $args):
?array {
['includeDeprecated' => $includeDeprecated] = $args;
if ($type instanceof ObjectType || $type instanceof InterfaceType) {
$fields = \array_values($type->getFields());
if (!$includeDeprecated) {
$fields = \array_filter($fields, function (Field $field) {
return !$field->isDeprecated();
});
}
return $fields;
}
return null;
},
],
'interfaces' => [
'type' => newList(newNonNull(__Type())),
'resolve' => function (TypeInterface $type): ?array {
return $type instanceof ObjectType ? $type->getInterfaces() : null;
},
],
'possibleTypes' => [
'type' => newList(newNonNull(__Type())),
'resolve' => function (
TypeInterface $type,
array $args,
array $context,
ResolveInfo $info
):
?array {
/** @var Schema $schema */
$schema = $info->getSchema();
/** @noinspection PhpParamsInspection */
return $type instanceof AbstractTypeInterface ? $schema->getPossibleTypes($type) : null;
},
],
'enumValues' => [
'type' => newList(newNonNull(__EnumValue())),
'args' => [
'includeDeprecated' => ['type' => booleanType(), 'defaultValue' => false],
],
'resolve' => function (TypeInterface $type, array $args): ?array {
['includeDeprecated' => $includeDeprecated] = $args;
if ($type instanceof EnumType) {
$values = \array_values($type->getValues());
if (!$includeDeprecated) {
$values = \array_filter($values, function (Field $field) {
return !$field->isDeprecated();
});
}
return $values;
}
return null;
},
],
'inputFields' => [
'type' => newList(newNonNull(__InputValue())),
'resolve' => function (TypeInterface $type): ?array {
return $type instanceof InputObjectType ? $type->getFields() : null;
},
],
'ofType' => ['type' => __Type()],
];
}
]);
});
$this->container
->share(GraphQL::FIELD_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::FIELD_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'Object and Interface types are described by a list of Fields, each of ' .
'which has a name, potentially a list of arguments, and a return type.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'args' => [
'type' => newNonNull(newList(newNonNull(__InputValue()))),
'resolve' => function (ArgumentsAwareInterface $directive): array {
return $directive->getArguments() ?? [];
},
],
'type' => ['type' => newNonNull(__Type())],
'isDeprecated' => ['type' => newNonNull(booleanType())],
'deprecationReason' => ['type' => stringType()],
];
}
]);
});
$this->container
->share(GraphQL::INPUT_VALUE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::INPUT_VALUE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'Arguments provided to Fields or Directives and the input fields of an ' .
'InputObject are represented as Input Values which describe their type ' .
'and optionally a default value.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'type' => ['type' => newNonNull(__Type())],
'defaultValue' => [
'type' => stringType(),
'description' =>
'A GraphQL-formatted string representing the default value for this ' .
'input value.',
'resolve' => function (/*$inputValue*/) {
// TODO: Implement this when we have support for printing AST.
return null;
}
],
];
}
]);
});
$this->container
->share(GraphQL::ENUM_VALUE_INTROSPECTION, function () {
return newObjectType([
'name' => GraphQL::ENUM_VALUE_INTROSPECTION,
'isIntrospection' => true,
'description' =>
'One possible value for a given Enum. Enum values are unique values, not ' .
'a placeholder for a string or numeric value. However an Enum value is ' .
'returned in a JSON response as a string.',
'fields' => function () {
return [
'name' => ['type' => newNonNull(stringType())],
'description' => ['type' => stringType()],
'isDeprecated' => ['type' => newNonNull(booleanType())],
'deprecationReason' => ['type' => stringType()],
];
}
]);
});
$this->container
->share(GraphQL::TYPE_KIND_INTROSPECTION, function () {
return newEnumType([
'name' => GraphQL::TYPE_KIND_INTROSPECTION,
'isIntrospection' => true,
'description' => 'An enum describing what kind of type a given `__Type` is.',
'values' => [
TypeKindEnum::SCALAR => [
'description' => 'Indicates this type is a scalar.',
],
TypeKindEnum::OBJECT => [
'description' => 'Indicates this type is an object. `fields` and `interfaces` are valid fields.',
],
TypeKindEnum::INTERFACE => [
'description' => 'Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.',
],
TypeKindEnum::UNION => [
'description' => 'Indicates this type is a union. `possibleTypes` is a valid field.',
],
TypeKindEnum::ENUM => [
'description' => 'Indicates this type is an enum. `enumValues` is a valid field.',
],
TypeKindEnum::INPUT_OBJECT => [
'description' => 'Indicates this type is an input object. `inputFields` is a valid field.',
],
TypeKindEnum::LIST => [
'description' => 'Indicates this type is a list. `ofType` is a valid field.',
],
TypeKindEnum::NON_NULL => [
'description' => 'Indicates this type is a non-null. `ofType` is a valid field.',
],
],
]);
});
} | [
"protected",
"function",
"registerIntrospectionTypes",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"share",
"(",
"GraphQL",
"::",
"SCHEMA_INTROSPECTION",
",",
"function",
"(",
")",
"{",
"return",
"newObjectType",
"(",
"[",
"'name'",
"=>",
"GraphQL",
"... | Registers the introspection types with the container. | [
"Registers",
"the",
"introspection",
"types",
"with",
"the",
"container",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Type/IntrospectionProvider.php#L58-L450 |
digiaonline/graphql-php | src/Type/IntrospectionProvider.php | IntrospectionProvider.registerMetaFields | protected function registerMetaFields()
{
$this->container
->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function ($__Schema) {
return newField([
'name' => '__schema',
'description' => 'Access the current type schema of this server.',
'type' => newNonNull($__Schema),
'resolve' => function ($source, $args, $context, ResolveInfo $info): Schema {
return $info->getSchema();
},
]);
})
->addArgument(GraphQL::SCHEMA_INTROSPECTION);
$this->container
->share(GraphQL::TYPE_META_FIELD_DEFINITION, function ($__Type) {
return newField([
'name' => '__type',
'description' => 'Request the type information of a single type.',
'type' => $__Type,
'args' => ['name' => ['type' => newNonNull(stringType())]],
'resolve' => function ($source, $args, $context, ResolveInfo $info): ?TypeInterface {
['name' => $name] = $args;
return $info->getSchema()->getType($name);
},
]);
})
->addArgument(GraphQL::TYPE_INTROSPECTION);
$this->container
->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function () {
return newField([
'name' => '__typename',
'description' => 'The name of the current Object type at runtime.',
'type' => newNonNull(stringType()),
'resolve' => function ($source, $args, $context, ResolveInfo $info): string {
return $info->getParentType()->getName();
},
]);
});
} | php | protected function registerMetaFields()
{
$this->container
->share(GraphQL::SCHEMA_META_FIELD_DEFINITION, function ($__Schema) {
return newField([
'name' => '__schema',
'description' => 'Access the current type schema of this server.',
'type' => newNonNull($__Schema),
'resolve' => function ($source, $args, $context, ResolveInfo $info): Schema {
return $info->getSchema();
},
]);
})
->addArgument(GraphQL::SCHEMA_INTROSPECTION);
$this->container
->share(GraphQL::TYPE_META_FIELD_DEFINITION, function ($__Type) {
return newField([
'name' => '__type',
'description' => 'Request the type information of a single type.',
'type' => $__Type,
'args' => ['name' => ['type' => newNonNull(stringType())]],
'resolve' => function ($source, $args, $context, ResolveInfo $info): ?TypeInterface {
['name' => $name] = $args;
return $info->getSchema()->getType($name);
},
]);
})
->addArgument(GraphQL::TYPE_INTROSPECTION);
$this->container
->share(GraphQL::TYPE_NAME_META_FIELD_DEFINITION, function () {
return newField([
'name' => '__typename',
'description' => 'The name of the current Object type at runtime.',
'type' => newNonNull(stringType()),
'resolve' => function ($source, $args, $context, ResolveInfo $info): string {
return $info->getParentType()->getName();
},
]);
});
} | [
"protected",
"function",
"registerMetaFields",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"share",
"(",
"GraphQL",
"::",
"SCHEMA_META_FIELD_DEFINITION",
",",
"function",
"(",
"$",
"__Schema",
")",
"{",
"return",
"newField",
"(",
"[",
"'name'",
"=>",
... | Registers the introspection meta fields with the container. | [
"Registers",
"the",
"introspection",
"meta",
"fields",
"with",
"the",
"container",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Type/IntrospectionProvider.php#L455-L496 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.collectConflictsBetweenFieldsAndFragment | protected function collectConflictsBetweenFieldsAndFragment(
ComparisonContext $context,
array &$comparedFragments,
array $fieldMap,
string $fragmentName,
bool $areMutuallyExclusive
): void {
// Memoize so a fragment is not compared for conflicts more than once.
if (isset($comparedFragments[$fragmentName])) {
return;
}
$comparedFragments[$fragmentName] = true;
$fragment = $this->getContext()->getFragment($fragmentName);
if (null === $fragment) {
return;
}
$contextB = $this->getReferencedFieldsAndFragmentNames($fragment);
$fieldMapB = $contextB->getFieldMap();
// Do not compare a fragment's fieldMap to itself.
if ($fieldMap == $fieldMapB) {
return;
}
// (D) First collect any conflicts between the provided collection of fields
// and the collection of fields represented by the given fragment.
$this->collectConflictsBetween(
$context,
$fieldMap,
$fieldMapB,
$areMutuallyExclusive
);
$fragmentNamesB = $contextB->getFragmentNames();
// (E) Then collect any conflicts between the provided collection of fields
// and any fragment names found in the given fragment.
if (!empty($fragmentNamesB)) {
$fragmentNamesBCount = \count($fragmentNamesB);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesBCount; $i++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMap,
$fragmentNamesB[$i],
$areMutuallyExclusive
);
}
}
} | php | protected function collectConflictsBetweenFieldsAndFragment(
ComparisonContext $context,
array &$comparedFragments,
array $fieldMap,
string $fragmentName,
bool $areMutuallyExclusive
): void {
// Memoize so a fragment is not compared for conflicts more than once.
if (isset($comparedFragments[$fragmentName])) {
return;
}
$comparedFragments[$fragmentName] = true;
$fragment = $this->getContext()->getFragment($fragmentName);
if (null === $fragment) {
return;
}
$contextB = $this->getReferencedFieldsAndFragmentNames($fragment);
$fieldMapB = $contextB->getFieldMap();
// Do not compare a fragment's fieldMap to itself.
if ($fieldMap == $fieldMapB) {
return;
}
// (D) First collect any conflicts between the provided collection of fields
// and the collection of fields represented by the given fragment.
$this->collectConflictsBetween(
$context,
$fieldMap,
$fieldMapB,
$areMutuallyExclusive
);
$fragmentNamesB = $contextB->getFragmentNames();
// (E) Then collect any conflicts between the provided collection of fields
// and any fragment names found in the given fragment.
if (!empty($fragmentNamesB)) {
$fragmentNamesBCount = \count($fragmentNamesB);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesBCount; $i++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMap,
$fragmentNamesB[$i],
$areMutuallyExclusive
);
}
}
} | [
"protected",
"function",
"collectConflictsBetweenFieldsAndFragment",
"(",
"ComparisonContext",
"$",
"context",
",",
"array",
"&",
"$",
"comparedFragments",
",",
"array",
"$",
"fieldMap",
",",
"string",
"$",
"fragmentName",
",",
"bool",
"$",
"areMutuallyExclusive",
")"... | Collect all conflicts found between a set of fields and a fragment reference
including via spreading in any nested fragments.
@param ComparisonContext $context
@param array $comparedFragments
@param array $fieldMap
@param string $fragmentName
@param bool $areMutuallyExclusive
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException | [
"Collect",
"all",
"conflicts",
"found",
"between",
"a",
"set",
"of",
"fields",
"and",
"a",
"fragment",
"reference",
"including",
"via",
"spreading",
"in",
"any",
"nested",
"fragments",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L177-L233 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.collectConflictsBetweenFragments | protected function collectConflictsBetweenFragments(
ComparisonContext $context,
string $fragmentNameA,
string $fragmentNameB,
bool $areMutuallyExclusive
): void {
// No need to compare a fragment to itself.
if ($fragmentNameA === $fragmentNameB) {
return;
}
// Memoize so two fragments are not compared for conflicts more than once.
if ($this->comparedFragmentPairs->has($fragmentNameA, $fragmentNameB, $areMutuallyExclusive)) {
return;
}
$this->comparedFragmentPairs->add($fragmentNameA, $fragmentNameB, $areMutuallyExclusive);
$fragmentA = $this->getContext()->getFragment($fragmentNameA);
$fragmentB = $this->getContext()->getFragment($fragmentNameB);
if (null === $fragmentA || null === $fragmentB) {
return;
}
$contextA = $this->getReferencedFieldsAndFragmentNames($fragmentA);
$contextB = $this->getReferencedFieldsAndFragmentNames($fragmentB);
// (F) First, collect all conflicts between these two collections of fields
// (not including any nested fragments).
$this->collectConflictsBetween(
$context,
$contextA->getFieldMap(),
$contextB->getFieldMap(),
$areMutuallyExclusive
);
$fragmentNamesB = $contextB->getFragmentNames();
// (G) Then collect conflicts between the first fragment and any nested
// fragments spread in the second fragment.
if (!empty($fragmentNamesB)) {
$fragmentNamesBCount = \count($fragmentNamesB);
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNameA,
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
$fragmentNamesA = $contextA->getFragmentNames();
// (G) Then collect conflicts between the second fragment and any nested
// fragments spread in the first fragment.
if (!empty($fragmentNamesA)) {
$fragmentNamesACount = \count($fragmentNamesA);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNamesA[$i],
$fragmentNameB,
$areMutuallyExclusive
);
}
}
} | php | protected function collectConflictsBetweenFragments(
ComparisonContext $context,
string $fragmentNameA,
string $fragmentNameB,
bool $areMutuallyExclusive
): void {
// No need to compare a fragment to itself.
if ($fragmentNameA === $fragmentNameB) {
return;
}
// Memoize so two fragments are not compared for conflicts more than once.
if ($this->comparedFragmentPairs->has($fragmentNameA, $fragmentNameB, $areMutuallyExclusive)) {
return;
}
$this->comparedFragmentPairs->add($fragmentNameA, $fragmentNameB, $areMutuallyExclusive);
$fragmentA = $this->getContext()->getFragment($fragmentNameA);
$fragmentB = $this->getContext()->getFragment($fragmentNameB);
if (null === $fragmentA || null === $fragmentB) {
return;
}
$contextA = $this->getReferencedFieldsAndFragmentNames($fragmentA);
$contextB = $this->getReferencedFieldsAndFragmentNames($fragmentB);
// (F) First, collect all conflicts between these two collections of fields
// (not including any nested fragments).
$this->collectConflictsBetween(
$context,
$contextA->getFieldMap(),
$contextB->getFieldMap(),
$areMutuallyExclusive
);
$fragmentNamesB = $contextB->getFragmentNames();
// (G) Then collect conflicts between the first fragment and any nested
// fragments spread in the second fragment.
if (!empty($fragmentNamesB)) {
$fragmentNamesBCount = \count($fragmentNamesB);
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNameA,
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
$fragmentNamesA = $contextA->getFragmentNames();
// (G) Then collect conflicts between the second fragment and any nested
// fragments spread in the first fragment.
if (!empty($fragmentNamesA)) {
$fragmentNamesACount = \count($fragmentNamesA);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNamesA[$i],
$fragmentNameB,
$areMutuallyExclusive
);
}
}
} | [
"protected",
"function",
"collectConflictsBetweenFragments",
"(",
"ComparisonContext",
"$",
"context",
",",
"string",
"$",
"fragmentNameA",
",",
"string",
"$",
"fragmentNameB",
",",
"bool",
"$",
"areMutuallyExclusive",
")",
":",
"void",
"{",
"// No need to compare a fra... | Collect all conflicts found between two fragments, including via spreading in
any nested fragments.
@param ComparisonContext $context
@param string $fragmentNameA
@param string $fragmentNameB
@param bool $areMutuallyExclusive
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException | [
"Collect",
"all",
"conflicts",
"found",
"between",
"two",
"fragments",
"including",
"via",
"spreading",
"in",
"any",
"nested",
"fragments",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L247-L319 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.findConflictsBetweenSubSelectionSets | protected function findConflictsBetweenSubSelectionSets(
?NamedTypeInterface $parentTypeA,
SelectionSetNode $selectionSetA,
?NamedTypeInterface $parentTypeB,
SelectionSetNode $selectionSetB,
bool $areMutuallyExclusive
): array {
$context = new ComparisonContext();
$contextA = $this->getFieldsAndFragmentNames($selectionSetA, $parentTypeA);
$contextB = $this->getFieldsAndFragmentNames($selectionSetB, $parentTypeB);
$fieldMapA = $contextA->getFieldMap();
$fieldMapB = $contextB->getFieldMap();
$fragmentNamesA = $contextA->getFragmentNames();
$fragmentNamesB = $contextB->getFragmentNames();
$fragmentNamesACount = \count($fragmentNamesA);
$fragmentNamesBCount = \count($fragmentNamesB);
// (H) First, collect all conflicts between these two collections of field.
$this->collectConflictsBetween(
$context,
$fieldMapA,
$fieldMapB,
$areMutuallyExclusive
);
// (I) Then collect conflicts between the first collection of fields and
// those referenced by each fragment name associated with the second.
if (!empty($fragmentNamesB)) {
$comparedFragments = [];
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMapA,
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
// (I) Then collect conflicts between the second collection of fields and
// those referenced by each fragment name associated with the first.
if (!empty($fragmentNamesA)) {
$comparedFragments = [];
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMapB,
$fragmentNamesA[$i],
$areMutuallyExclusive
);
}
}
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNamesA[$i],
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
return $context->getConflicts();
} | php | protected function findConflictsBetweenSubSelectionSets(
?NamedTypeInterface $parentTypeA,
SelectionSetNode $selectionSetA,
?NamedTypeInterface $parentTypeB,
SelectionSetNode $selectionSetB,
bool $areMutuallyExclusive
): array {
$context = new ComparisonContext();
$contextA = $this->getFieldsAndFragmentNames($selectionSetA, $parentTypeA);
$contextB = $this->getFieldsAndFragmentNames($selectionSetB, $parentTypeB);
$fieldMapA = $contextA->getFieldMap();
$fieldMapB = $contextB->getFieldMap();
$fragmentNamesA = $contextA->getFragmentNames();
$fragmentNamesB = $contextB->getFragmentNames();
$fragmentNamesACount = \count($fragmentNamesA);
$fragmentNamesBCount = \count($fragmentNamesB);
// (H) First, collect all conflicts between these two collections of field.
$this->collectConflictsBetween(
$context,
$fieldMapA,
$fieldMapB,
$areMutuallyExclusive
);
// (I) Then collect conflicts between the first collection of fields and
// those referenced by each fragment name associated with the second.
if (!empty($fragmentNamesB)) {
$comparedFragments = [];
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMapA,
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
// (I) Then collect conflicts between the second collection of fields and
// those referenced by each fragment name associated with the first.
if (!empty($fragmentNamesA)) {
$comparedFragments = [];
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
$this->collectConflictsBetweenFieldsAndFragment(
$context,
$comparedFragments,
$fieldMapB,
$fragmentNamesA[$i],
$areMutuallyExclusive
);
}
}
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fragmentNamesACount; $i++) {
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fragmentNamesBCount; $j++) {
$this->collectConflictsBetweenFragments(
$context,
$fragmentNamesA[$i],
$fragmentNamesB[$j],
$areMutuallyExclusive
);
}
}
return $context->getConflicts();
} | [
"protected",
"function",
"findConflictsBetweenSubSelectionSets",
"(",
"?",
"NamedTypeInterface",
"$",
"parentTypeA",
",",
"SelectionSetNode",
"$",
"selectionSetA",
",",
"?",
"NamedTypeInterface",
"$",
"parentTypeB",
",",
"SelectionSetNode",
"$",
"selectionSetB",
",",
"boo... | Find all conflicts found between two selection sets, including those found
via spreading in fragments. Called when determining if conflicts exist
between the sub-fields of two overlapping fields.
@param NamedTypeInterface|null $parentTypeA
@param SelectionSetNode $selectionSetA
@param NamedTypeInterface|null $parentTypeB
@param SelectionSetNode $selectionSetB
@param bool $areMutuallyExclusive
@return Conflict[]
@throws InvalidTypeException
@throws InvariantException
@throws ConversionException | [
"Find",
"all",
"conflicts",
"found",
"between",
"two",
"selection",
"sets",
"including",
"those",
"found",
"via",
"spreading",
"in",
"fragments",
".",
"Called",
"when",
"determining",
"if",
"conflicts",
"exist",
"between",
"the",
"sub",
"-",
"fields",
"of",
"t... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L336-L413 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.collectConflictsWithin | protected function collectConflictsWithin(ComparisonContext $context): void
{
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For every response name, if there are multiple fields, they
// must be compared to find a potential conflict.
foreach ($context->getFieldMap() as $responseName => $fields) {
$fieldsCount = \count($fields);
// This compares every field in the list to every other field in this list
// (except to itself). If the list only has one item, nothing needs to
// be compared.
if ($fieldsCount > 1) {
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fieldsCount; $i++) {
for ($j = $i + 1; $j < $fieldsCount; $j++) {
$conflict = $this->findConflict(
$responseName,
$fields[$i],
$fields[$j],
// within one collection is never mutually exclusive
false/* $areMutuallyExclusive */
);
if (null !== $conflict) {
$context->reportConflict($conflict);
}
}
}
}
}
} | php | protected function collectConflictsWithin(ComparisonContext $context): void
{
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For every response name, if there are multiple fields, they
// must be compared to find a potential conflict.
foreach ($context->getFieldMap() as $responseName => $fields) {
$fieldsCount = \count($fields);
// This compares every field in the list to every other field in this list
// (except to itself). If the list only has one item, nothing needs to
// be compared.
if ($fieldsCount > 1) {
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fieldsCount; $i++) {
for ($j = $i + 1; $j < $fieldsCount; $j++) {
$conflict = $this->findConflict(
$responseName,
$fields[$i],
$fields[$j],
// within one collection is never mutually exclusive
false/* $areMutuallyExclusive */
);
if (null !== $conflict) {
$context->reportConflict($conflict);
}
}
}
}
}
} | [
"protected",
"function",
"collectConflictsWithin",
"(",
"ComparisonContext",
"$",
"context",
")",
":",
"void",
"{",
"// A field map is a keyed collection, where each key represents a response",
"// name and the value at that key is a list of all fields which provide that",
"// response nam... | Collect all Conflicts "within" one collection of fields.
@param ComparisonContext $context
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException | [
"Collect",
"all",
"Conflicts",
"within",
"one",
"collection",
"of",
"fields",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L423-L454 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.collectConflictsBetween | protected function collectConflictsBetween(
ComparisonContext $context,
array $fieldMapA,
array $fieldMapB,
bool $parentFieldsAreMutuallyExclusive
): void {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For any response name which appears in both provided field
// maps, each field from the first field map must be compared to every field
// in the second field map to find potential conflicts.
foreach ($fieldMapA as $responseName => $fieldsA) {
$fieldsB = $fieldMapB[$responseName] ?? null;
if (null !== $fieldsB) {
$fieldsACount = \count($fieldsA);
$fieldsBCount = \count($fieldsB);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fieldsACount; $i++) {
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fieldsBCount; $j++) {
$conflict = $this->findConflict(
$responseName,
$fieldsA[$i],
$fieldsB[$j],
$parentFieldsAreMutuallyExclusive
);
if (null !== $conflict) {
$context->reportConflict($conflict);
}
}
}
}
}
} | php | protected function collectConflictsBetween(
ComparisonContext $context,
array $fieldMapA,
array $fieldMapB,
bool $parentFieldsAreMutuallyExclusive
): void {
// A field map is a keyed collection, where each key represents a response
// name and the value at that key is a list of all fields which provide that
// response name. For any response name which appears in both provided field
// maps, each field from the first field map must be compared to every field
// in the second field map to find potential conflicts.
foreach ($fieldMapA as $responseName => $fieldsA) {
$fieldsB = $fieldMapB[$responseName] ?? null;
if (null !== $fieldsB) {
$fieldsACount = \count($fieldsA);
$fieldsBCount = \count($fieldsB);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $fieldsACount; $i++) {
/** @noinspection ForeachInvariantsInspection */
for ($j = 0; $j < $fieldsBCount; $j++) {
$conflict = $this->findConflict(
$responseName,
$fieldsA[$i],
$fieldsB[$j],
$parentFieldsAreMutuallyExclusive
);
if (null !== $conflict) {
$context->reportConflict($conflict);
}
}
}
}
}
} | [
"protected",
"function",
"collectConflictsBetween",
"(",
"ComparisonContext",
"$",
"context",
",",
"array",
"$",
"fieldMapA",
",",
"array",
"$",
"fieldMapB",
",",
"bool",
"$",
"parentFieldsAreMutuallyExclusive",
")",
":",
"void",
"{",
"// A field map is a keyed collecti... | Collect all Conflicts between two collections of fields. This is similar to,
but different from the `collectConflictsWithin` function above. This check
assumes that `collectConflictsWithin` has already been called on each
provided collection of fields. This is true because this validator traverses
each individual selection set.
@param ComparisonContext $context
@param array $fieldMapA
@param array $fieldMapB
@param bool $parentFieldsAreMutuallyExclusive
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException | [
"Collect",
"all",
"Conflicts",
"between",
"two",
"collections",
"of",
"fields",
".",
"This",
"is",
"similar",
"to",
"but",
"different",
"from",
"the",
"collectConflictsWithin",
"function",
"above",
".",
"This",
"check",
"assumes",
"that",
"collectConflictsWithin",
... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L471-L506 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.findConflict | protected function findConflict(
string $responseName,
FieldContext $fieldA,
FieldContext $fieldB,
bool $parentFieldsAreMutuallyExclusive
): ?Conflict {
$parentTypeA = $fieldA->getParentType();
$parentTypeB = $fieldB->getParentType();
// If it is known that two fields could not possibly apply at the same
// time, due to the parent types, then it is safe to permit them to diverge
// in aliased field or arguments used as they will not present any ambiguity
// by differing.
// It is known that two parent types could never overlap if they are
// different Object types. Interface or Union types might overlap - if not
// in the current state of the schema, then perhaps in some future version,
// thus may not safely diverge.
$areMutuallyExclusive = $parentFieldsAreMutuallyExclusive
|| ($parentTypeA !== $parentTypeB
&& $parentTypeA instanceof ObjectType
&& $parentTypeB instanceof ObjectType);
$nodeA = $fieldA->getNode();
$nodeB = $fieldB->getNode();
$definitionA = $fieldA->getDefinition();
$definitionB = $fieldB->getDefinition();
if (!$areMutuallyExclusive) {
// Two aliases must refer to the same field.
$nameA = $nodeA->getNameValue();
$nameB = $nodeB->getNameValue();
if ($nameA !== $nameB) {
return new Conflict(
$responseName,
sprintf('%s and %s are different fields', $nameA, $nameB),
[$nodeA],
[$nodeB]
);
}
// Two field calls must have the same arguments.
if (!ValueHelper::compareArguments($nodeA->getArguments(), $nodeB->getArguments())) {
return new Conflict(
$responseName,
'they have differing arguments',
[$nodeA],
[$nodeB]
);
}
}
// The return type for each field.
$typeA = null !== $definitionA ? $definitionA->getType() : null;
$typeB = null !== $definitionB ? $definitionB->getType() : null;
if (null !== $typeA && null !== $typeB && TypeHelper::compareTypes($typeA, $typeB)) {
return new Conflict(
$responseName,
sprintf('they return conflicting types %s and %s', (string)$typeA, (string)$typeB),
[$nodeA],
[$nodeB]
);
}
// Collect and compare sub-fields. Use the same "visited fragment names" list
// for both collections so fields in a fragment reference are never
// compared to themselves.
$selectionSetA = $nodeA->getSelectionSet();
$selectionSetB = $nodeB->getSelectionSet();
if (null !== $selectionSetA && null !== $selectionSetB) {
$conflicts = $this->findConflictsBetweenSubSelectionSets(
getNamedType($typeA),
$selectionSetA,
getNamedType($typeB),
$selectionSetB,
$areMutuallyExclusive
);
return $this->subfieldConflicts($conflicts, $responseName, $nodeA, $nodeB);
}
return null;
} | php | protected function findConflict(
string $responseName,
FieldContext $fieldA,
FieldContext $fieldB,
bool $parentFieldsAreMutuallyExclusive
): ?Conflict {
$parentTypeA = $fieldA->getParentType();
$parentTypeB = $fieldB->getParentType();
// If it is known that two fields could not possibly apply at the same
// time, due to the parent types, then it is safe to permit them to diverge
// in aliased field or arguments used as they will not present any ambiguity
// by differing.
// It is known that two parent types could never overlap if they are
// different Object types. Interface or Union types might overlap - if not
// in the current state of the schema, then perhaps in some future version,
// thus may not safely diverge.
$areMutuallyExclusive = $parentFieldsAreMutuallyExclusive
|| ($parentTypeA !== $parentTypeB
&& $parentTypeA instanceof ObjectType
&& $parentTypeB instanceof ObjectType);
$nodeA = $fieldA->getNode();
$nodeB = $fieldB->getNode();
$definitionA = $fieldA->getDefinition();
$definitionB = $fieldB->getDefinition();
if (!$areMutuallyExclusive) {
// Two aliases must refer to the same field.
$nameA = $nodeA->getNameValue();
$nameB = $nodeB->getNameValue();
if ($nameA !== $nameB) {
return new Conflict(
$responseName,
sprintf('%s and %s are different fields', $nameA, $nameB),
[$nodeA],
[$nodeB]
);
}
// Two field calls must have the same arguments.
if (!ValueHelper::compareArguments($nodeA->getArguments(), $nodeB->getArguments())) {
return new Conflict(
$responseName,
'they have differing arguments',
[$nodeA],
[$nodeB]
);
}
}
// The return type for each field.
$typeA = null !== $definitionA ? $definitionA->getType() : null;
$typeB = null !== $definitionB ? $definitionB->getType() : null;
if (null !== $typeA && null !== $typeB && TypeHelper::compareTypes($typeA, $typeB)) {
return new Conflict(
$responseName,
sprintf('they return conflicting types %s and %s', (string)$typeA, (string)$typeB),
[$nodeA],
[$nodeB]
);
}
// Collect and compare sub-fields. Use the same "visited fragment names" list
// for both collections so fields in a fragment reference are never
// compared to themselves.
$selectionSetA = $nodeA->getSelectionSet();
$selectionSetB = $nodeB->getSelectionSet();
if (null !== $selectionSetA && null !== $selectionSetB) {
$conflicts = $this->findConflictsBetweenSubSelectionSets(
getNamedType($typeA),
$selectionSetA,
getNamedType($typeB),
$selectionSetB,
$areMutuallyExclusive
);
return $this->subfieldConflicts($conflicts, $responseName, $nodeA, $nodeB);
}
return null;
} | [
"protected",
"function",
"findConflict",
"(",
"string",
"$",
"responseName",
",",
"FieldContext",
"$",
"fieldA",
",",
"FieldContext",
"$",
"fieldB",
",",
"bool",
"$",
"parentFieldsAreMutuallyExclusive",
")",
":",
"?",
"Conflict",
"{",
"$",
"parentTypeA",
"=",
"$... | Determines if there is a conflict between two particular fields, including
comparing their sub-fields.
@param string $responseName
@param FieldContext $fieldA
@param FieldContext $fieldB
@param bool $parentFieldsAreMutuallyExclusive
@return Conflict|null
@throws ConversionException
@throws InvalidTypeException
@throws InvariantException | [
"Determines",
"if",
"there",
"is",
"a",
"conflict",
"between",
"two",
"particular",
"fields",
"including",
"comparing",
"their",
"sub",
"-",
"fields",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L521-L606 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.getFieldsAndFragmentNames | protected function getFieldsAndFragmentNames(
SelectionSetNode $selectionSet,
?NamedTypeInterface $parentType
): ComparisonContext {
if (!$this->cachedFieldsAndFragmentNames->offsetExists($selectionSet)) {
$cached = new ComparisonContext();
$this->collectFieldsAndFragmentNames($cached, $selectionSet, $parentType);
$this->cachedFieldsAndFragmentNames->offsetSet($selectionSet, $cached);
}
return $this->cachedFieldsAndFragmentNames->offsetGet($selectionSet);
} | php | protected function getFieldsAndFragmentNames(
SelectionSetNode $selectionSet,
?NamedTypeInterface $parentType
): ComparisonContext {
if (!$this->cachedFieldsAndFragmentNames->offsetExists($selectionSet)) {
$cached = new ComparisonContext();
$this->collectFieldsAndFragmentNames($cached, $selectionSet, $parentType);
$this->cachedFieldsAndFragmentNames->offsetSet($selectionSet, $cached);
}
return $this->cachedFieldsAndFragmentNames->offsetGet($selectionSet);
} | [
"protected",
"function",
"getFieldsAndFragmentNames",
"(",
"SelectionSetNode",
"$",
"selectionSet",
",",
"?",
"NamedTypeInterface",
"$",
"parentType",
")",
":",
"ComparisonContext",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"cachedFieldsAndFragmentNames",
"->",
"offsetE... | Given a selection set, return the collection of fields (a mapping of response
name to field nodes and definitions) as well as a list of fragment names
referenced via fragment spreads.
@param SelectionSetNode $selectionSet
@param NamedTypeInterface|null $parentType
@return ComparisonContext
@throws InvalidTypeException
@throws InvariantException
@throws ConversionException | [
"Given",
"a",
"selection",
"set",
"return",
"the",
"collection",
"of",
"fields",
"(",
"a",
"mapping",
"of",
"response",
"name",
"to",
"field",
"nodes",
"and",
"definitions",
")",
"as",
"well",
"as",
"a",
"list",
"of",
"fragment",
"names",
"referenced",
"vi... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L620-L633 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.getReferencedFieldsAndFragmentNames | protected function getReferencedFieldsAndFragmentNames(FragmentDefinitionNode $fragment): ComparisonContext
{
if ($this->cachedFieldsAndFragmentNames->offsetExists($fragment)) {
return $this->cachedFieldsAndFragmentNames->offsetGet($fragment);
}
/** @var NamedTypeInterface $fragmentType */
$fragmentType = TypeASTConverter::convert($this->getContext()->getSchema(), $fragment->getTypeCondition());
return $this->getFieldsAndFragmentNames($fragment->getSelectionSet(), $fragmentType);
} | php | protected function getReferencedFieldsAndFragmentNames(FragmentDefinitionNode $fragment): ComparisonContext
{
if ($this->cachedFieldsAndFragmentNames->offsetExists($fragment)) {
return $this->cachedFieldsAndFragmentNames->offsetGet($fragment);
}
/** @var NamedTypeInterface $fragmentType */
$fragmentType = TypeASTConverter::convert($this->getContext()->getSchema(), $fragment->getTypeCondition());
return $this->getFieldsAndFragmentNames($fragment->getSelectionSet(), $fragmentType);
} | [
"protected",
"function",
"getReferencedFieldsAndFragmentNames",
"(",
"FragmentDefinitionNode",
"$",
"fragment",
")",
":",
"ComparisonContext",
"{",
"if",
"(",
"$",
"this",
"->",
"cachedFieldsAndFragmentNames",
"->",
"offsetExists",
"(",
"$",
"fragment",
")",
")",
"{",... | Given a reference to a fragment, return the represented collection of fields
as well as a list of nested fragment names referenced via fragment spreads.
@param FragmentDefinitionNode $fragment
@return ComparisonContext
@throws InvalidTypeException
@throws ConversionException
@throws InvariantException | [
"Given",
"a",
"reference",
"to",
"a",
"fragment",
"return",
"the",
"represented",
"collection",
"of",
"fields",
"as",
"well",
"as",
"a",
"list",
"of",
"nested",
"fragment",
"names",
"referenced",
"via",
"fragment",
"spreads",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L645-L655 |
digiaonline/graphql-php | src/Validation/Conflict/ConflictFinder.php | ConflictFinder.subfieldConflicts | protected function subfieldConflicts(
array $conflicts,
string $responseName,
FieldNode $nodeA,
FieldNode $nodeB
): ?Conflict {
if (empty($conflicts)) {
return null;
}
return new Conflict(
$responseName,
array_map(function (Conflict $conflict) {
return [$conflict->getResponseName(), $conflict->getReason()];
}, $conflicts),
array_reduce($conflicts, function ($allFields, Conflict $conflict) {
return array_merge($allFields, $conflict->getFieldsA());
}, [$nodeA]),
array_reduce($conflicts, function ($allFields, Conflict $conflict) {
return array_merge($allFields, $conflict->getFieldsB());
}, [$nodeB])
);
} | php | protected function subfieldConflicts(
array $conflicts,
string $responseName,
FieldNode $nodeA,
FieldNode $nodeB
): ?Conflict {
if (empty($conflicts)) {
return null;
}
return new Conflict(
$responseName,
array_map(function (Conflict $conflict) {
return [$conflict->getResponseName(), $conflict->getReason()];
}, $conflicts),
array_reduce($conflicts, function ($allFields, Conflict $conflict) {
return array_merge($allFields, $conflict->getFieldsA());
}, [$nodeA]),
array_reduce($conflicts, function ($allFields, Conflict $conflict) {
return array_merge($allFields, $conflict->getFieldsB());
}, [$nodeB])
);
} | [
"protected",
"function",
"subfieldConflicts",
"(",
"array",
"$",
"conflicts",
",",
"string",
"$",
"responseName",
",",
"FieldNode",
"$",
"nodeA",
",",
"FieldNode",
"$",
"nodeB",
")",
":",
"?",
"Conflict",
"{",
"if",
"(",
"empty",
"(",
"$",
"conflicts",
")"... | Given a series of Conflicts which occurred between two sub-fields, generate
a single Conflict.
@param array|Conflict[] $conflicts
@param string $responseName
@param FieldNode $nodeA
@param FieldNode $nodeB
@return Conflict|null | [
"Given",
"a",
"series",
"of",
"Conflicts",
"which",
"occurred",
"between",
"two",
"sub",
"-",
"fields",
"generate",
"a",
"single",
"Conflict",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Conflict/ConflictFinder.php#L701-L723 |
digiaonline/graphql-php | src/Validation/Rule/FieldOnCorrectTypeRule.php | FieldOnCorrectTypeRule.getSuggestedTypeNames | protected function getSuggestedTypeNames(Schema $schema, TypeInterface $type, string $fieldName): array
{
if (!$type instanceof AbstractTypeInterface) {
// Otherwise, must be an Object type, which does not have possible fields.
return [];
}
$suggestedObjectTypes = [];
$interfaceUsageCount = [];
foreach ($schema->getPossibleTypes($type) as $possibleType) {
if (!$possibleType instanceof FieldsAwareInterface) {
continue;
}
$typeFields = $possibleType->getFields();
if (!isset($typeFields[$fieldName])) {
break;
}
if (!$possibleType instanceof NamedTypeInterface) {
continue;
}
$suggestedObjectTypes[] = $possibleType->getName();
if (!$possibleType instanceof ObjectType) {
continue;
}
foreach ($possibleType->getInterfaces() as $possibleInterface) {
$interfaceFields = $possibleInterface->getFields();
if (!isset($interfaceFields[$fieldName])) {
break;
}
$interfaceName = $possibleInterface->getName();
$interfaceUsageCount[$interfaceName] = ($interfaceUsageCount[$interfaceName] ?? 0) + 1;
}
}
$suggestedInterfaceTypes = \array_keys($interfaceUsageCount);
\uasort($suggestedInterfaceTypes, function ($a, $b) use ($interfaceUsageCount) {
return $interfaceUsageCount[$b] - $interfaceUsageCount[$a];
});
return \array_merge($suggestedInterfaceTypes, $suggestedObjectTypes);
} | php | protected function getSuggestedTypeNames(Schema $schema, TypeInterface $type, string $fieldName): array
{
if (!$type instanceof AbstractTypeInterface) {
// Otherwise, must be an Object type, which does not have possible fields.
return [];
}
$suggestedObjectTypes = [];
$interfaceUsageCount = [];
foreach ($schema->getPossibleTypes($type) as $possibleType) {
if (!$possibleType instanceof FieldsAwareInterface) {
continue;
}
$typeFields = $possibleType->getFields();
if (!isset($typeFields[$fieldName])) {
break;
}
if (!$possibleType instanceof NamedTypeInterface) {
continue;
}
$suggestedObjectTypes[] = $possibleType->getName();
if (!$possibleType instanceof ObjectType) {
continue;
}
foreach ($possibleType->getInterfaces() as $possibleInterface) {
$interfaceFields = $possibleInterface->getFields();
if (!isset($interfaceFields[$fieldName])) {
break;
}
$interfaceName = $possibleInterface->getName();
$interfaceUsageCount[$interfaceName] = ($interfaceUsageCount[$interfaceName] ?? 0) + 1;
}
}
$suggestedInterfaceTypes = \array_keys($interfaceUsageCount);
\uasort($suggestedInterfaceTypes, function ($a, $b) use ($interfaceUsageCount) {
return $interfaceUsageCount[$b] - $interfaceUsageCount[$a];
});
return \array_merge($suggestedInterfaceTypes, $suggestedObjectTypes);
} | [
"protected",
"function",
"getSuggestedTypeNames",
"(",
"Schema",
"$",
"schema",
",",
"TypeInterface",
"$",
"type",
",",
"string",
"$",
"fieldName",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"type",
"instanceof",
"AbstractTypeInterface",
")",
"{",
"// Otherw... | Go through all of the implementations of type, as well as the interfaces
that they implement. If any of those types include the provided field,
suggest them, sorted by how often the type is referenced, starting
with Interfaces.
@param Schema $schema
@param TypeInterface $type
@param string $fieldName
@return array
@throws InvariantException | [
"Go",
"through",
"all",
"of",
"the",
"implementations",
"of",
"type",
"as",
"well",
"as",
"the",
"interfaces",
"that",
"they",
"implement",
".",
"If",
"any",
"of",
"those",
"types",
"include",
"the",
"provided",
"field",
"suggest",
"them",
"sorted",
"by",
... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/FieldOnCorrectTypeRule.php#L75-L125 |
digiaonline/graphql-php | src/Validation/Rule/FieldOnCorrectTypeRule.php | FieldOnCorrectTypeRule.getSuggestedFieldNames | protected function getSuggestedFieldNames(OutputTypeInterface $type, string $fieldName): array
{
if (!($type instanceof ObjectType || $type instanceof InterfaceType)) {
// Otherwise, must be a Union type, which does not define fields.
return [];
}
$possibleFieldNames = \array_keys($type->getFields());
return suggestionList($fieldName, $possibleFieldNames);
} | php | protected function getSuggestedFieldNames(OutputTypeInterface $type, string $fieldName): array
{
if (!($type instanceof ObjectType || $type instanceof InterfaceType)) {
// Otherwise, must be a Union type, which does not define fields.
return [];
}
$possibleFieldNames = \array_keys($type->getFields());
return suggestionList($fieldName, $possibleFieldNames);
} | [
"protected",
"function",
"getSuggestedFieldNames",
"(",
"OutputTypeInterface",
"$",
"type",
",",
"string",
"$",
"fieldName",
")",
":",
"array",
"{",
"if",
"(",
"!",
"(",
"$",
"type",
"instanceof",
"ObjectType",
"||",
"$",
"type",
"instanceof",
"InterfaceType",
... | For the field name provided, determine if there are any similar field names
that may be the result of a typo.
@param OutputTypeInterface $type
@param string $fieldName
@return array
@throws \Exception | [
"For",
"the",
"field",
"name",
"provided",
"determine",
"if",
"there",
"are",
"any",
"similar",
"field",
"names",
"that",
"may",
"be",
"the",
"result",
"of",
"a",
"typo",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/FieldOnCorrectTypeRule.php#L136-L146 |
digiaonline/graphql-php | src/Language/NodeBuilder.php | NodeBuilder.createLocation | protected function createLocation(array $ast): ?Location
{
return isset($ast['loc']['start'], $ast['loc']['end'])
? new Location($ast['loc']['start'], $ast['loc']['end'], $ast['loc']['source'] ?? null)
: null;
} | php | protected function createLocation(array $ast): ?Location
{
return isset($ast['loc']['start'], $ast['loc']['end'])
? new Location($ast['loc']['start'], $ast['loc']['end'], $ast['loc']['source'] ?? null)
: null;
} | [
"protected",
"function",
"createLocation",
"(",
"array",
"$",
"ast",
")",
":",
"?",
"Location",
"{",
"return",
"isset",
"(",
"$",
"ast",
"[",
"'loc'",
"]",
"[",
"'start'",
"]",
",",
"$",
"ast",
"[",
"'loc'",
"]",
"[",
"'end'",
"]",
")",
"?",
"new",... | Creates a location object.
@param array $ast
@return Location|null | [
"Creates",
"a",
"location",
"object",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/NodeBuilder.php#L783-L788 |
digiaonline/graphql-php | src/Language/NodeBuilder.php | NodeBuilder.buildNode | protected function buildNode(array $ast, string $propertyName): ?NodeInterface
{
return isset($ast[$propertyName]) ? $this->build($ast[$propertyName]) : null;
} | php | protected function buildNode(array $ast, string $propertyName): ?NodeInterface
{
return isset($ast[$propertyName]) ? $this->build($ast[$propertyName]) : null;
} | [
"protected",
"function",
"buildNode",
"(",
"array",
"$",
"ast",
",",
"string",
"$",
"propertyName",
")",
":",
"?",
"NodeInterface",
"{",
"return",
"isset",
"(",
"$",
"ast",
"[",
"$",
"propertyName",
"]",
")",
"?",
"$",
"this",
"->",
"build",
"(",
"$",
... | Builds a single item from the given AST.
@param array $ast
@param string $propertyName
@return NodeInterface|null
@throws LanguageException | [
"Builds",
"a",
"single",
"item",
"from",
"the",
"given",
"AST",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/NodeBuilder.php#L811-L814 |
digiaonline/graphql-php | src/Language/NodeBuilder.php | NodeBuilder.buildNodes | protected function buildNodes(array $ast, string $propertyName): array
{
$array = [];
if (isset($ast[$propertyName]) && \is_array($ast[$propertyName])) {
foreach ($ast[$propertyName] as $subAst) {
$array[] = $this->build($subAst);
}
}
return $array;
} | php | protected function buildNodes(array $ast, string $propertyName): array
{
$array = [];
if (isset($ast[$propertyName]) && \is_array($ast[$propertyName])) {
foreach ($ast[$propertyName] as $subAst) {
$array[] = $this->build($subAst);
}
}
return $array;
} | [
"protected",
"function",
"buildNodes",
"(",
"array",
"$",
"ast",
",",
"string",
"$",
"propertyName",
")",
":",
"array",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"ast",
"[",
"$",
"propertyName",
"]",
")",
"&&",
"\\",
"is_... | Builds many items from the given AST.
@param array $ast
@param string $propertyName
@return NodeInterface[]
@throws LanguageException | [
"Builds",
"many",
"items",
"from",
"the",
"given",
"AST",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/NodeBuilder.php#L824-L835 |
digiaonline/graphql-php | src/Validation/Rule/SupportedRules.php | SupportedRules.build | public static function build(): array
{
$rules = [];
foreach (self::$supportedRules as $className) {
$rules[] = GraphQL::make($className);
}
return $rules;
} | php | public static function build(): array
{
$rules = [];
foreach (self::$supportedRules as $className) {
$rules[] = GraphQL::make($className);
}
return $rules;
} | [
"public",
"static",
"function",
"build",
"(",
")",
":",
"array",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"supportedRules",
"as",
"$",
"className",
")",
"{",
"$",
"rules",
"[",
"]",
"=",
"GraphQL",
"::",
"make",
"("... | Rules maintain state so they should always new instances.
@return array | [
"Rules",
"maintain",
"state",
"so",
"they",
"should",
"always",
"new",
"instances",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/SupportedRules.php#L45-L54 |
digiaonline/graphql-php | src/Type/Coercer/IntCoercer.php | IntCoercer.coerce | public function coerce($value): int
{
if ($value === '') {
throw new InvalidTypeException('Int cannot represent non 32-bit signed integer value: (empty string)');
}
if (\is_bool($value)) {
$value = (int)$value;
}
if (!\is_numeric($value) || $value > PHP_INT_MAX || $value < PHP_INT_MIN) {
throw new InvalidTypeException(
\sprintf('Int cannot represent non 32-bit signed integer value: %s', $value)
);
}
$floatValue = (float)$value;
if ($floatValue != $value || \floor($floatValue) !== $floatValue) {
throw new InvalidTypeException(\sprintf('Int cannot represent non-integer value: %s', $value));
}
return (int)$value;
} | php | public function coerce($value): int
{
if ($value === '') {
throw new InvalidTypeException('Int cannot represent non 32-bit signed integer value: (empty string)');
}
if (\is_bool($value)) {
$value = (int)$value;
}
if (!\is_numeric($value) || $value > PHP_INT_MAX || $value < PHP_INT_MIN) {
throw new InvalidTypeException(
\sprintf('Int cannot represent non 32-bit signed integer value: %s', $value)
);
}
$floatValue = (float)$value;
if ($floatValue != $value || \floor($floatValue) !== $floatValue) {
throw new InvalidTypeException(\sprintf('Int cannot represent non-integer value: %s', $value));
}
return (int)$value;
} | [
"public",
"function",
"coerce",
"(",
"$",
"value",
")",
":",
"int",
"{",
"if",
"(",
"$",
"value",
"===",
"''",
")",
"{",
"throw",
"new",
"InvalidTypeException",
"(",
"'Int cannot represent non 32-bit signed integer value: (empty string)'",
")",
";",
"}",
"if",
"... | @inheritdoc
@throws InvalidTypeException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Type/Coercer/IntCoercer.php#L14-L37 |
digiaonline/graphql-php | src/Validation/Rule/VariablesInAllowedPositionRule.php | VariablesInAllowedPositionRule.leaveOperationDefinition | protected function leaveOperationDefinition(OperationDefinitionNode $node): VisitorResult
{
$usages = $this->context->getRecursiveVariableUsages($node);
/**
* @var VariableNode $variableNode
* @var TypeInterface $type
*/
foreach ($usages as ['node' => $variableNode, 'type' => $type]) {
$variableName = $variableNode->getNameValue();
$variableDefinition = $this->variableDefinitionMap[$variableName];
if (null !== $variableDefinition && null !== $type) {
// A var type is allowed if it is the same or more strict (e.g. is
// a subtype of) than the expected type. It can be more strict if
// the variable type is non-null when the expected type is nullable.
// If both are list types, the variable item type can be more strict
// than the expected item type (contravariant).
$schema = $this->context->getSchema();
$variableType = TypeASTConverter::convert($schema, $variableDefinition->getType());
if (null !== $variableType &&
!TypeHelper::isTypeSubtypeOf(
$schema,
$this->getEffectiveType($variableType, $variableDefinition),
$type
)
) {
$this->context->reportError(
new ValidationException(
badVariablePositionMessage($variableName, (string)$variableType, (string)$type),
[$variableDefinition, $variableNode]
)
);
}
}
}
return new VisitorResult($node);
} | php | protected function leaveOperationDefinition(OperationDefinitionNode $node): VisitorResult
{
$usages = $this->context->getRecursiveVariableUsages($node);
/**
* @var VariableNode $variableNode
* @var TypeInterface $type
*/
foreach ($usages as ['node' => $variableNode, 'type' => $type]) {
$variableName = $variableNode->getNameValue();
$variableDefinition = $this->variableDefinitionMap[$variableName];
if (null !== $variableDefinition && null !== $type) {
// A var type is allowed if it is the same or more strict (e.g. is
// a subtype of) than the expected type. It can be more strict if
// the variable type is non-null when the expected type is nullable.
// If both are list types, the variable item type can be more strict
// than the expected item type (contravariant).
$schema = $this->context->getSchema();
$variableType = TypeASTConverter::convert($schema, $variableDefinition->getType());
if (null !== $variableType &&
!TypeHelper::isTypeSubtypeOf(
$schema,
$this->getEffectiveType($variableType, $variableDefinition),
$type
)
) {
$this->context->reportError(
new ValidationException(
badVariablePositionMessage($variableName, (string)$variableType, (string)$type),
[$variableDefinition, $variableNode]
)
);
}
}
}
return new VisitorResult($node);
} | [
"protected",
"function",
"leaveOperationDefinition",
"(",
"OperationDefinitionNode",
"$",
"node",
")",
":",
"VisitorResult",
"{",
"$",
"usages",
"=",
"$",
"this",
"->",
"context",
"->",
"getRecursiveVariableUsages",
"(",
"$",
"node",
")",
";",
"/**\n * @var ... | @inheritdoc
@throws InvariantException
@throws \Digia\GraphQL\Util\ConversionException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/VariablesInAllowedPositionRule.php#L46-L85 |
digiaonline/graphql-php | src/Validation/Rule/VariablesInAllowedPositionRule.php | VariablesInAllowedPositionRule.getEffectiveType | protected function getEffectiveType(
TypeInterface $variableType,
VariableDefinitionNode $variableDefinition
): TypeInterface {
return (!$variableDefinition->hasDefaultValue() || $variableType instanceof NonNullType)
? $variableType
: newNonNull($variableType);
} | php | protected function getEffectiveType(
TypeInterface $variableType,
VariableDefinitionNode $variableDefinition
): TypeInterface {
return (!$variableDefinition->hasDefaultValue() || $variableType instanceof NonNullType)
? $variableType
: newNonNull($variableType);
} | [
"protected",
"function",
"getEffectiveType",
"(",
"TypeInterface",
"$",
"variableType",
",",
"VariableDefinitionNode",
"$",
"variableDefinition",
")",
":",
"TypeInterface",
"{",
"return",
"(",
"!",
"$",
"variableDefinition",
"->",
"hasDefaultValue",
"(",
")",
"||",
... | If a variable definition has a default value, it's effectively non-null.
@param TypeInterface $variableType
@param VariableDefinitionNode $variableDefinition
@return TypeInterface
@throws InvariantException | [
"If",
"a",
"variable",
"definition",
"has",
"a",
"default",
"value",
"it",
"s",
"effectively",
"non",
"-",
"null",
"."
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Validation/Rule/VariablesInAllowedPositionRule.php#L106-L113 |
digiaonline/graphql-php | src/Util/TypeASTConverter.php | TypeASTConverter.convert | public static function convert(Schema $schema, TypeNodeInterface $typeNode): ?TypeInterface
{
$innerType = null;
if ($typeNode instanceof ListTypeNode) {
$innerType = self::convert($schema, $typeNode->getType());
return null !== $innerType ? newList($innerType) : null;
}
if ($typeNode instanceof NonNullTypeNode) {
$innerType = self::convert($schema, $typeNode->getType());
return null !== $innerType ? newNonNull($innerType) : null;
}
if ($typeNode instanceof NamedTypeNode) {
return $schema->getType($typeNode->getNameValue());
}
throw new ConversionException(sprintf('Unexpected type kind: %s', $typeNode->getKind()));
} | php | public static function convert(Schema $schema, TypeNodeInterface $typeNode): ?TypeInterface
{
$innerType = null;
if ($typeNode instanceof ListTypeNode) {
$innerType = self::convert($schema, $typeNode->getType());
return null !== $innerType ? newList($innerType) : null;
}
if ($typeNode instanceof NonNullTypeNode) {
$innerType = self::convert($schema, $typeNode->getType());
return null !== $innerType ? newNonNull($innerType) : null;
}
if ($typeNode instanceof NamedTypeNode) {
return $schema->getType($typeNode->getNameValue());
}
throw new ConversionException(sprintf('Unexpected type kind: %s', $typeNode->getKind()));
} | [
"public",
"static",
"function",
"convert",
"(",
"Schema",
"$",
"schema",
",",
"TypeNodeInterface",
"$",
"typeNode",
")",
":",
"?",
"TypeInterface",
"{",
"$",
"innerType",
"=",
"null",
";",
"if",
"(",
"$",
"typeNode",
"instanceof",
"ListTypeNode",
")",
"{",
... | Given a Schema and an AST node describing a type, return a GraphQLType
definition which applies to that type. For example, if provided the parsed
AST node for `[User]`, a GraphQLList instance will be returned, containing
the type called "User" found in the schema. If a type called "User" is not
found in the schema, then undefined will be returned.
@param Schema $schema
@param TypeNodeInterface $typeNode
@return TypeInterface|null
@throws InvariantException
@throws ConversionException | [
"Given",
"a",
"Schema",
"and",
"an",
"AST",
"node",
"describing",
"a",
"type",
"return",
"a",
"GraphQLType",
"definition",
"which",
"applies",
"to",
"that",
"type",
".",
"For",
"example",
"if",
"provided",
"the",
"parsed",
"AST",
"node",
"for",
"[",
"User"... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Util/TypeASTConverter.php#L31-L50 |
digiaonline/graphql-php | src/Schema/Validation/Rule/TypesRule.php | TypesRule.evaluate | public function evaluate(): void
{
$typeMap = $this->context->getSchema()->getTypeMap();
foreach ($typeMap as $type) {
if (!($type instanceof NamedTypeInterface)) {
$this->context->reportError(
new SchemaValidationException(
\sprintf('Expected GraphQL named type but got: %s.', toString($type)),
$type instanceof ASTNodeAwareInterface ? [$type->getAstNode()] : null
)
);
continue;
}
// Ensure it is named correctly (excluding introspection types).
/** @noinspection PhpParamsInspection */
if (!isIntrospectionType($type)) {
$this->validateName($type);
}
if ($type instanceof ObjectType) {
// Ensure fields are valid.
$this->validateFields($type);
// Ensure objects implement the interfaces they claim to.
$this->validateObjectInterfaces($type);
continue;
}
if ($type instanceof InterfaceType) {
// Ensure fields are valid.
$this->validateFields($type);
continue;
}
if ($type instanceof UnionType) {
// Ensure Unions include valid member types.
$this->validateUnionMembers($type);
continue;
}
if ($type instanceof EnumType) {
// Ensure Enums have valid values.
$this->validateEnumValues($type);
continue;
}
if ($type instanceof InputObjectType) {
// Ensure Input Object fields are valid.
$this->validateInputFields($type);
continue;
}
}
} | php | public function evaluate(): void
{
$typeMap = $this->context->getSchema()->getTypeMap();
foreach ($typeMap as $type) {
if (!($type instanceof NamedTypeInterface)) {
$this->context->reportError(
new SchemaValidationException(
\sprintf('Expected GraphQL named type but got: %s.', toString($type)),
$type instanceof ASTNodeAwareInterface ? [$type->getAstNode()] : null
)
);
continue;
}
// Ensure it is named correctly (excluding introspection types).
/** @noinspection PhpParamsInspection */
if (!isIntrospectionType($type)) {
$this->validateName($type);
}
if ($type instanceof ObjectType) {
// Ensure fields are valid.
$this->validateFields($type);
// Ensure objects implement the interfaces they claim to.
$this->validateObjectInterfaces($type);
continue;
}
if ($type instanceof InterfaceType) {
// Ensure fields are valid.
$this->validateFields($type);
continue;
}
if ($type instanceof UnionType) {
// Ensure Unions include valid member types.
$this->validateUnionMembers($type);
continue;
}
if ($type instanceof EnumType) {
// Ensure Enums have valid values.
$this->validateEnumValues($type);
continue;
}
if ($type instanceof InputObjectType) {
// Ensure Input Object fields are valid.
$this->validateInputFields($type);
continue;
}
}
} | [
"public",
"function",
"evaluate",
"(",
")",
":",
"void",
"{",
"$",
"typeMap",
"=",
"$",
"this",
"->",
"context",
"->",
"getSchema",
"(",
")",
"->",
"getTypeMap",
"(",
")",
";",
"foreach",
"(",
"$",
"typeMap",
"as",
"$",
"type",
")",
"{",
"if",
"(",... | @inheritdoc
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Schema/Validation/Rule/TypesRule.php#L42-L96 |
digiaonline/graphql-php | src/Schema/DefinitionPrinter.php | DefinitionPrinter.isSchemaOfCommonNames | protected function isSchemaOfCommonNames(Schema $schema): bool
{
if (null !== ($queryType = $schema->getQueryType()) &&
$queryType->getName() !== 'Query') {
return false;
}
if (null !== ($mutationType = $schema->getMutationType()) &&
$mutationType->getName() !== 'Mutation') {
return false;
}
if (null !== ($subscriptionType = $schema->getSubscriptionType()) &&
$subscriptionType->getName() !== 'Subscription') {
return false;
}
return true;
} | php | protected function isSchemaOfCommonNames(Schema $schema): bool
{
if (null !== ($queryType = $schema->getQueryType()) &&
$queryType->getName() !== 'Query') {
return false;
}
if (null !== ($mutationType = $schema->getMutationType()) &&
$mutationType->getName() !== 'Mutation') {
return false;
}
if (null !== ($subscriptionType = $schema->getSubscriptionType()) &&
$subscriptionType->getName() !== 'Subscription') {
return false;
}
return true;
} | [
"protected",
"function",
"isSchemaOfCommonNames",
"(",
"Schema",
"$",
"schema",
")",
":",
"bool",
"{",
"if",
"(",
"null",
"!==",
"(",
"$",
"queryType",
"=",
"$",
"schema",
"->",
"getQueryType",
"(",
")",
")",
"&&",
"$",
"queryType",
"->",
"getName",
"(",... | GraphQL schema define root types for each type of operation. These types are
the same as any other type and can be named in any manner, however there is
a common naming convention:
schema {
query: Query
mutation: Mutation
subscription: Subscription
}
When using this naming convention, the schema description can be omitted.
@param Schema $schema
@return bool | [
"GraphQL",
"schema",
"define",
"root",
"types",
"for",
"each",
"type",
"of",
"operation",
".",
"These",
"types",
"are",
"the",
"same",
"as",
"any",
"other",
"type",
"and",
"can",
"be",
"named",
"in",
"any",
"manner",
"however",
"there",
"is",
"a",
"commo... | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Schema/DefinitionPrinter.php#L192-L210 |
digiaonline/graphql-php | src/Language/MultiFileSourceBuilder.php | MultiFileSourceBuilder.build | public function build(): Source
{
$combinedSource = '';
foreach ($this->filePaths as $filePath) {
if (!\file_exists($filePath) || !\is_readable($filePath)) {
throw new FileNotFoundException(sprintf('The file %s cannot be found or is not readable', $filePath));
}
$combinedSource .= \file_get_contents($filePath);
}
return new Source($combinedSource);
} | php | public function build(): Source
{
$combinedSource = '';
foreach ($this->filePaths as $filePath) {
if (!\file_exists($filePath) || !\is_readable($filePath)) {
throw new FileNotFoundException(sprintf('The file %s cannot be found or is not readable', $filePath));
}
$combinedSource .= \file_get_contents($filePath);
}
return new Source($combinedSource);
} | [
"public",
"function",
"build",
"(",
")",
":",
"Source",
"{",
"$",
"combinedSource",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"filePaths",
"as",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"\\",
"file_exists",
"(",
"$",
"filePath",
")",
"||",... | @inheritdoc
@throws FileNotFoundException
@throws InvariantException | [
"@inheritdoc"
] | train | https://github.com/digiaonline/graphql-php/blob/a5d6475ce0f3329850ced33e5f0eac6269eea2df/src/Language/MultiFileSourceBuilder.php#L35-L48 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/RabbitMqSupervisorExtension.php | RabbitMqSupervisorExtension.load | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
// check that commands do not contain sprintf specifiers that were required by older versions
foreach ($config['commands'] as $command) {
if (false !== strpos($command, '%')) {
throw new InvalidConfigurationException(sprintf(
'Invalid configuration for path "%s": %s',
'rabbit_mq_supervisor.commands',
'command is no longer allowed to contain sprintf specifiers (e.g. "%1$d")'
));
}
}
$consumer = [];
if (!empty($config['consumer'])) {
$consumer = $config['consumer'];
}
if (empty($consumer['general']['worker'])) {
$consumer['general']['worker'] = [];
}
// take over worker count from old configuration key
if (null !== $config['worker_count']) {
$consumer['general']['worker']['count'] = $config['worker_count'];
}
// set default value of 250 if messages is not set or set to default value
if (!array_key_exists('messages', $consumer['general']) || null === $consumer['general']['messages']) {
$consumer['general']['messages'] = 250;
}
$container->setParameter('phobetor_rabbitmq_supervisor.config', array('consumer' => $consumer));
$container->setParameter('phobetor_rabbitmq_supervisor.supervisor_instance_identifier', $config['supervisor_instance_identifier']);
$container->setParameter('phobetor_rabbitmq_supervisor.paths', $config['paths']);
$container->setParameter('phobetor_rabbitmq_supervisor.workspace', $config['paths']['workspace_directory']);
$container->setParameter('phobetor_rabbitmq_supervisor.configuration_file', $config['paths']['configuration_file']);
$container->setParameter('phobetor_rabbitmq_supervisor.commands', $config['commands']);
} | php | public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
// check that commands do not contain sprintf specifiers that were required by older versions
foreach ($config['commands'] as $command) {
if (false !== strpos($command, '%')) {
throw new InvalidConfigurationException(sprintf(
'Invalid configuration for path "%s": %s',
'rabbit_mq_supervisor.commands',
'command is no longer allowed to contain sprintf specifiers (e.g. "%1$d")'
));
}
}
$consumer = [];
if (!empty($config['consumer'])) {
$consumer = $config['consumer'];
}
if (empty($consumer['general']['worker'])) {
$consumer['general']['worker'] = [];
}
// take over worker count from old configuration key
if (null !== $config['worker_count']) {
$consumer['general']['worker']['count'] = $config['worker_count'];
}
// set default value of 250 if messages is not set or set to default value
if (!array_key_exists('messages', $consumer['general']) || null === $consumer['general']['messages']) {
$consumer['general']['messages'] = 250;
}
$container->setParameter('phobetor_rabbitmq_supervisor.config', array('consumer' => $consumer));
$container->setParameter('phobetor_rabbitmq_supervisor.supervisor_instance_identifier', $config['supervisor_instance_identifier']);
$container->setParameter('phobetor_rabbitmq_supervisor.paths', $config['paths']);
$container->setParameter('phobetor_rabbitmq_supervisor.workspace', $config['paths']['workspace_directory']);
$container->setParameter('phobetor_rabbitmq_supervisor.configuration_file', $config['paths']['configuration_file']);
$container->setParameter('phobetor_rabbitmq_supervisor.commands', $config['commands']);
} | [
"public",
"function",
"load",
"(",
"array",
"$",
"configs",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"configuration",
"=",
"new",
"Configuration",
"(",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"processConfiguration",
"(",
"$",
"con... | {@inheritDoc} | [
"{"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/RabbitMqSupervisorExtension.php#L20-L64 |
Phobetor/rabbitmq-supervisor-bundle | Services/RabbitMqSupervisor.php | RabbitMqSupervisor.build | public function build()
{
$this->createPathDirectories();
if (!is_file($this->createSupervisorConfigurationFilePath())) {
$this->generateSupervisorConfiguration();
}
// remove old worker configuration files
/** @var \SplFileInfo $item */
foreach (new \DirectoryIterator($this->paths['worker_configuration_directory']) as $item) {
if ($item->isDir()) {
continue;
}
if ('conf' !== $item->getExtension()) {
continue;
}
unlink($item->getRealPath());
}
// generate program configuration files for all consumers
$this->generateWorkerConfigurations(array_keys($this->consumers), $this->commands['rabbitmq_consumer']);
// generate program configuration files for all multiple consumers
$this->generateWorkerConfigurations(array_keys($this->multipleConsumers), $this->commands['rabbitmq_multiple_consumer']);
// generate program configuration files for all batch consumers
$this->generateWorkerConfigurations(array_keys($this->batchConsumers), $this->commands['rabbitmq_batch_consumer']);
//generate program configuration files for all rpc_server consumers
$this->generateWorkerConfigurations(array_keys($this->rpcServers), $this->commands['rabbitmq_rpc_server']);
// start supervisord and reload configuration
$this->supervisor->runAndReload();
} | php | public function build()
{
$this->createPathDirectories();
if (!is_file($this->createSupervisorConfigurationFilePath())) {
$this->generateSupervisorConfiguration();
}
// remove old worker configuration files
/** @var \SplFileInfo $item */
foreach (new \DirectoryIterator($this->paths['worker_configuration_directory']) as $item) {
if ($item->isDir()) {
continue;
}
if ('conf' !== $item->getExtension()) {
continue;
}
unlink($item->getRealPath());
}
// generate program configuration files for all consumers
$this->generateWorkerConfigurations(array_keys($this->consumers), $this->commands['rabbitmq_consumer']);
// generate program configuration files for all multiple consumers
$this->generateWorkerConfigurations(array_keys($this->multipleConsumers), $this->commands['rabbitmq_multiple_consumer']);
// generate program configuration files for all batch consumers
$this->generateWorkerConfigurations(array_keys($this->batchConsumers), $this->commands['rabbitmq_batch_consumer']);
//generate program configuration files for all rpc_server consumers
$this->generateWorkerConfigurations(array_keys($this->rpcServers), $this->commands['rabbitmq_rpc_server']);
// start supervisord and reload configuration
$this->supervisor->runAndReload();
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"createPathDirectories",
"(",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"this",
"->",
"createSupervisorConfigurationFilePath",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"generateSuperv... | Build all supervisor worker configuration files | [
"Build",
"all",
"supervisor",
"worker",
"configuration",
"files"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/RabbitMqSupervisor.php#L109-L145 |
Phobetor/rabbitmq-supervisor-bundle | Services/RabbitMqSupervisor.php | RabbitMqSupervisor.kill | public function kill($signal = '', $waitForProcessToDisappear = false)
{
$pid = $this->getSupervisorPid();
if (!empty($pid) && $this->isProcessRunning($pid)) {
if (!empty($signal)) {
$signal = sprintf('-%s', $signal);
}
$command = sprintf('kill %s %d', $signal, $pid);
passthru($command);
if ($waitForProcessToDisappear) {
$this->wait();
}
}
} | php | public function kill($signal = '', $waitForProcessToDisappear = false)
{
$pid = $this->getSupervisorPid();
if (!empty($pid) && $this->isProcessRunning($pid)) {
if (!empty($signal)) {
$signal = sprintf('-%s', $signal);
}
$command = sprintf('kill %s %d', $signal, $pid);
passthru($command);
if ($waitForProcessToDisappear) {
$this->wait();
}
}
} | [
"public",
"function",
"kill",
"(",
"$",
"signal",
"=",
"''",
",",
"$",
"waitForProcessToDisappear",
"=",
"false",
")",
"{",
"$",
"pid",
"=",
"$",
"this",
"->",
"getSupervisorPid",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pid",
")",
"&&",
... | Send kill signal to supervisord
@param string $signal
@param bool $waitForProcessToDisappear | [
"Send",
"kill",
"signal",
"to",
"supervisord"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/RabbitMqSupervisor.php#L195-L211 |
Phobetor/rabbitmq-supervisor-bundle | Services/RabbitMqSupervisor.php | RabbitMqSupervisor.wait | public function wait()
{
$pid = $this->getSupervisorPid();
if (!empty($pid)) {
while ($this->isProcessRunning($pid)) {
sleep(1);
}
}
} | php | public function wait()
{
$pid = $this->getSupervisorPid();
if (!empty($pid)) {
while ($this->isProcessRunning($pid)) {
sleep(1);
}
}
} | [
"public",
"function",
"wait",
"(",
")",
"{",
"$",
"pid",
"=",
"$",
"this",
"->",
"getSupervisorPid",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"pid",
")",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"isProcessRunning",
"(",
"$",
"pid",
")"... | Wait for supervisord process to disappear | [
"Wait",
"for",
"supervisord",
"process",
"to",
"disappear"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/RabbitMqSupervisor.php#L216-L224 |
Phobetor/rabbitmq-supervisor-bundle | Services/RabbitMqSupervisor.php | RabbitMqSupervisor.isProcessRunning | private function isProcessRunning($pid)
{
$state = array();
exec(sprintf('ps -o pid %d', $pid), $state);
// remove alignment spaces from PIDs
$state = array_map('trim', $state);
/*
* ps will return at least one row, the column labels.
* If the process is running ps will return a second row with its status.
*
* check if pid is in that list to work even if some systems ignore the pid filter parameter
*/
return 1 < count($state) && in_array($pid, $state);
} | php | private function isProcessRunning($pid)
{
$state = array();
exec(sprintf('ps -o pid %d', $pid), $state);
// remove alignment spaces from PIDs
$state = array_map('trim', $state);
/*
* ps will return at least one row, the column labels.
* If the process is running ps will return a second row with its status.
*
* check if pid is in that list to work even if some systems ignore the pid filter parameter
*/
return 1 < count($state) && in_array($pid, $state);
} | [
"private",
"function",
"isProcessRunning",
"(",
"$",
"pid",
")",
"{",
"$",
"state",
"=",
"array",
"(",
")",
";",
"exec",
"(",
"sprintf",
"(",
"'ps -o pid %d'",
",",
"$",
"pid",
")",
",",
"$",
"state",
")",
";",
"// remove alignment spaces from PIDs",
"$",
... | Check if a process with the given pid is running
@param int $pid
@return bool | [
"Check",
"if",
"a",
"process",
"with",
"the",
"given",
"pid",
"is",
"running"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/RabbitMqSupervisor.php#L232-L247 |
Phobetor/rabbitmq-supervisor-bundle | Services/RabbitMqSupervisor.php | RabbitMqSupervisor.getSupervisorPid | private function getSupervisorPid()
{
$pidPath = $this->paths['pid_file'];
$pid = null;
if (is_file($pidPath) && is_readable($pidPath)) {
$pid = (int)file_get_contents($pidPath);
}
return $pid;
} | php | private function getSupervisorPid()
{
$pidPath = $this->paths['pid_file'];
$pid = null;
if (is_file($pidPath) && is_readable($pidPath)) {
$pid = (int)file_get_contents($pidPath);
}
return $pid;
} | [
"private",
"function",
"getSupervisorPid",
"(",
")",
"{",
"$",
"pidPath",
"=",
"$",
"this",
"->",
"paths",
"[",
"'pid_file'",
"]",
";",
"$",
"pid",
"=",
"null",
";",
"if",
"(",
"is_file",
"(",
"$",
"pidPath",
")",
"&&",
"is_readable",
"(",
"$",
"pidP... | Determines the supervisord process id
@return null|int | [
"Determines",
"the",
"supervisord",
"process",
"id"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/RabbitMqSupervisor.php#L254-L264 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/Configuration.php | Configuration.addPaths | protected function addPaths(ArrayNodeDefinition $node)
{
$node
->fixXmlConfig('path')
->children()
->arrayNode('paths')
->addDefaultsIfNotSet()
->children()
->scalarNode('workspace_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/')->end()
->scalarNode('configuration_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.conf')->end()
->scalarNode('pid_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.pid')->end()
->scalarNode('sock_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.sock')->end()
->scalarNode('log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.log')->end()
->scalarNode('worker_configuration_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/worker/')->end()
->scalarNode('worker_output_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stdout.log')->end()
->scalarNode('worker_error_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stderr.log')->end()
->scalarNode('php_executable')->defaultValue('php')->end()
->end()
->end()
->end()
;
} | php | protected function addPaths(ArrayNodeDefinition $node)
{
$node
->fixXmlConfig('path')
->children()
->arrayNode('paths')
->addDefaultsIfNotSet()
->children()
->scalarNode('workspace_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/')->end()
->scalarNode('configuration_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.conf')->end()
->scalarNode('pid_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.pid')->end()
->scalarNode('sock_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisor.sock')->end()
->scalarNode('log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/supervisord.log')->end()
->scalarNode('worker_configuration_directory')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/worker/')->end()
->scalarNode('worker_output_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stdout.log')->end()
->scalarNode('worker_error_log_file')->defaultValue('%kernel.root_dir%/supervisor/%kernel.environment%/logs/stderr.log')->end()
->scalarNode('php_executable')->defaultValue('php')->end()
->end()
->end()
->end()
;
} | [
"protected",
"function",
"addPaths",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"fixXmlConfig",
"(",
"'path'",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'paths'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
... | Add paths configuration
@param ArrayNodeDefinition $node | [
"Add",
"paths",
"configuration"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/Configuration.php#L40-L61 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/Configuration.php | Configuration.addCommands | protected function addCommands(ArrayNodeDefinition $node)
{
$node
->fixXmlConfig('command')
->children()
->arrayNode('commands')
->addDefaultsIfNotSet()
->children()
->scalarNode('rabbitmq_consumer')->defaultValue('rabbitmq:consumer')->end()
->scalarNode('rabbitmq_multiple_consumer')->defaultValue('rabbitmq:multiple-consumer')->end()
->scalarNode('rabbitmq_batch_consumer')->defaultValue('rabbitmq:batch:consumer')->end()
->scalarNode('rabbitmq_rpc_server')->defaultValue('rabbitmq:rpc-server')->end()
->end()
->end()
->end()
;
} | php | protected function addCommands(ArrayNodeDefinition $node)
{
$node
->fixXmlConfig('command')
->children()
->arrayNode('commands')
->addDefaultsIfNotSet()
->children()
->scalarNode('rabbitmq_consumer')->defaultValue('rabbitmq:consumer')->end()
->scalarNode('rabbitmq_multiple_consumer')->defaultValue('rabbitmq:multiple-consumer')->end()
->scalarNode('rabbitmq_batch_consumer')->defaultValue('rabbitmq:batch:consumer')->end()
->scalarNode('rabbitmq_rpc_server')->defaultValue('rabbitmq:rpc-server')->end()
->end()
->end()
->end()
;
} | [
"protected",
"function",
"addCommands",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"fixXmlConfig",
"(",
"'command'",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'commands'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
... | Add commands configuration
@param ArrayNodeDefinition $node | [
"Add",
"commands",
"configuration"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/Configuration.php#L68-L84 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/Configuration.php | Configuration.addConsumer | protected function addConsumer(ArrayNodeDefinition $node)
{
$consumerChildren = $node
->children()
->arrayNode('consumer')
->addDefaultsIfNotSet()
->children();
$general = $consumerChildren
->arrayNode('general');
$this->addGeneralConsumerConfiguration($general);
$individualPrototype = $consumerChildren
->arrayNode('individual')
->useAttributeAsKey('consumer')
->prototype('array');
$this->addIndividualConsumerConfiguration($individualPrototype);
} | php | protected function addConsumer(ArrayNodeDefinition $node)
{
$consumerChildren = $node
->children()
->arrayNode('consumer')
->addDefaultsIfNotSet()
->children();
$general = $consumerChildren
->arrayNode('general');
$this->addGeneralConsumerConfiguration($general);
$individualPrototype = $consumerChildren
->arrayNode('individual')
->useAttributeAsKey('consumer')
->prototype('array');
$this->addIndividualConsumerConfiguration($individualPrototype);
} | [
"protected",
"function",
"addConsumer",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"consumerChildren",
"=",
"$",
"node",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'consumer'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children"... | Add general and individual consumer configuration
@param ArrayNodeDefinition $node | [
"Add",
"general",
"and",
"individual",
"consumer",
"configuration"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/Configuration.php#L91-L108 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/Configuration.php | Configuration.addGeneralConsumerConfiguration | protected function addGeneralConsumerConfiguration(ArrayNodeDefinition $node)
{
$node
->normalizeKeys(false)
->addDefaultsIfNotSet()
->children()
->integerNode('messages')
->min(0)
->defaultValue(250)
->end()
->integerNode('memory-limit')
->defaultNull()
->end()
->booleanNode('debug')
->defaultNull()
->end()
->booleanNode('without-signals')
->defaultNull()
->end()
->arrayNode('worker')
->addDefaultsIfNotSet()
->children()
->integerNode('count')
->min(1)
->defaultValue(1)
->end()
->integerNode('startsecs')
->min(0)
->defaultValue(2)
->end()
->booleanNode('autorestart')
->defaultTrue()
->end()
->enumNode('stopsignal')
->values(array('TERM', 'INT', 'KILL'))
->defaultValue('INT')
->end()
->booleanNode('stopasgroup')
->defaultTrue()
->end()
->integerNode('stopwaitsecs')
->min(0)
->defaultValue(60)
->end()
->end()
->end()
->end()
;
} | php | protected function addGeneralConsumerConfiguration(ArrayNodeDefinition $node)
{
$node
->normalizeKeys(false)
->addDefaultsIfNotSet()
->children()
->integerNode('messages')
->min(0)
->defaultValue(250)
->end()
->integerNode('memory-limit')
->defaultNull()
->end()
->booleanNode('debug')
->defaultNull()
->end()
->booleanNode('without-signals')
->defaultNull()
->end()
->arrayNode('worker')
->addDefaultsIfNotSet()
->children()
->integerNode('count')
->min(1)
->defaultValue(1)
->end()
->integerNode('startsecs')
->min(0)
->defaultValue(2)
->end()
->booleanNode('autorestart')
->defaultTrue()
->end()
->enumNode('stopsignal')
->values(array('TERM', 'INT', 'KILL'))
->defaultValue('INT')
->end()
->booleanNode('stopasgroup')
->defaultTrue()
->end()
->integerNode('stopwaitsecs')
->min(0)
->defaultValue(60)
->end()
->end()
->end()
->end()
;
} | [
"protected",
"function",
"addGeneralConsumerConfiguration",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"normalizeKeys",
"(",
"false",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"integerNode",
"(",
"'m... | Add consumer configuration
@param ArrayNodeDefinition $node | [
"Add",
"consumer",
"configuration"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/Configuration.php#L115-L163 |
Phobetor/rabbitmq-supervisor-bundle | DependencyInjection/Configuration.php | Configuration.addIndividualConsumerConfiguration | protected function addIndividualConsumerConfiguration(ArrayNodeDefinition $node)
{
$node
->normalizeKeys(false)
->children()
->integerNode('messages')
->min(0)
->defaultNull()
->end()
->integerNode('memory-limit')
->defaultNull()
->end()
->booleanNode('debug')
->defaultNull()
->end()
->booleanNode('without-signals')
->defaultNull()
->end()
->scalarNode('command')
->defaultNull()
->end()
->arrayNode('worker')
->children()
->integerNode('count')
->min(1)
->defaultNull()
->end()
->integerNode('startsecs')
->min(0)
->defaultNull()
->end()
->booleanNode('autorestart')
->defaultNull()
->end()
->enumNode('stopsignal')
->values(array('TERM', 'INT', 'KILL'))
->defaultNull()
->end()
->booleanNode('stopasgroup')
->defaultNull()
->end()
->integerNode('stopwaitsecs')
->min(0)
->defaultNull()
->end()
->end()
->end()
->end()
;
} | php | protected function addIndividualConsumerConfiguration(ArrayNodeDefinition $node)
{
$node
->normalizeKeys(false)
->children()
->integerNode('messages')
->min(0)
->defaultNull()
->end()
->integerNode('memory-limit')
->defaultNull()
->end()
->booleanNode('debug')
->defaultNull()
->end()
->booleanNode('without-signals')
->defaultNull()
->end()
->scalarNode('command')
->defaultNull()
->end()
->arrayNode('worker')
->children()
->integerNode('count')
->min(1)
->defaultNull()
->end()
->integerNode('startsecs')
->min(0)
->defaultNull()
->end()
->booleanNode('autorestart')
->defaultNull()
->end()
->enumNode('stopsignal')
->values(array('TERM', 'INT', 'KILL'))
->defaultNull()
->end()
->booleanNode('stopasgroup')
->defaultNull()
->end()
->integerNode('stopwaitsecs')
->min(0)
->defaultNull()
->end()
->end()
->end()
->end()
;
} | [
"protected",
"function",
"addIndividualConsumerConfiguration",
"(",
"ArrayNodeDefinition",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"normalizeKeys",
"(",
"false",
")",
"->",
"children",
"(",
")",
"->",
"integerNode",
"(",
"'messages'",
")",
"->",
"min",
"(",
... | Add consumer configuration
@param ArrayNodeDefinition $node | [
"Add",
"consumer",
"configuration"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/DependencyInjection/Configuration.php#L170-L219 |
Phobetor/rabbitmq-supervisor-bundle | Services/Supervisor.php | Supervisor.execute | public function execute($cmd, $failOnError = true)
{
$command = $this->createSupervisorControlCommand($cmd);
$this->logger->debug('Executing: ' . $command);
$p = new Process($command);
$p->setWorkingDirectory($this->applicationDirectory);
$p->run();
if ($failOnError) {
if ($p->getExitCode() !== 0) {
$this->logger->critical(sprintf('supervisorctl returns code: %s', $p->getExitCodeText()));
}
$this->logger->debug('supervisorctl output: '. $p->getOutput());
if ($p->getExitCode() !== 0) {
throw new ProcessException($p);
}
}
return $p;
} | php | public function execute($cmd, $failOnError = true)
{
$command = $this->createSupervisorControlCommand($cmd);
$this->logger->debug('Executing: ' . $command);
$p = new Process($command);
$p->setWorkingDirectory($this->applicationDirectory);
$p->run();
if ($failOnError) {
if ($p->getExitCode() !== 0) {
$this->logger->critical(sprintf('supervisorctl returns code: %s', $p->getExitCodeText()));
}
$this->logger->debug('supervisorctl output: '. $p->getOutput());
if ($p->getExitCode() !== 0) {
throw new ProcessException($p);
}
}
return $p;
} | [
"public",
"function",
"execute",
"(",
"$",
"cmd",
",",
"$",
"failOnError",
"=",
"true",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"createSupervisorControlCommand",
"(",
"$",
"cmd",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Ex... | Execute a supervisorctl command
@param $cmd string supervisorctl command
@param $failOnError bool indicate id errors should raise an exception
@return \Symfony\Component\Process\Process | [
"Execute",
"a",
"supervisorctl",
"command"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/Supervisor.php#L63-L82 |
Phobetor/rabbitmq-supervisor-bundle | Services/Supervisor.php | Supervisor.runAndReload | public function runAndReload()
{
// start supervisor and reload configuration
$commands = [];
$commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('reread'));
$commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('update'));
$this->run(implode('', $commands));
} | php | public function runAndReload()
{
// start supervisor and reload configuration
$commands = [];
$commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('reread'));
$commands[] = sprintf(' && %s', $this->createSupervisorControlCommand('update'));
$this->run(implode('', $commands));
} | [
"public",
"function",
"runAndReload",
"(",
")",
"{",
"// start supervisor and reload configuration",
"$",
"commands",
"=",
"[",
"]",
";",
"$",
"commands",
"[",
"]",
"=",
"sprintf",
"(",
"' && %s'",
",",
"$",
"this",
"->",
"createSupervisorControlCommand",
"(",
"... | Update configuration and processes | [
"Update",
"configuration",
"and",
"processes"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/Supervisor.php#L100-L108 |
Phobetor/rabbitmq-supervisor-bundle | Services/Supervisor.php | Supervisor.run | public function run($followingCommand = '')
{
$result = $this->execute('status', false)->getOutput();
if (strpos($result, 'sock no such file') || strpos($result, 'refused connection')) {
$command = sprintf(
'supervisord%1$s%2$s%3$s',
$this->configurationParameter,
$this->identifierParameter,
$followingCommand
);
$this->logger->debug('Executing: ' . $command);
$p = new Process($command);
$p->setWorkingDirectory($this->applicationDirectory);
if (!$this->waitForSupervisord) {
$p->start();
} else {
$p->run();
if ($p->getExitCode() !== 0) {
$this->logger->critical(sprintf('supervisord returns code: %s', $p->getExitCodeText()));
throw new ProcessException($p);
}
$this->logger->debug('supervisord output: '. $p->getOutput());
}
}
} | php | public function run($followingCommand = '')
{
$result = $this->execute('status', false)->getOutput();
if (strpos($result, 'sock no such file') || strpos($result, 'refused connection')) {
$command = sprintf(
'supervisord%1$s%2$s%3$s',
$this->configurationParameter,
$this->identifierParameter,
$followingCommand
);
$this->logger->debug('Executing: ' . $command);
$p = new Process($command);
$p->setWorkingDirectory($this->applicationDirectory);
if (!$this->waitForSupervisord) {
$p->start();
} else {
$p->run();
if ($p->getExitCode() !== 0) {
$this->logger->critical(sprintf('supervisord returns code: %s', $p->getExitCodeText()));
throw new ProcessException($p);
}
$this->logger->debug('supervisord output: '. $p->getOutput());
}
}
} | [
"public",
"function",
"run",
"(",
"$",
"followingCommand",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"execute",
"(",
"'status'",
",",
"false",
")",
"->",
"getOutput",
"(",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"result",
",",
"'... | Start supervisord if not already running
@param $followingCommand string command to execute after supervisord was started | [
"Start",
"supervisord",
"if",
"not",
"already",
"running"
] | train | https://github.com/Phobetor/rabbitmq-supervisor-bundle/blob/2cf73b02b8f2e407e3b02121190d461d083c16d3/Services/Supervisor.php#L115-L139 |
spatie/activitylog | src/Spatie/Activitylog/Handlers/EloquentHandler.php | EloquentHandler.log | public function log($text, $userId = '', $attributes = [])
{
Activity::create(
[
'text' => $text,
'user_id' => ($userId == '' ? null : $userId),
'ip_address' => $attributes['ipAddress'],
]
);
return true;
} | php | public function log($text, $userId = '', $attributes = [])
{
Activity::create(
[
'text' => $text,
'user_id' => ($userId == '' ? null : $userId),
'ip_address' => $attributes['ipAddress'],
]
);
return true;
} | [
"public",
"function",
"log",
"(",
"$",
"text",
",",
"$",
"userId",
"=",
"''",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"Activity",
"::",
"create",
"(",
"[",
"'text'",
"=>",
"$",
"text",
",",
"'user_id'",
"=>",
"(",
"$",
"userId",
"==",
"'... | Log activity in an Eloquent model.
@param string $text
@param $userId
@param array $attributes
@return bool | [
"Log",
"activity",
"in",
"an",
"Eloquent",
"model",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/Handlers/EloquentHandler.php#L19-L30 |
spatie/activitylog | src/Spatie/Activitylog/Handlers/EloquentHandler.php | EloquentHandler.cleanLog | public function cleanLog($maxAgeInMonths)
{
$minimumDate = Carbon::now()->subMonths($maxAgeInMonths);
Activity::where('created_at', '<=', $minimumDate)->delete();
return true;
} | php | public function cleanLog($maxAgeInMonths)
{
$minimumDate = Carbon::now()->subMonths($maxAgeInMonths);
Activity::where('created_at', '<=', $minimumDate)->delete();
return true;
} | [
"public",
"function",
"cleanLog",
"(",
"$",
"maxAgeInMonths",
")",
"{",
"$",
"minimumDate",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"subMonths",
"(",
"$",
"maxAgeInMonths",
")",
";",
"Activity",
"::",
"where",
"(",
"'created_at'",
",",
"'<='",
",",
"... | Clean old log records.
@param int $maxAgeInMonths
@return bool | [
"Clean",
"old",
"log",
"records",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/Handlers/EloquentHandler.php#L39-L45 |
spatie/activitylog | src/Spatie/Activitylog/Handlers/DefaultLaravelHandler.php | DefaultLaravelHandler.log | public function log($text, $userId = '', $attributes = [])
{
$logText = $text;
$logText .= ($userId != '' ? ' (by user_id '.$userId.')' : '');
$logText .= (count($attributes)) ? PHP_EOL.print_r($attributes, true) : '';
Log::info($logText);
return true;
} | php | public function log($text, $userId = '', $attributes = [])
{
$logText = $text;
$logText .= ($userId != '' ? ' (by user_id '.$userId.')' : '');
$logText .= (count($attributes)) ? PHP_EOL.print_r($attributes, true) : '';
Log::info($logText);
return true;
} | [
"public",
"function",
"log",
"(",
"$",
"text",
",",
"$",
"userId",
"=",
"''",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"logText",
"=",
"$",
"text",
";",
"$",
"logText",
".=",
"(",
"$",
"userId",
"!=",
"''",
"?",
"' (by user_id '",
".... | Log activity in Laravels log handler.
@param string $text
@param $userId
@param array $attributes
@return bool | [
"Log",
"activity",
"in",
"Laravels",
"log",
"handler",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/Handlers/DefaultLaravelHandler.php#L18-L27 |
spatie/activitylog | src/Spatie/Activitylog/ActivitylogSupervisor.php | ActivitylogSupervisor.log | public function log($text, $userId = '')
{
$userId = $this->normalizeUserId($userId);
if (! $this->shouldLogCall($text, $userId)) {
return false;
}
$ipAddress = Request::getClientIp();
foreach ($this->logHandlers as $logHandler) {
$logHandler->log($text, $userId, compact('ipAddress'));
}
return true;
} | php | public function log($text, $userId = '')
{
$userId = $this->normalizeUserId($userId);
if (! $this->shouldLogCall($text, $userId)) {
return false;
}
$ipAddress = Request::getClientIp();
foreach ($this->logHandlers as $logHandler) {
$logHandler->log($text, $userId, compact('ipAddress'));
}
return true;
} | [
"public",
"function",
"log",
"(",
"$",
"text",
",",
"$",
"userId",
"=",
"''",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"normalizeUserId",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"shouldLogCall",
"(",
"$",
"text",
... | Log some activity to all registered log handlers.
@param $text
@param string $userId
@return bool | [
"Log",
"some",
"activity",
"to",
"all",
"registered",
"log",
"handlers",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/ActivitylogSupervisor.php#L52-L67 |
spatie/activitylog | src/Spatie/Activitylog/ActivitylogSupervisor.php | ActivitylogSupervisor.cleanLog | public function cleanLog()
{
foreach ($this->logHandlers as $logHandler) {
$logHandler->cleanLog(Config::get('activitylog.deleteRecordsOlderThanMonths'));
}
return true;
} | php | public function cleanLog()
{
foreach ($this->logHandlers as $logHandler) {
$logHandler->cleanLog(Config::get('activitylog.deleteRecordsOlderThanMonths'));
}
return true;
} | [
"public",
"function",
"cleanLog",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"logHandlers",
"as",
"$",
"logHandler",
")",
"{",
"$",
"logHandler",
"->",
"cleanLog",
"(",
"Config",
"::",
"get",
"(",
"'activitylog.deleteRecordsOlderThanMonths'",
")",
")",
... | Clean out old entries in the log.
@return bool | [
"Clean",
"out",
"old",
"entries",
"in",
"the",
"log",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/ActivitylogSupervisor.php#L74-L81 |
spatie/activitylog | src/Spatie/Activitylog/ActivitylogSupervisor.php | ActivitylogSupervisor.normalizeUserId | public function normalizeUserId($userId)
{
if (is_numeric($userId)) {
return $userId;
}
if (is_object($userId)) {
return $userId->id;
}
if ($this->auth->check()) {
return $this->auth->user()->id;
}
if (is_numeric($this->config->get('activitylog.defaultUserId'))) {
return $this->config->get('activitylog.defaultUserId');
};
return '';
} | php | public function normalizeUserId($userId)
{
if (is_numeric($userId)) {
return $userId;
}
if (is_object($userId)) {
return $userId->id;
}
if ($this->auth->check()) {
return $this->auth->user()->id;
}
if (is_numeric($this->config->get('activitylog.defaultUserId'))) {
return $this->config->get('activitylog.defaultUserId');
};
return '';
} | [
"public",
"function",
"normalizeUserId",
"(",
"$",
"userId",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"userId",
")",
")",
"{",
"return",
"$",
"userId",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"userId",
")",
")",
"{",
"return",
"$",
"userId",
... | Normalize the user id.
@param object|int $userId
@return int | [
"Normalize",
"the",
"user",
"id",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/ActivitylogSupervisor.php#L90-L109 |
spatie/activitylog | src/Spatie/Activitylog/ActivitylogSupervisor.php | ActivitylogSupervisor.shouldLogCall | protected function shouldLogCall($text, $userId)
{
$beforeHandler = $this->config->get('activitylog.beforeHandler');
if (is_null($beforeHandler) || $beforeHandler == '') {
return true;
}
return app($beforeHandler)->shouldLog($text, $userId);
} | php | protected function shouldLogCall($text, $userId)
{
$beforeHandler = $this->config->get('activitylog.beforeHandler');
if (is_null($beforeHandler) || $beforeHandler == '') {
return true;
}
return app($beforeHandler)->shouldLog($text, $userId);
} | [
"protected",
"function",
"shouldLogCall",
"(",
"$",
"text",
",",
"$",
"userId",
")",
"{",
"$",
"beforeHandler",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'activitylog.beforeHandler'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"beforeHandler",
")... | Determine if this call should be logged.
@param $text
@param $userId
@return bool | [
"Determine",
"if",
"this",
"call",
"should",
"be",
"logged",
"."
] | train | https://github.com/spatie/activitylog/blob/d333d1a775d2367330363127906295bd6eb3320a/src/Spatie/Activitylog/ActivitylogSupervisor.php#L119-L128 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap/Util/Unit.php | Unit.getFormatted | public function getFormatted()
{
if ($this->getUnit() != "") {
return $this->getValue() . " " . $this->getUnit();
} else {
return (string)$this->getValue();
}
} | php | public function getFormatted()
{
if ($this->getUnit() != "") {
return $this->getValue() . " " . $this->getUnit();
} else {
return (string)$this->getValue();
}
} | [
"public",
"function",
"getFormatted",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getUnit",
"(",
")",
"!=",
"\"\"",
")",
"{",
"return",
"$",
"this",
"->",
"getValue",
"(",
")",
".",
"\" \"",
".",
"$",
"this",
"->",
"getUnit",
"(",
")",
";",
"}"... | Get the value as formatted string with unit.
@return string The value as formatted string with unit.
The unit is not included if it is empty. | [
"Get",
"the",
"value",
"as",
"formatted",
"string",
"with",
"unit",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap/Util/Unit.php#L121-L128 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getWeather | public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '')
{
$answer = $this->getRawWeatherData($query, $units, $lang, $appid, 'xml');
$xml = $this->parseXML($answer);
return new CurrentWeather($xml, $units);
} | php | public function getWeather($query, $units = 'imperial', $lang = 'en', $appid = '')
{
$answer = $this->getRawWeatherData($query, $units, $lang, $appid, 'xml');
$xml = $this->parseXML($answer);
return new CurrentWeather($xml, $units);
} | [
"public",
"function",
"getWeather",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
")",
"{",
"$",
"answer",
"=",
"$",
"this",
"->",
"getRawWeatherData",
"(",
"$",
"query",
",",
... | Returns the current weather at the place you specified.
@param array|int|string $query The place to get weather information for. For possible values see below.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return CurrentWeather The weather object.
There are four ways to specify the place to get weather information for:
- Use the city name: $query must be a string containing the city name.
- Use the city id: $query must be an integer containing the city id.
- Use the coordinates: $query must be an associative array containing the 'lat' and 'lon' values.
- Use the zip code: $query must be a string, prefixed with "zip:"
Zip code may specify country. e.g., "zip:77070" (Houston, TX, US) or "zip:500001,IN" (Hyderabad, India)
@api | [
"Returns",
"the",
"current",
"weather",
"at",
"the",
"place",
"you",
"specified",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L192-L198 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getWeatherGroup | public function getWeatherGroup($ids, $units = 'imperial', $lang = 'en', $appid = '')
{
$answer = $this->getRawWeatherGroupData($ids, $units, $lang, $appid);
$json = $this->parseJson($answer);
return new CurrentWeatherGroup($json, $units);
} | php | public function getWeatherGroup($ids, $units = 'imperial', $lang = 'en', $appid = '')
{
$answer = $this->getRawWeatherGroupData($ids, $units, $lang, $appid);
$json = $this->parseJson($answer);
return new CurrentWeatherGroup($json, $units);
} | [
"public",
"function",
"getWeatherGroup",
"(",
"$",
"ids",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
")",
"{",
"$",
"answer",
"=",
"$",
"this",
"->",
"getRawWeatherGroupData",
"(",
"$",
"ids",
"... | Returns the current weather for a group of city ids.
@param array $ids The city ids to get weather information for
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return CurrentWeatherGroup
@api | [
"Returns",
"the",
"current",
"weather",
"for",
"a",
"group",
"of",
"city",
"ids",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L215-L221 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getWeatherForecast | public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1)
{
if ($days <= 5) {
$answer = $this->getRawHourlyForecastData($query, $units, $lang, $appid, 'xml');
} elseif ($days <= 16) {
$answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days);
} else {
throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be 16 or lower.');
}
$xml = $this->parseXML($answer);
return new WeatherForecast($xml, $units, $days);
} | php | public function getWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1)
{
if ($days <= 5) {
$answer = $this->getRawHourlyForecastData($query, $units, $lang, $appid, 'xml');
} elseif ($days <= 16) {
$answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days);
} else {
throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be 16 or lower.');
}
$xml = $this->parseXML($answer);
return new WeatherForecast($xml, $units, $days);
} | [
"public",
"function",
"getWeatherForecast",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
",",
"$",
"days",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"days",
"<=",
"5",
")",
"{",
... | Returns the forecast for the place you specified. DANGER: Might return
fewer results than requested due to a bug in the OpenWeatherMap API!
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@param int $days For how much days you want to get a forecast. Default 1, maximum: 16.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return WeatherForecast
@api | [
"Returns",
"the",
"forecast",
"for",
"the",
"place",
"you",
"specified",
".",
"DANGER",
":",
"Might",
"return",
"fewer",
"results",
"than",
"requested",
"due",
"to",
"a",
"bug",
"in",
"the",
"OpenWeatherMap",
"API!"
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L240-L252 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getDailyWeatherForecast | public function getDailyWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1)
{
if ($days > 16) {
throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be 16 or lower.');
}
$answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days);
$xml = $this->parseXML($answer);
return new WeatherForecast($xml, $units, $days);
} | php | public function getDailyWeatherForecast($query, $units = 'imperial', $lang = 'en', $appid = '', $days = 1)
{
if ($days > 16) {
throw new \InvalidArgumentException('Error: forecasts are only available for the next 16 days. $days must be 16 or lower.');
}
$answer = $this->getRawDailyForecastData($query, $units, $lang, $appid, 'xml', $days);
$xml = $this->parseXML($answer);
return new WeatherForecast($xml, $units, $days);
} | [
"public",
"function",
"getDailyWeatherForecast",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
",",
"$",
"days",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"days",
">",
"16",
")",
"... | Returns the DAILY forecast for the place you specified. DANGER: Might return
fewer results than requested due to a bug in the OpenWeatherMap API!
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@param int $days For how much days you want to get a forecast. Default 1, maximum: 16.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return WeatherForecast
@api | [
"Returns",
"the",
"DAILY",
"forecast",
"for",
"the",
"place",
"you",
"specified",
".",
"DANGER",
":",
"Might",
"return",
"fewer",
"results",
"than",
"requested",
"due",
"to",
"a",
"bug",
"in",
"the",
"OpenWeatherMap",
"API!"
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L271-L280 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getWeatherHistory | public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '')
{
if (!in_array($type, array('tick', 'hour', 'day'))) {
throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"');
}
$xml = json_decode($this->getRawWeatherHistory($query, $start, $endOrCount, $type, $units, $lang, $appid), true);
if ($xml['cod'] != 200) {
throw new OWMException($xml['message'], $xml['cod']);
}
return new WeatherHistory($xml, $query);
} | php | public function getWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '')
{
if (!in_array($type, array('tick', 'hour', 'day'))) {
throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"');
}
$xml = json_decode($this->getRawWeatherHistory($query, $start, $endOrCount, $type, $units, $lang, $appid), true);
if ($xml['cod'] != 200) {
throw new OWMException($xml['message'], $xml['cod']);
}
return new WeatherHistory($xml, $query);
} | [
"public",
"function",
"getWeatherHistory",
"(",
"$",
"query",
",",
"\\",
"DateTime",
"$",
"start",
",",
"$",
"endOrCount",
"=",
"1",
",",
"$",
"type",
"=",
"'hour'",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appi... | Returns the weather history for the place you specified.
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param \DateTime $start
@param int $endOrCount
@param string $type Can either be 'tick', 'hour' or 'day'.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return WeatherHistory
@api | [
"Returns",
"the",
"weather",
"history",
"for",
"the",
"place",
"you",
"specified",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L300-L313 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getCurrentUVIndex | public function getCurrentUVIndex($lat, $lon)
{
$answer = $this->getRawCurrentUVIndexData($lat, $lon);
$json = $this->parseJson($answer);
return new UVIndex($json);
} | php | public function getCurrentUVIndex($lat, $lon)
{
$answer = $this->getRawCurrentUVIndexData($lat, $lon);
$json = $this->parseJson($answer);
return new UVIndex($json);
} | [
"public",
"function",
"getCurrentUVIndex",
"(",
"$",
"lat",
",",
"$",
"lon",
")",
"{",
"$",
"answer",
"=",
"$",
"this",
"->",
"getRawCurrentUVIndexData",
"(",
"$",
"lat",
",",
"$",
"lon",
")",
";",
"$",
"json",
"=",
"$",
"this",
"->",
"parseJson",
"(... | Returns the current uv index at the location you specified.
@param float $lat The location's latitude.
@param float $lon The location's longitude.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return UVIndex The uvi object.
@api | [
"Returns",
"the",
"current",
"uv",
"index",
"at",
"the",
"location",
"you",
"specified",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L328-L334 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getUVIndex | public function getUVIndex($lat, $lon, $dateTime, $timePrecision = 'day')
{
$answer = $this->getRawUVIndexData($lat, $lon, $dateTime, $timePrecision);
$json = $this->parseJson($answer);
return new UVIndex($json);
} | php | public function getUVIndex($lat, $lon, $dateTime, $timePrecision = 'day')
{
$answer = $this->getRawUVIndexData($lat, $lon, $dateTime, $timePrecision);
$json = $this->parseJson($answer);
return new UVIndex($json);
} | [
"public",
"function",
"getUVIndex",
"(",
"$",
"lat",
",",
"$",
"lon",
",",
"$",
"dateTime",
",",
"$",
"timePrecision",
"=",
"'day'",
")",
"{",
"$",
"answer",
"=",
"$",
"this",
"->",
"getRawUVIndexData",
"(",
"$",
"lat",
",",
"$",
"lon",
",",
"$",
"... | Returns the uv index at date, time and location you specified.
@param float $lat The location's latitude.
@param float $lon The location's longitude.
@param \DateTimeInterface $dateTime The date and time to request data for.
@param string $timePrecision This decides about the timespan OWM will look for the uv index. The tighter
the timespan, the less likely it is to get a result. Can be 'year', 'month',
'day', 'hour', 'minute' or 'second', defaults to 'day'.
@throws OpenWeatherMap\Exception If OpenWeatherMap returns an error.
@throws \InvalidArgumentException If an argument error occurs.
@return UVIndex The uvi object.
@api | [
"Returns",
"the",
"uv",
"index",
"at",
"date",
"time",
"and",
"location",
"you",
"specified",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L353-L359 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawWeatherData | public function getRawWeatherData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml')
{
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherUrl);
return $this->cacheOrFetchResult($url);
} | php | public function getRawWeatherData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml')
{
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherUrl);
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawWeatherData",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
",",
"$",
"mode",
"=",
"'xml'",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl... | Directly returns the xml/json/html string returned by OpenWeatherMap for the current weather.
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
@return string Returns false on failure and the fetched data in the format you specified on success.
Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data.
@api | [
"Directly",
"returns",
"the",
"xml",
"/",
"json",
"/",
"html",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"current",
"weather",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L376-L381 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawWeatherGroupData | public function getRawWeatherGroupData($ids, $units = 'imperial', $lang = 'en', $appid = '')
{
$url = $this->buildUrl($ids, $units, $lang, $appid, 'json', $this->weatherGroupUrl);
return $this->cacheOrFetchResult($url);
} | php | public function getRawWeatherGroupData($ids, $units = 'imperial', $lang = 'en', $appid = '')
{
$url = $this->buildUrl($ids, $units, $lang, $appid, 'json', $this->weatherGroupUrl);
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawWeatherGroupData",
"(",
"$",
"ids",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"buildUrl",
"(",
"$",
"ids",
",",
"$",... | Directly returns the JSON string returned by OpenWeatherMap for the group of current weather.
Only a JSON response format is supported for this webservice.
@param array $ids The city ids to get weather information for
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@return string Returns false on failure and the fetched data in the format you specified on success.
@api | [
"Directly",
"returns",
"the",
"JSON",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"group",
"of",
"current",
"weather",
".",
"Only",
"a",
"JSON",
"response",
"format",
"is",
"supported",
"for",
"this",
"webservice",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L396-L401 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawHourlyForecastData | public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml')
{
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherHourlyForecastUrl);
return $this->cacheOrFetchResult($url);
} | php | public function getRawHourlyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml')
{
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherHourlyForecastUrl);
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawHourlyForecastData",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
",",
"$",
"mode",
"=",
"'xml'",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"b... | Directly returns the xml/json/html string returned by OpenWeatherMap for the hourly forecast.
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default).
@return string Returns false on failure and the fetched data in the format you specified on success.
Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data.
@api | [
"Directly",
"returns",
"the",
"xml",
"/",
"json",
"/",
"html",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"hourly",
"forecast",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L418-L423 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawDailyForecastData | public function getRawDailyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml', $cnt = 16)
{
if ($cnt > 16) {
throw new \InvalidArgumentException('$cnt must be 16 or lower!');
}
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherDailyForecastUrl) . "&cnt=$cnt";
return $this->cacheOrFetchResult($url);
} | php | public function getRawDailyForecastData($query, $units = 'imperial', $lang = 'en', $appid = '', $mode = 'xml', $cnt = 16)
{
if ($cnt > 16) {
throw new \InvalidArgumentException('$cnt must be 16 or lower!');
}
$url = $this->buildUrl($query, $units, $lang, $appid, $mode, $this->weatherDailyForecastUrl) . "&cnt=$cnt";
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawDailyForecastData",
"(",
"$",
"query",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"appid",
"=",
"''",
",",
"$",
"mode",
"=",
"'xml'",
",",
"$",
"cnt",
"=",
"16",
")",
"{",
"if",
"(",
... | Directly returns the xml/json/html string returned by OpenWeatherMap for the daily forecast.
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@param string $mode The format of the data fetched. Possible values are 'json', 'html' and 'xml' (default)
@param int $cnt How many days of forecast shall be returned? Maximum (and default): 16
@throws \InvalidArgumentException If $cnt is higher than 16.
@return string Returns false on failure and the fetched data in the format you specified on success.
Warning: If an error occurs, OpenWeatherMap ALWAYS returns json data.
@api | [
"Directly",
"returns",
"the",
"xml",
"/",
"json",
"/",
"html",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"daily",
"forecast",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L443-L451 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawWeatherHistory | public function getRawWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '')
{
if (!in_array($type, array('tick', 'hour', 'day'))) {
throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"');
}
$url = $this->buildUrl($query, $units, $lang, $appid, 'json', $this->weatherHistoryUrl);
$url .= "&type=$type&start={$start->format('U')}";
if ($endOrCount instanceof \DateTime) {
$url .= "&end={$endOrCount->format('U')}";
} elseif (is_numeric($endOrCount) && $endOrCount > 0) {
$url .= "&cnt=$endOrCount";
} else {
throw new \InvalidArgumentException('$endOrCount must be either a \DateTime or a positive integer.');
}
return $this->cacheOrFetchResult($url);
} | php | public function getRawWeatherHistory($query, \DateTime $start, $endOrCount = 1, $type = 'hour', $units = 'imperial', $lang = 'en', $appid = '')
{
if (!in_array($type, array('tick', 'hour', 'day'))) {
throw new \InvalidArgumentException('$type must be either "tick", "hour" or "day"');
}
$url = $this->buildUrl($query, $units, $lang, $appid, 'json', $this->weatherHistoryUrl);
$url .= "&type=$type&start={$start->format('U')}";
if ($endOrCount instanceof \DateTime) {
$url .= "&end={$endOrCount->format('U')}";
} elseif (is_numeric($endOrCount) && $endOrCount > 0) {
$url .= "&cnt=$endOrCount";
} else {
throw new \InvalidArgumentException('$endOrCount must be either a \DateTime or a positive integer.');
}
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawWeatherHistory",
"(",
"$",
"query",
",",
"\\",
"DateTime",
"$",
"start",
",",
"$",
"endOrCount",
"=",
"1",
",",
"$",
"type",
"=",
"'hour'",
",",
"$",
"units",
"=",
"'imperial'",
",",
"$",
"lang",
"=",
"'en'",
",",
"$",
"a... | Directly returns the json string returned by OpenWeatherMap for the weather history.
@param array|int|string $query The place to get weather information for. For possible values see ::getWeather.
@param \DateTime $start The \DateTime object of the date to get the first weather information from.
@param \DateTime|int $endOrCount Can be either a \DateTime object representing the end of the period to
receive weather history data for or an integer counting the number of
reports requested.
@param string $type The period of the weather history requested. Can be either be either "tick",
"hour" or "day".
@param string $units Can be either 'metric' or 'imperial' (default). This affects almost all units returned.
@param string $lang The language to use for descriptions, default is 'en'. For possible values see http://openweathermap.org/current#multi.
@param string $appid Your app id, default ''. See http://openweathermap.org/appid for more details.
@throws \InvalidArgumentException
@return string Returns false on failure and the fetched data in the format you specified on success.
Warning If an error occurred, OpenWeatherMap ALWAYS returns data in json format.
@api | [
"Directly",
"returns",
"the",
"json",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"weather",
"history",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L475-L492 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawCurrentUVIndexData | public function getRawCurrentUVIndexData($lat, $lon)
{
if (!$this->apiKey) {
throw new \RuntimeException('Before using this method, you must set the api key using ->setApiKey()');
}
if (!is_float($lat) || !is_float($lon)) {
throw new \InvalidArgumentException('$lat and $lon must be floating point numbers');
}
$url = $this->buildUVIndexUrl($lat, $lon);
return $this->cacheOrFetchResult($url);
} | php | public function getRawCurrentUVIndexData($lat, $lon)
{
if (!$this->apiKey) {
throw new \RuntimeException('Before using this method, you must set the api key using ->setApiKey()');
}
if (!is_float($lat) || !is_float($lon)) {
throw new \InvalidArgumentException('$lat and $lon must be floating point numbers');
}
$url = $this->buildUVIndexUrl($lat, $lon);
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawCurrentUVIndexData",
"(",
"$",
"lat",
",",
"$",
"lon",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"apiKey",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Before using this method, you must set the api key using ->setApiKey... | Directly returns the json string returned by OpenWeatherMap for the current UV index data.
@param float $lat The location's latitude.
@param float $lon The location's longitude.
@return bool|string Returns the fetched data.
@api | [
"Directly",
"returns",
"the",
"json",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"current",
"UV",
"index",
"data",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L504-L515 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.getRawUVIndexData | public function getRawUVIndexData($lat, $lon, $dateTime, $timePrecision = 'day')
{
if (!$this->apiKey) {
throw new \RuntimeException('Before using this method, you must set the api key using ->setApiKey()');
}
if (!is_float($lat) || !is_float($lon)) {
throw new \InvalidArgumentException('$lat and $lon must be floating point numbers');
}
if (interface_exists('DateTimeInterface') && !$dateTime instanceof \DateTimeInterface || !$dateTime instanceof \DateTime) {
throw new \InvalidArgumentException('$dateTime must be an instance of \DateTime or \DateTimeInterface');
}
$url = $this->buildUVIndexUrl($lat, $lon, $dateTime, $timePrecision);
return $this->cacheOrFetchResult($url);
} | php | public function getRawUVIndexData($lat, $lon, $dateTime, $timePrecision = 'day')
{
if (!$this->apiKey) {
throw new \RuntimeException('Before using this method, you must set the api key using ->setApiKey()');
}
if (!is_float($lat) || !is_float($lon)) {
throw new \InvalidArgumentException('$lat and $lon must be floating point numbers');
}
if (interface_exists('DateTimeInterface') && !$dateTime instanceof \DateTimeInterface || !$dateTime instanceof \DateTime) {
throw new \InvalidArgumentException('$dateTime must be an instance of \DateTime or \DateTimeInterface');
}
$url = $this->buildUVIndexUrl($lat, $lon, $dateTime, $timePrecision);
return $this->cacheOrFetchResult($url);
} | [
"public",
"function",
"getRawUVIndexData",
"(",
"$",
"lat",
",",
"$",
"lon",
",",
"$",
"dateTime",
",",
"$",
"timePrecision",
"=",
"'day'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"apiKey",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
... | Directly returns the json string returned by OpenWeatherMap for the UV index data.
@param float $lat The location's latitude.
@param float $lon The location's longitude.
@param \DateTimeInterface $dateTime The date and time to request data for.
@param string $timePrecision This decides about the timespan OWM will look for the uv index. The tighter
the timespan, the less likely it is to get a result. Can be 'year', 'month',
'day', 'hour', 'minute' or 'second', defaults to 'day'.
@return bool|string Returns the fetched data.
@api | [
"Directly",
"returns",
"the",
"json",
"string",
"returned",
"by",
"OpenWeatherMap",
"for",
"the",
"UV",
"index",
"data",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L531-L545 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.cacheOrFetchResult | private function cacheOrFetchResult($url)
{
if ($this->cache !== false) {
/** @var AbstractCache $cache */
$cache = $this->cache;
$cache->setSeconds($this->seconds);
if ($cache->isCached($url)) {
$this->wasCached = true;
return $cache->getCached($url);
}
$result = $this->fetcher->fetch($url);
$cache->setCached($url, $result);
} else {
$result = $this->fetcher->fetch($url);
}
$this->wasCached = false;
return $result;
} | php | private function cacheOrFetchResult($url)
{
if ($this->cache !== false) {
/** @var AbstractCache $cache */
$cache = $this->cache;
$cache->setSeconds($this->seconds);
if ($cache->isCached($url)) {
$this->wasCached = true;
return $cache->getCached($url);
}
$result = $this->fetcher->fetch($url);
$cache->setCached($url, $result);
} else {
$result = $this->fetcher->fetch($url);
}
$this->wasCached = false;
return $result;
} | [
"private",
"function",
"cacheOrFetchResult",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"!==",
"false",
")",
"{",
"/** @var AbstractCache $cache */",
"$",
"cache",
"=",
"$",
"this",
"->",
"cache",
";",
"$",
"cache",
"->",
"setSeconds... | Fetches the result or delivers a cached version of the result.
@param string $url
@return string | [
"Fetches",
"the",
"result",
"or",
"delivers",
"a",
"cached",
"version",
"of",
"the",
"result",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L572-L590 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.buildUrl | private function buildUrl($query, $units, $lang, $appid, $mode, $url)
{
$queryUrl = $this->buildQueryUrlParameter($query);
$url = $url."$queryUrl&units=$units&lang=$lang&mode=$mode&APPID=";
$url .= empty($appid) ? $this->apiKey : $appid;
return $url;
} | php | private function buildUrl($query, $units, $lang, $appid, $mode, $url)
{
$queryUrl = $this->buildQueryUrlParameter($query);
$url = $url."$queryUrl&units=$units&lang=$lang&mode=$mode&APPID=";
$url .= empty($appid) ? $this->apiKey : $appid;
return $url;
} | [
"private",
"function",
"buildUrl",
"(",
"$",
"query",
",",
"$",
"units",
",",
"$",
"lang",
",",
"$",
"appid",
",",
"$",
"mode",
",",
"$",
"url",
")",
"{",
"$",
"queryUrl",
"=",
"$",
"this",
"->",
"buildQueryUrlParameter",
"(",
"$",
"query",
")",
";... | Build the url to fetch weather data from.
@param $query
@param $units
@param $lang
@param $appid
@param $mode
@param string $url The url to prepend.
@return bool|string The fetched url, false on failure. | [
"Build",
"the",
"url",
"to",
"fetch",
"weather",
"data",
"from",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L604-L612 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.buildUVIndexUrl | private function buildUVIndexUrl($lat, $lon, $dateTime = null, $timePrecision = null)
{
if ($dateTime !== null) {
$format = '\Z';
switch ($timePrecision) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'second':
$format = ':s' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'minute':
$format = ':i' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'hour':
$format = '\TH' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'day':
$format = '-d' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'month':
$format = '-m' . $format;
case 'year':
$format = 'Y' . $format;
break;
default:
throw new \InvalidArgumentException('$timePrecision is invalid.');
}
// OWM only accepts UTC timezones.
$dateTime->setTimezone(new \DateTimeZone('UTC'));
$dateTime = $dateTime->format($format);
} else {
$dateTime = 'current';
}
return sprintf($this->uvIndexUrl . '/%s,%s/%s.json?appid=%s', $lat, $lon, $dateTime, $this->apiKey);
} | php | private function buildUVIndexUrl($lat, $lon, $dateTime = null, $timePrecision = null)
{
if ($dateTime !== null) {
$format = '\Z';
switch ($timePrecision) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'second':
$format = ':s' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'minute':
$format = ':i' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'hour':
$format = '\TH' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'day':
$format = '-d' . $format;
/** @noinspection PhpMissingBreakStatementInspection */
case 'month':
$format = '-m' . $format;
case 'year':
$format = 'Y' . $format;
break;
default:
throw new \InvalidArgumentException('$timePrecision is invalid.');
}
// OWM only accepts UTC timezones.
$dateTime->setTimezone(new \DateTimeZone('UTC'));
$dateTime = $dateTime->format($format);
} else {
$dateTime = 'current';
}
return sprintf($this->uvIndexUrl . '/%s,%s/%s.json?appid=%s', $lat, $lon, $dateTime, $this->apiKey);
} | [
"private",
"function",
"buildUVIndexUrl",
"(",
"$",
"lat",
",",
"$",
"lon",
",",
"$",
"dateTime",
"=",
"null",
",",
"$",
"timePrecision",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dateTime",
"!==",
"null",
")",
"{",
"$",
"format",
"=",
"'\\Z'",
";",
... | @param float $lat
@param float $lon
@param \DateTime|\DateTimeImmutable $dateTime
@param string $timePrecision
@return string | [
"@param",
"float",
"$lat",
"@param",
"float",
"$lon",
"@param",
"\\",
"DateTime|",
"\\",
"DateTimeImmutable",
"$dateTime",
"@param",
"string",
"$timePrecision"
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L622-L656 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.buildQueryUrlParameter | private function buildQueryUrlParameter($query)
{
switch ($query) {
case is_array($query) && isset($query['lat']) && isset($query['lon']) && is_numeric($query['lat']) && is_numeric($query['lon']):
return "lat={$query['lat']}&lon={$query['lon']}";
case is_array($query) && is_numeric($query[0]):
return 'id='.implode(',', $query);
case is_numeric($query):
return "id=$query";
case is_string($query) && strpos($query, 'zip:') === 0:
$subQuery = str_replace('zip:', '', $query);
return 'zip='.urlencode($subQuery);
case is_string($query):
return 'q='.urlencode($query);
default:
throw new \InvalidArgumentException('Error: $query has the wrong format. See the documentation of OpenWeatherMap::getWeather() to read about valid formats.');
}
} | php | private function buildQueryUrlParameter($query)
{
switch ($query) {
case is_array($query) && isset($query['lat']) && isset($query['lon']) && is_numeric($query['lat']) && is_numeric($query['lon']):
return "lat={$query['lat']}&lon={$query['lon']}";
case is_array($query) && is_numeric($query[0]):
return 'id='.implode(',', $query);
case is_numeric($query):
return "id=$query";
case is_string($query) && strpos($query, 'zip:') === 0:
$subQuery = str_replace('zip:', '', $query);
return 'zip='.urlencode($subQuery);
case is_string($query):
return 'q='.urlencode($query);
default:
throw new \InvalidArgumentException('Error: $query has the wrong format. See the documentation of OpenWeatherMap::getWeather() to read about valid formats.');
}
} | [
"private",
"function",
"buildQueryUrlParameter",
"(",
"$",
"query",
")",
"{",
"switch",
"(",
"$",
"query",
")",
"{",
"case",
"is_array",
"(",
"$",
"query",
")",
"&&",
"isset",
"(",
"$",
"query",
"[",
"'lat'",
"]",
")",
"&&",
"isset",
"(",
"$",
"query... | Builds the query string for the url.
@param mixed $query
@return string The built query string for the url.
@throws \InvalidArgumentException If the query parameter is invalid. | [
"Builds",
"the",
"query",
"string",
"for",
"the",
"url",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L667-L684 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.parseXML | private function parseXML($answer)
{
// Disable default error handling of SimpleXML (Do not throw E_WARNINGs).
libxml_use_internal_errors(true);
libxml_clear_errors();
try {
return new \SimpleXMLElement($answer);
} catch (\Exception $e) {
// Invalid xml format. This happens in case OpenWeatherMap returns an error.
// OpenWeatherMap always uses json for errors, even if one specifies xml as format.
$error = json_decode($answer, true);
if (isset($error['message'])) {
throw new OWMException($error['message'], isset($error['cod']) ? $error['cod'] : 0);
} else {
throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer);
}
}
} | php | private function parseXML($answer)
{
// Disable default error handling of SimpleXML (Do not throw E_WARNINGs).
libxml_use_internal_errors(true);
libxml_clear_errors();
try {
return new \SimpleXMLElement($answer);
} catch (\Exception $e) {
// Invalid xml format. This happens in case OpenWeatherMap returns an error.
// OpenWeatherMap always uses json for errors, even if one specifies xml as format.
$error = json_decode($answer, true);
if (isset($error['message'])) {
throw new OWMException($error['message'], isset($error['cod']) ? $error['cod'] : 0);
} else {
throw new OWMException('Unknown fatal error: OpenWeatherMap returned the following json object: ' . $answer);
}
}
} | [
"private",
"function",
"parseXML",
"(",
"$",
"answer",
")",
"{",
"// Disable default error handling of SimpleXML (Do not throw E_WARNINGs).",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"libxml_clear_errors",
"(",
")",
";",
"try",
"{",
"return",
"new",
"\\",
"S... | @param string $answer The content returned by OpenWeatherMap.
@return \SimpleXMLElement
@throws OWMException If the content isn't valid XML. | [
"@param",
"string",
"$answer",
"The",
"content",
"returned",
"by",
"OpenWeatherMap",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L692-L709 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap.php | OpenWeatherMap.parseJson | private function parseJson($answer)
{
$json = json_decode($answer);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new OWMException('OpenWeatherMap returned an invalid json object. JSON error was: ' . $this->json_last_error_msg());
}
if (isset($json->message)) {
throw new OWMException('An error occurred: '. $json->message);
}
return $json;
} | php | private function parseJson($answer)
{
$json = json_decode($answer);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new OWMException('OpenWeatherMap returned an invalid json object. JSON error was: ' . $this->json_last_error_msg());
}
if (isset($json->message)) {
throw new OWMException('An error occurred: '. $json->message);
}
return $json;
} | [
"private",
"function",
"parseJson",
"(",
"$",
"answer",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"answer",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"throw",
"new",
"OWMException",
"(",
"'OpenWeatherM... | @param string $answer The content returned by OpenWeatherMap.
@return \stdClass
@throws OWMException If the content isn't valid JSON. | [
"@param",
"string",
"$answer",
"The",
"content",
"returned",
"by",
"OpenWeatherMap",
"."
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap.php#L717-L728 |
cmfcmf/OpenWeatherMap-PHP-Api | Cmfcmf/OpenWeatherMap/Fetcher/CurlFetcher.php | CurlFetcher.fetch | public function fetch($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt_array($ch, $this->curlOptions);
$content = curl_exec($ch);
curl_close($ch);
return $content;
} | php | public function fetch($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt_array($ch, $this->curlOptions);
$content = curl_exec($ch);
curl_close($ch);
return $content;
} | [
"public",
"function",
"fetch",
"(",
"$",
"url",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFE... | {@inheritdoc} | [
"{"
] | train | https://github.com/cmfcmf/OpenWeatherMap-PHP-Api/blob/a1fe20bab717116c75557cc9c16120cb6af5ee48/Cmfcmf/OpenWeatherMap/Fetcher/CurlFetcher.php#L46-L58 |
lisachenko/protocol-fcgi | src/FCGI/Record.php | Record.unpack | final public static function unpack(string $data): self
{
$self = new static();
[
$self->version,
$self->type,
$self->requestId,
$self->contentLength,
$self->paddingLength,
$self->reserved
] = array_values(unpack(FCGI::HEADER_FORMAT, $data));
$payload = substr($data, FCGI::HEADER_LEN);
self::unpackPayload($self, $payload);
if (get_called_class() !== __CLASS__ && $self->contentLength > 0) {
static::unpackPayload($self, $payload);
}
return $self;
} | php | final public static function unpack(string $data): self
{
$self = new static();
[
$self->version,
$self->type,
$self->requestId,
$self->contentLength,
$self->paddingLength,
$self->reserved
] = array_values(unpack(FCGI::HEADER_FORMAT, $data));
$payload = substr($data, FCGI::HEADER_LEN);
self::unpackPayload($self, $payload);
if (get_called_class() !== __CLASS__ && $self->contentLength > 0) {
static::unpackPayload($self, $payload);
}
return $self;
} | [
"final",
"public",
"static",
"function",
"unpack",
"(",
"string",
"$",
"data",
")",
":",
"self",
"{",
"$",
"self",
"=",
"new",
"static",
"(",
")",
";",
"[",
"$",
"self",
"->",
"version",
",",
"$",
"self",
"->",
"type",
",",
"$",
"self",
"->",
"re... | Unpacks the message from the binary data buffer
@param string $data Binary buffer with raw data
@return static | [
"Unpacks",
"the",
"message",
"from",
"the",
"binary",
"data",
"buffer"
] | train | https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record.php#L78-L97 |
lisachenko/protocol-fcgi | src/FCGI/Record.php | Record.setContentData | public function setContentData(string $data): self
{
$this->contentData = $data;
$this->contentLength = strlen($this->contentData);
$extraLength = $this->contentLength % 8;
$this->paddingLength = $extraLength ? (8 - $extraLength) : 0;
return $this;
} | php | public function setContentData(string $data): self
{
$this->contentData = $data;
$this->contentLength = strlen($this->contentData);
$extraLength = $this->contentLength % 8;
$this->paddingLength = $extraLength ? (8 - $extraLength) : 0;
return $this;
} | [
"public",
"function",
"setContentData",
"(",
"string",
"$",
"data",
")",
":",
"self",
"{",
"$",
"this",
"->",
"contentData",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"contentLength",
"=",
"strlen",
"(",
"$",
"this",
"->",
"contentData",
")",
";",
"$",... | Sets the content data and adjusts the length fields
@param string $data
@return static | [
"Sets",
"the",
"content",
"data",
"and",
"adjusts",
"the",
"length",
"fields"
] | train | https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record.php#L127-L134 |
lisachenko/protocol-fcgi | src/FCGI/Record.php | Record.unpackPayload | protected static function unpackPayload($self, string $data): void
{
[
$self->contentData,
$self->paddingData
] = array_values(
unpack("a{$self->contentLength}contentData/a{$self->paddingLength}paddingData", $data)
);
} | php | protected static function unpackPayload($self, string $data): void
{
[
$self->contentData,
$self->paddingData
] = array_values(
unpack("a{$self->contentLength}contentData/a{$self->paddingLength}paddingData", $data)
);
} | [
"protected",
"static",
"function",
"unpackPayload",
"(",
"$",
"self",
",",
"string",
"$",
"data",
")",
":",
"void",
"{",
"[",
"$",
"self",
"->",
"contentData",
",",
"$",
"self",
"->",
"paddingData",
"]",
"=",
"array_values",
"(",
"unpack",
"(",
"\"a{$sel... | Method to unpack the payload for the record.
NB: Default implementation will be always called
@param static $self Instance of current frame
@param string $data Binary data | [
"Method",
"to",
"unpack",
"the",
"payload",
"for",
"the",
"record",
"."
] | train | https://github.com/lisachenko/protocol-fcgi/blob/ffd0ccfcd6a9efc05caa74b2b593c178bc3f8e74/src/FCGI/Record.php#L208-L216 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.