isLeafType() публичный статический Метод

public static isLeafType ( $type ) : boolean
$type
Результат boolean
Пример #1
0
 public function __invoke(ValidationContext $context)
 {
     return [Node::FIELD => function (Field $node) use($context) {
         $type = $context->getType();
         if ($type) {
             if (Type::isLeafType($type)) {
                 if ($node->selectionSet) {
                     return new Error(Messages::noSubselectionAllowedMessage($node->name->value, $type), [$node->selectionSet]);
                 }
             } else {
                 if (!$node->selectionSet) {
                     return new Error(Messages::requiredSubselectionMessage($node->name->value, $type), [$node]);
                 }
             }
         }
     }];
 }
 /**
  * @param OutputType $type1
  * @param OutputType $type2
  * @return bool
  */
 private function doTypesConflict(OutputType $type1, OutputType $type2)
 {
     if ($type1 instanceof ListOfType) {
         return $type2 instanceof ListOfType ? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType()) : true;
     }
     if ($type2 instanceof ListOfType) {
         return $type1 instanceof ListOfType ? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType()) : true;
     }
     if ($type1 instanceof NonNull) {
         return $type2 instanceof NonNull ? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType()) : true;
     }
     if ($type2 instanceof NonNull) {
         return $type1 instanceof NonNull ? $this->doTypesConflict($type1->getWrappedType(), $type2->getWrappedType()) : true;
     }
     if (Type::isLeafType($type1) || Type::isLeafType($type2)) {
         return $type1 !== $type2;
     }
     return false;
 }