@param \google\protobuf\FileDescriptorProto $fileDescriptor
@param \google\protobuf\EnumDescriptorProto $enumDescriptor
@param string                               $parent

@return \Protobuf\Compiler\Entity
971703
protected function generateEnum(FileDescriptorProto $fileDescriptor, EnumDescriptorProto $enumDescriptor, $parent = null)
    {
        $type   = Entity::TYPE_ENUM;
        $name   = $enumDescriptor->getName();
        $entity = new Entity($type, $name, $enumDescriptor, $fileDescriptor, $parent);

        return $entity;
    }
1054165
public function createMultipartRelatedPartForInlineChildrenOf(ParentHeaderPart $parent)
    {
        $relatedPart = $this->partBuilderFactory->newPartBuilder($this->mimePartFactory)->createMessagePart();
        $this->setMimeHeaderBoundaryOnPart($relatedPart, 'multipart/related');
        foreach ($parent->getChildParts(PartFilter::fromDisposition('inline', PartFilter::FILTER_EXCLUDE)) as $part) {
            $parent->removePart($part);
            $relatedPart->addChild($part);
        }
        $parent->addChild($relatedPart, 0);
        return $relatedPart;
    }
59169
protected function mapReflectorPropertiesOntoDescriptor(Function_ $reflector, FunctionDescriptor $descriptor): void
    {
        $packages = new Collection();
        $package = $this->extractPackageFromDocBlock($reflector->getDocBlock());
        //TODO: this looks like a potential bug. Have to investigate this!
        if ($package) {
            $tag = new TagDescriptor('package');
            $tag->setDescription($package);
            $packages->add($tag);
        }

        $descriptor->getTags()->set('package', $packages);

        $descriptor->setFullyQualifiedStructuralElementName($reflector->getFqsen());
        $descriptor->setName($reflector->getName());
        $descriptor->setLine($reflector->getLocation()->getLineNumber());
        $descriptor->setNamespace('\\' . trim(substr(
            (string) $reflector->getFqsen(),
            0,
            -strlen($reflector->getName()) - 2
        ), '\\'));
        $descriptor->setReturnType($reflector->getReturnType());
    }
1294111
public function findOneByTerms(Competency $parent, Ability $ability)
    {
        $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]);

        if (!$link) {
            throw new \RuntimeException(
                "Competency {$parent->getId()} is not linked to ability {$ability->getId()}"
            );
        }

        return $link;
    }
393576
protected function generateExtension(FileDescriptorProto $fileDescriptor, $parent = null)
    {
        $name   = 'Extension';
        $type   = Entity::TYPE_EXTENSION;
        $entity = new Entity($type, $name, $fileDescriptor, $fileDescriptor, $parent);

        if ($fileDescriptor->hasExtensionList() && $this->containsProtobufExtension($fileDescriptor->getExtensionList())) {
            $entity->setProtobufExtension(true);
        }

        return $entity;
    }
645177
public function setParent(\Octopouce\AdminBundle\Entity\Category $parent = null)
    {
        $this->parent = $parent;

        return $this;
    }
846245
public function setParent($parent, $from)
    {
        $this->parents()->set($parent, $parent instanceof Document ? $from : '*');
        return $this;
    }
646268
protected function generateFieldSizeStatement(Entity $entity, FieldDescriptorProto $field)
    {
        $generator = new SerializedSizeFieldStatementGenerator($this->context);
        $statement = $generator->generateFieldSizeStatement($entity, $field);

        return $statement;
    }
955055
public function setParent(\Coral\ContentBundle\Entity\Node $parent)
    {
        $this->parent = $parent;

        return $this;
    }
349157
public function registerReferences(DescriptorInterface $descriptor)
    {

        //  register the EPB references
        foreach ($descriptor->getEpbReferences() as $epbReference) {
            $this->registerEpbReference($epbReference);
        }

        // register the resource references
        foreach ($descriptor->getResReferences() as $resReference) {
            $this->registerResReference($resReference);
        }

        // register the bean references
        foreach ($descriptor->getBeanReferences() as $beanReference) {
            $this->registerBeanReference($beanReference);
        }

        // register the persistence unit references
        foreach ($descriptor->getPersistenceUnitReferences() as $persistenceUnitReference) {
            $this->registerPersistenceUnitReference($persistenceUnitReference);
        }
    }
