OverlappingFieldsCanBeMerged
extends ValidationRule
in package
ReasonOrReasons is recursive, but PHPStan does not support that.
Tags
Table of Contents
- $cachedFieldsAndFragmentNames : SplObjectStorage
- A cache for the "field map" and list of fragment names found in any given selection set. Selection sets may be asked for this information multiple times, so this improves the performance of this validator.
- $comparedFragmentPairs : PairSet
- A memoization for when two fragments are compared "between" each other for conflicts. Two fragments may be compared many times, so memoizing this can dramatically improve the performance of this validator.
- $name : string
- fieldsConflictMessage() : string
- getName() : string
- getSDLVisitor() : array<string|int, mixed>
- Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
- getVisitor() : array<string|int, mixed>
- Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
- reasonMessage() : string
- collectConflictsBetween() : void
- 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.
- collectConflictsBetweenFieldsAndFragment() : void
- Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments.
- collectConflictsBetweenFragments() : void
- Collect all conflicts found between two fragments, including via spreading in any nested fragments.
- collectConflictsWithin() : void
- Collect all Conflicts "within" one collection of fields.
- deduplicateFields() : array<string|int, mixed>
- doTypesConflict() : bool
- Two types conflict if both types could not apply to a value simultaneously.
- fieldFingerprint() : string
- findConflict() : array<string|int, mixed>|null
- Determines if there is a conflict between two particular fields, including comparing their sub-fields.
- findConflictsBetweenSubSelectionSets() : array<int, Conflict>
- 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.
- findConflictsWithinSelectionSet() : array<string|int, mixed>
- Find all conflicts found "within" a selection set, including those found via spreading in fragments. Called when visiting each SelectionSet in the Automattic\WooCommerce\Vendor\GraphQL Document.
-
getFieldsAndFragmentNames()
: array{: \Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules\FieldMap, : array
} - Given a selection set, return the collection of fields (a mapping of response name to field ASTs and definitions) as well as a list of fragment names referenced via fragment spreads.
- getReferencedFieldsAndFragmentNames() : array<string|int, mixed>
- 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.
- internalCollectFieldsAndFragmentNames() : void
- 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.
- sameArguments() : bool
- sameValue() : bool
- subfieldConflicts() : array<string|int, mixed>|null
- Merge Conflicts between two sub-fields into a single Conflict.
Properties
$cachedFieldsAndFragmentNames
A cache for the "field map" and list of fragment names found in any given selection set. Selection sets may be asked for this information multiple times, so this improves the performance of this validator.
protected
SplObjectStorage
$cachedFieldsAndFragmentNames
Tags
$comparedFragmentPairs
A memoization for when two fragments are compared "between" each other for conflicts. Two fragments may be compared many times, so memoizing this can dramatically improve the performance of this validator.
protected
PairSet
$comparedFragmentPairs
$name
protected
string
$name
Methods
fieldsConflictMessage()
public
static fieldsConflictMessage(string $responseName, string|array<string|int, mixed> $reasonOrReasons) : string
Parameters
- $responseName : string
- $reasonOrReasons : string|array<string|int, mixed>
Tags
Return values
string —getName()
public
getName() : string
Return values
string —getSDLVisitor()
Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
public
getSDLVisitor(SDLValidationContext $context) : array<string|int, mixed>
Parameters
- $context : SDLValidationContext
Tags
Return values
array<string|int, mixed> —getVisitor()
Returns structure suitable for @see \Automattic\WooCommerce\Vendor\GraphQL\Language\Visitor.
public
getVisitor(QueryValidationContext $context) : array<string|int, mixed>
Parameters
- $context : QueryValidationContext
Return values
array<string|int, mixed> —reasonMessage()
public
static reasonMessage(string|array<string|int, mixed> $reasonOrReasons) : string
Parameters
- $reasonOrReasons : string|array<string|int, mixed>
Tags
Return values
string —collectConflictsBetween()
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.
protected
collectConflictsBetween(QueryValidationContext $context, array<string|int, mixed> &$conflicts, bool $parentFieldsAreMutuallyExclusive, array<string|int, mixed> $fieldMap1, array<string|int, mixed> $fieldMap2) : void
Parameters
- $context : QueryValidationContext
- $conflicts : array<string|int, mixed>
- $parentFieldsAreMutuallyExclusive : bool
- $fieldMap1 : array<string|int, mixed>
- $fieldMap2 : array<string|int, mixed>
Tags
Return values
void —collectConflictsBetweenFieldsAndFragment()
Collect all conflicts found between a set of fields and a fragment reference including via spreading in any nested fragments.
protected
collectConflictsBetweenFieldsAndFragment(QueryValidationContext $context, array<string|int, mixed> &$conflicts, array<string, true> &$comparedFragments, bool $areMutuallyExclusive, array<string|int, mixed> $fieldMap, string $fragmentName) : void
Parameters
- $context : QueryValidationContext
- $conflicts : array<string|int, mixed>
- $comparedFragments : array<string, true>
- $areMutuallyExclusive : bool
- $fieldMap : array<string|int, mixed>
- $fragmentName : string
Tags
Return values
void —collectConflictsBetweenFragments()
Collect all conflicts found between two fragments, including via spreading in any nested fragments.
protected
collectConflictsBetweenFragments(QueryValidationContext $context, array<string|int, mixed> &$conflicts, bool $areMutuallyExclusive, string $fragmentName1, string $fragmentName2) : void
Parameters
- $context : QueryValidationContext
- $conflicts : array<string|int, mixed>
- $areMutuallyExclusive : bool
- $fragmentName1 : string
- $fragmentName2 : string
Tags
Return values
void —collectConflictsWithin()
Collect all Conflicts "within" one collection of fields.
protected
collectConflictsWithin(QueryValidationContext $context, array<int, Conflict> &$conflicts, array<string|int, mixed> $fieldMap) : void
Parameters
- $context : QueryValidationContext
- $conflicts : array<int, Conflict>
- $fieldMap : array<string|int, mixed>
Tags
Return values
void —deduplicateFields()
protected
deduplicateFields(array<string|int, mixed> $fields) : array<string|int, mixed>
Parameters
- $fields : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —doTypesConflict()
Two types conflict if both types could not apply to a value simultaneously.
protected
doTypesConflict(Type $type1, Type $type2) : bool
Composite types are ignored as their individual field types will be compared later recursively. However, List and Non-Null types must match.
Parameters
Return values
bool —fieldFingerprint()
protected
fieldFingerprint(array<string|int, mixed> $field) : string
Parameters
- $field : array<string|int, mixed>
Tags
Return values
string —findConflict()
Determines if there is a conflict between two particular fields, including comparing their sub-fields.
protected
findConflict(QueryValidationContext $context, bool $parentFieldsAreMutuallyExclusive, string $responseName, array{: \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|null, : \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\FieldNode, : \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\FieldDefinition|null} $field1, array{: \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|null, : \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\FieldNode, : \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\FieldDefinition|null} $field2) : array<string|int, mixed>|null
Parameters
- $context : QueryValidationContext
- $parentFieldsAreMutuallyExclusive : bool
- $responseName : string
- $field1 : array{: \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|null, : \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\FieldNode, : \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\FieldDefinition|null}
- $field2 : array{: \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|null, : \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\FieldNode, : \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\FieldDefinition|null}
Tags
Return values
array<string|int, mixed>|null —findConflictsBetweenSubSelectionSets()
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.
protected
findConflictsBetweenSubSelectionSets(QueryValidationContext $context, bool $areMutuallyExclusive, Type|null $parentType1, SelectionSetNode $selectionSet1, Type|null $parentType2, SelectionSetNode $selectionSet2) : array<int, Conflict>
Parameters
- $context : QueryValidationContext
- $areMutuallyExclusive : bool
- $parentType1 : Type|null
- $selectionSet1 : SelectionSetNode
- $parentType2 : Type|null
- $selectionSet2 : SelectionSetNode
Tags
Return values
array<int, Conflict> —findConflictsWithinSelectionSet()
Find all conflicts found "within" a selection set, including those found via spreading in fragments. Called when visiting each SelectionSet in the Automattic\WooCommerce\Vendor\GraphQL Document.
protected
findConflictsWithinSelectionSet(QueryValidationContext $context, Type|null $parentType, SelectionSetNode $selectionSet) : array<string|int, mixed>
Parameters
- $context : QueryValidationContext
- $parentType : Type|null
- $selectionSet : SelectionSetNode
Tags
Return values
array<string|int, mixed> —getFieldsAndFragmentNames()
Given a selection set, return the collection of fields (a mapping of response name to field ASTs and definitions) as well as a list of fragment names referenced via fragment spreads.
protected
getFieldsAndFragmentNames(QueryValidationContext $context, Type|null $parentType, SelectionSetNode $selectionSet) : array{: \Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules\FieldMap, : array}
Parameters
- $context : QueryValidationContext
- $parentType : Type|null
- $selectionSet : SelectionSetNode
Tags
Return values
array{: \Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules\FieldMap, : arraygetReferencedFieldsAndFragmentNames()
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.
protected
getReferencedFieldsAndFragmentNames(QueryValidationContext $context, FragmentDefinitionNode $fragment) : array<string|int, mixed>
Parameters
- $context : QueryValidationContext
- $fragment : FragmentDefinitionNode
Tags
Return values
array<string|int, mixed> —internalCollectFieldsAndFragmentNames()
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.
protected
internalCollectFieldsAndFragmentNames(QueryValidationContext $context, Type|null $parentType, SelectionSetNode $selectionSet, array<string|int, mixed> &$astAndDefs, array<string, bool> &$fragmentNames) : void
Parameters
- $context : QueryValidationContext
- $parentType : Type|null
- $selectionSet : SelectionSetNode
- $astAndDefs : array<string|int, mixed>
- $fragmentNames : array<string, bool>
Tags
Return values
void —sameArguments()
protected
sameArguments(NodeList<string|int, ArgumentNode> $arguments1, NodeList<string|int, ArgumentNode> $arguments2) : bool
Parameters
- $arguments1 : NodeList<string|int, ArgumentNode>
-
keep
- $arguments2 : NodeList<string|int, ArgumentNode>
-
keep
Tags
Return values
bool —sameValue()
protected
sameValue(Node $value1, Node $value2) : bool
Parameters
Tags
Return values
bool —subfieldConflicts()
Merge Conflicts between two sub-fields into a single Conflict.
protected
subfieldConflicts(array<string|int, mixed> $conflicts, string $responseName, FieldNode $ast1, FieldNode $ast2) : array<string|int, mixed>|null
