ArgumentNode.php
2 months ago
BooleanValueNode.php
2 months ago
DefinitionNode.php
2 months ago
DirectiveDefinitionNode.php
2 months ago
DirectiveNode.php
2 months ago
DocumentNode.php
2 months ago
EnumTypeDefinitionNode.php
2 months ago
EnumTypeExtensionNode.php
2 months ago
EnumValueDefinitionNode.php
2 months ago
EnumValueNode.php
2 months ago
ExecutableDefinitionNode.php
2 months ago
FieldDefinitionNode.php
2 months ago
FieldNode.php
2 months ago
FloatValueNode.php
2 months ago
FragmentDefinitionNode.php
2 months ago
FragmentSpreadNode.php
2 months ago
HasSelectionSet.php
2 months ago
InlineFragmentNode.php
2 months ago
InputObjectTypeDefinitionNode.php
2 months ago
InputObjectTypeExtensionNode.php
2 months ago
InputValueDefinitionNode.php
2 months ago
IntValueNode.php
2 months ago
InterfaceTypeDefinitionNode.php
2 months ago
InterfaceTypeExtensionNode.php
2 months ago
ListTypeNode.php
2 months ago
ListValueNode.php
2 months ago
Location.php
2 months ago
NameNode.php
2 months ago
NamedTypeNode.php
2 months ago
Node.php
2 months ago
NodeKind.php
2 months ago
NodeList.php
2 months ago
NonNullTypeNode.php
2 months ago
NullValueNode.php
2 months ago
ObjectFieldNode.php
2 months ago
ObjectTypeDefinitionNode.php
2 months ago
ObjectTypeExtensionNode.php
2 months ago
ObjectValueNode.php
2 months ago
OperationDefinitionNode.php
2 months ago
OperationTypeDefinitionNode.php
2 months ago
ScalarTypeDefinitionNode.php
2 months ago
ScalarTypeExtensionNode.php
2 months ago
SchemaDefinitionNode.php
2 months ago
SchemaExtensionNode.php
2 months ago
SelectionNode.php
2 months ago
SelectionSetNode.php
2 months ago
StringValueNode.php
2 months ago
TypeDefinitionNode.php
2 months ago
TypeExtensionNode.php
2 months ago
TypeNode.php
2 months ago
TypeSystemDefinitionNode.php
2 months ago
TypeSystemExtensionNode.php
2 months ago
UnionTypeDefinitionNode.php
2 months ago
UnionTypeExtensionNode.php
2 months ago
ValueNode.php
2 months ago
VariableDefinitionNode.php
2 months ago
VariableNode.php
2 months ago
Location.php
64 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Vendor\GraphQL\Language\AST; |
| 4 | |
| 5 | use Automattic\WooCommerce\Vendor\GraphQL\Language\Source; |
| 6 | use Automattic\WooCommerce\Vendor\GraphQL\Language\Token; |
| 7 | |
| 8 | /** |
| 9 | * Contains a range of UTF-8 character offsets and token references that |
| 10 | * identify the region of the source from which the AST derived. |
| 11 | * |
| 12 | * @phpstan-type LocationArray array{start: int, end: int} |
| 13 | */ |
| 14 | class Location |
| 15 | { |
| 16 | /** The character offset at which this Node begins. */ |
| 17 | public int $start; |
| 18 | |
| 19 | /** The character offset at which this Node ends. */ |
| 20 | public int $end; |
| 21 | |
| 22 | /** The Token at which this Node begins. */ |
| 23 | public ?Token $startToken = null; |
| 24 | |
| 25 | /** The Token at which this Node ends. */ |
| 26 | public ?Token $endToken = null; |
| 27 | |
| 28 | /** The Source document the AST represents. */ |
| 29 | public ?Source $source = null; |
| 30 | |
| 31 | public static function create(int $start, int $end): self |
| 32 | { |
| 33 | $tmp = new static(); |
| 34 | |
| 35 | $tmp->start = $start; |
| 36 | $tmp->end = $end; |
| 37 | |
| 38 | return $tmp; |
| 39 | } |
| 40 | |
| 41 | public function __construct(?Token $startToken = null, ?Token $endToken = null, ?Source $source = null) |
| 42 | { |
| 43 | $this->startToken = $startToken; |
| 44 | $this->endToken = $endToken; |
| 45 | $this->source = $source; |
| 46 | |
| 47 | if ($startToken === null || $endToken === null) { |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | $this->start = $startToken->start; |
| 52 | $this->end = $endToken->end; |
| 53 | } |
| 54 | |
| 55 | /** @return LocationArray */ |
| 56 | public function toArray(): array |
| 57 | { |
| 58 | return [ |
| 59 | 'start' => $this->start, |
| 60 | 'end' => $this->end, |
| 61 | ]; |
| 62 | } |
| 63 | } |
| 64 |