519007
protected function hydrateEntityInRevision($parentIdentifier, $revision) {
    $parentIdentifier = $this->v->validateIdentifier($parentIdentifier, $this->getEntityMeta());
    
    if ($revision === $this->defaultRevision) {
      return $this->repository->hydrate($parentIdentifier);
    } else {
      throw EntityNotFoundException::criteria(compact('parentIdentifier', 'revision'));
    }
  }
1349989
protected function generateHasMethod(Entity $entity, FieldDescriptorProto $field)
    {
        $fieldName  = $field->getName();
        $methodName = $this->getAccessorName('has', $field);
        $method     = MethodGenerator::fromArray([
            'name'       => $methodName,
            'body'       => 'return $this->' . $fieldName . ' !== null;',
            'docblock'   => [
                'shortDescription' => "Check if '$fieldName' has a value",
                'tags'             => [
                    [
                        'name'        => 'return',
                        'description' => 'bool',
                    ]
                ]
            ]
        ]);

        return $method;
    }
347708
public function generateBody(Entity $entity, FieldDescriptorProto $field)
    {
        $name      = $field->getName();
        $tag       = $field->getNumber();
        $extEntity = $this->getEntity($field->getExtendee());
        $extendee  = $extEntity->getNamespacedName();

        $nameQuoted     = var_export($name, true);
        $extendeeQuoted = var_export($extendee, true);

        $sizeCallback  = $this->generateSizeCallback($entity, $field);
        $readCallback  = $this->generateReadCallback($entity, $field);
        $writeCallback = $this->generateWriteCallback($entity, $field);
        $callbacks     = array_merge($readCallback, [null], $writeCallback, [null], $sizeCallback);
        $arguments     = [
            $extendeeQuoted,
            $nameQuoted,
            $tag,
            '$readCallback',
            '$writeCallback',
            '$sizeCallback',
            '__METHOD__'
        ];

        $body[] = 'if (self::$' . $name . ' !== null) {';
        $body[] = '    return self::$' . $name . ';';
        $body[] = '}';
        $body[] = null;
        $body   = array_merge($body, $callbacks);
        $body[] = null;
        $body[] = 'return self::$' . $name . ' = new \Protobuf\Extension\ExtensionField(' . implode(', ', $arguments) . ');';

        return $body;
    }
431906
final public function parent(string $parent)
    {
        if (!$this->allowParent) {
            throw new InvalidArgumentException(sprintf('A parent cannot be defined when either "_instanceof" or "_defaults" are also defined for service prototype "%s".', $this->id));
        }

        if ($this->definition instanceof ChildDefinition) {
            $this->definition->setParent($parent);
        } elseif ($this->definition->isAutoconfigured()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also have "autoconfigure". Try disabling autoconfiguration for the service.', $this->id));
        } elseif ($this->definition->getBindings()) {
            throw new InvalidArgumentException(sprintf('The service "%s" cannot have a "parent" and also "bind" arguments.', $this->id));
        } else {
            // cast Definition to ChildDefinition
            $definition = serialize($this->definition);
            $definition = substr_replace($definition, '53', 2, 2);
            $definition = substr_replace($definition, 'Child', 44, 0);
            $definition = unserialize($definition);

            $this->definition = $definition->setParent($parent);
        }

        return $this;
    }
900168
protected function getDoctype(FieldDescriptorProto $field)
    {
        $fieldType = $field->getType()->value();
        $phpType   = Field::getPhpType($fieldType);
        $refTypes  = [
            Type::TYPE_ENUM_VALUE    => true,
            Type::TYPE_MESSAGE_VALUE => true
        ];

        if (isset($refTypes[$fieldType])) {
            $typeName  = $field->getTypeName();
            $refEntity = $this->getEntity($typeName);

            return $refEntity->getNamespacedName();
        }

        return $phpType ?: 'mixed';
    }
1329699
protected function hasExtension(FileDescriptorProto $fileDescriptor)
    {
        $messages     = $fileDescriptor->getMessageTypeList();
        $hasExtension = $fileDescriptor->hasExtensionList();

        if ($hasExtension) {
            return true;
        }

        if ($messages === null) {
            return false;
        }

        foreach ($messages as $message) {
            if ($message->hasExtensionList()) {
                return true;
            }
        }

        return false;
    }
167105
protected function renderElement(Descriptor $descriptor) {
		$element = $this->renderElementInner($descriptor);
		
		if ($descriptor->hasChildren()) {
			$tagsLocator = $this->getTagsLocator();
			
			$children = $this->renderChildren($descriptor);
			$element  = $tagsLocator->link->render() . $element;
			
			return $children . $tagsLocator->wrapper->render($element);
		}
		
		return $element;
	}