Automattic\WooCommerce\Vendor\GraphQL\Validator\Rules
OverlappingFieldsCanBeMerged::doTypesConflict
Two types conflict if both types could not apply to a value simultaneously.
Composite types are ignored as their individual field types will be compared later recursively. However, List and Non-Null types must match.
Method of the class: OverlappingFieldsCanBeMerged{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->doTypesConflict( $type1, $type2 ): bool;
OverlappingFieldsCanBeMerged::doTypesConflict() OverlappingFieldsCanBeMerged::doTypesConflict code WC 10.9.1
protected function doTypesConflict(Type $type1, Type $type2): bool
{
if ($type1 instanceof ListOfType) {
return $type2 instanceof ListOfType
? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType())
: true;
}
if ($type2 instanceof ListOfType) {
return true;
}
if ($type1 instanceof NonNull) {
return $type2 instanceof NonNull
? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType())
: true;
}
if ($type2 instanceof NonNull) {
return true;
}
if (Type::isLeafType($type1) || Type::isLeafType($type2)) {
return $type1 !== $type2;
}
return false;
}