Creates SubSpecs.

@internal

@param array $_subTerms Array representation of a subspec
@param SubfieldInterface|null The subfield is optional

@throws CK\MARCspec\Exception\InvalidMARCspecException

@return SubSpecInterface Instance of SubSpecInterface
333385
private function createSubSpec($_subTerms, $Subfield = null)
    {
        $fieldContext = $this->field->getBaseSpec();
        $context = $fieldContext;
        if (!is_null($Subfield)) {
            $context = $fieldContext.$Subfield->getBaseSpec();
            $subfieldContext = $Subfield->getBaseSpec();
        }

        $handleSubTerm = function ($subTerm) use ($fieldContext, $context) {
            if ('\\' == $subTerm[0]) { // is a comparisonString
                return new ComparisonString(substr($subTerm, 1));
            } else {
                if (strpos('[/_$', $subTerm[0]) && is_null($context)) {
                    throw new InvalidMARCspecException(
                        InvalidMARCspecException::SS.
                        InvalidMARCspecException::MISSINGFIELD,
                        $subTerm
                    );
                }

                switch ($subTerm[0]) {
                    case '_':
                        if ($refPos = strpos($context, $subTerm[0])) {
                            if ('$' !== substr($context, $refPos - 1, 1)) {
                                return new MARCspec(substr($context, 0, $refPos).$subTerm);
                            }
                        }

                        return new MARCspec($fieldContext.$subTerm);

                    case '$':
                        return new MARCspec($fieldContext.$subTerm);

                    case '/':
                        $refPos = strrpos($context, $subTerm[0]);
                        if ($refPos) {
                            if ('$' !== substr($context, $refPos - 1, 1)) {
                                return new MARCspec(substr($context, 0, $refPos).$subTerm);
                            }
                        }

                        return new MARCspec($context.$subTerm);

                    case '[':
                        $refPos = strrpos($context, $subTerm[0]);
                        if ($refPos) {
                            if ('$' !== substr($context, $refPos - 1, 1)) {
                                return new MARCspec(substr($context, 0, $refPos).$subTerm);
                            } else {
                                return new MARCspec($context.$subTerm);
                            }
                        } else {
                            return new MARCspec(substr($context, 0, 3).$subTerm);
                        }

                    default:
                        return new MARCspec($subTerm);
                }
            }
        };

        $_subTermSet = [];

        if (array_key_exists('leftsubterm', $_subTerms)) {
            $_subTermSet['leftsubterm'] = $handleSubTerm($_subTerms['leftsubterm']);
        } else {
            $_subTermSet['leftsubterm'] = new self($context);
        }

        $_subTermSet['rightsubterm'] = $handleSubTerm($_subTerms['rightsubterm']);

        return new SubSpec($_subTermSet['leftsubterm'], $_subTerms['operator'], $_subTermSet['rightsubterm']);
    }
670202
private function createSubresourceMetadata($subresource, PropertyMetadata $propertyMetadata): ?SubresourceMetadata
    {
        if (!$subresource) {
            return null;
        }

        $type = $propertyMetadata->getType();
        $maxDepth = \is_array($subresource) ? $subresource['maxDepth'] ?? null : null;

        if (null !== $type) {
            $isCollection = $type->isCollection();
            $resourceClass = $isCollection && ($collectionValueType = $type->getCollectionValueType()) ? $collectionValueType->getClassName() : $type->getClassName();
        } elseif (\is_array($subresource) && isset($subresource['resourceClass'])) {
            $resourceClass = $subresource['resourceClass'];
            $isCollection = $subresource['collection'] ?? true;
        } else {
            return null;
        }

        return new SubresourceMetadata($resourceClass, $isCollection, $maxDepth);
    }
10566
private function addSubfield($_subfield)
    {
        if (array_key_exists('subfieldtagrange', $_subfield)) {
            $_subfieldRange = $this->handleSubfieldRanges($_subfield['subfieldtagrange']);
        } else {
            $_subfieldRange[] = $_subfield['subfieldtag'];
        }

        foreach ($_subfieldRange as $subfieldTag) {
            $Subfield = new Subfield((string) $subfieldTag);

            if (array_key_exists('index', $_subfield)) {
                $_pos = $this->validatePos($_subfield['index']);

                $Subfield->setIndexStartEnd($_pos[0], $_pos[1]);
            } else {
                // as of MARCspec 3.2.2 spec without index is always an abbreviation
                $Subfield->setIndexStartEnd(0, '#');
            }

            if (array_key_exists('charpos', $_subfield)) {
                $_chars = $this->validatePos($_subfield['charpos']);

                $Subfield->setCharStartEnd($_chars[0], $_chars[1]);
            }

            if (array_key_exists('subspecs', $_subfield)) {
                $_subSpecs = [];

                foreach ($_subfield['subspecs'] as $subspec) {
                    if (!array_key_exists('operator', $subspec)) {
                        foreach ($subspec as $orSubSpec) {
                            $_subSpecs[] = $this->createSubSpec($orSubSpec, $Subfield);
                        }
                        $Subfield->addSubSpec($_subSpecs);
                    } else {
                        $Subspec = $this->createSubSpec($subspec, $Subfield);

                        $Subfield->addSubSpec($Subspec);
                    }
                }
            }

            $this->addSubfields($Subfield);
        }
    }
209540
public function ignoreListOfSubTemplates($subtemplates_list)
    {
        if ( ! is_array($subtemplates_list) ) {
            throw new InvalidException('List of subtemplate filenames must be an array');
        }
        $filenames = array_values($subtemplates_list);
        try {
            $this->getSoapClient()->SetSubTemplateIgnoreList(array(
                'filenames' => $filenames ,
            ));

            return $this;
        } catch ( SoapException $ex ) {
            throw new IgnoreException("Error while telling the server to ignore a list of subtemplates" , $ex);
        }
    }
1203656
public static function inParams(ParamErrors $errors, ParamErrorMessages $errorMessages): self
    {
        return new self(Sequence::of($errors)->map(
                function(array $errors, $paramName) use ($errorMessages): array
                {
                    $resolved = ['field' => $paramName, 'errors' => []];
                    foreach ($errors as $id => $error) {
                        $resolved['errors'][] = [
                                'id'      => $id,
                                'details' => $error->details(),
                                'message' => $errorMessages->messageFor($error)->message()
                        ];
                    }

                    return $resolved;
                }
        ));
    }
949128
function(C, SuperC) {
		C.$super = null; // what's this?
		C.$subclasses = [];
		C.$superclass = SuperC || null;
		C.$recurring = SuperC ?
			gui.Object.copy(SuperC.$recurring) : Object.create(null);
		if (SuperC) {
			SuperC.$subclasses.push(C);
		}
		return C;
	}
720459
def MakeSubparser(subparsers, parents, method, arguments=None):
    """"""
    name = ('-'.join(re.split(r'([A-Z][a-z]+)', method.__name__)[1:-1:2])).lower()
    help = method.__doc__.splitlines()[0]
    subparser = subparsers.add_parser(
        name=name, description=help, help=help.rstrip('.'), parents=parents)
    subparser.set_defaults(method=method, positional=[])
    argspec = inspect.getargspec(method)

    # Figure out positionals and default argument, if any. Explicitly includes
    # arguments that default to '' but excludes arguments that default to None.
    offset = len(argspec.args) - len(argspec.defaults or []) - 1
    positional = []
    for i in range(1, len(argspec.args)):
        if i > offset and argspec.defaults[i - offset - 1] is None:
            break
        positional.append(argspec.args[i])
    defaults = [None] * offset + list(argspec.defaults or [])

    # Add all arguments so they append to args.positional.
    args_help = _DocToArgs(method.__doc__)
    for name, default in zip(positional, defaults):
        if not isinstance(default, (None.__class__, str)):
            continue
        subparser.add_argument(
            name, help=(arguments or {}).get(name, args_help.get(name)),
            default=default, nargs='?' if default is not None else None,
            action=PositionalArg)
    if argspec.varargs:
        subparser.add_argument(
            argspec.varargs, nargs=argparse.REMAINDER,
            help=(arguments or {}).get(argspec.varargs, args_help.get(argspec.varargs)))
    return subparser
961231
private function iterateSubSpec($subSpecs, $fieldIndex, $subfieldIndex = null)
    {
        $valid = true;
        foreach ($subSpecs as $_subSpec) {
            if (is_array($_subSpec)) { // chained subSpecs (OR)
                foreach ($_subSpec as $this->currentSubSpec) {
                    $this->setIndexStartEnd($fieldIndex, $subfieldIndex);
                    if ($valid = $this->checkSubSpec()) {
                        break; // at least one of them is true (OR)
                    }
                }
            } else {
                // repeated SubSpecs (AND)
                $this->currentSubSpec = $_subSpec;
                $this->setIndexStartEnd($fieldIndex, $subfieldIndex);
                if (!$valid = $this->checkSubSpec()) {
                    break; // all of them have to be true (AND)
                }
            }
        }

        return $valid;
    }
989584
function createSubComponent() {
    $output = null;
    foreach( $this->components as $component ) {
      if( '' >= $component->getConfig( 'language'))
        $component->setConfig( 'language',  $this->getConfig( 'language' ));
      $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
      $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
      $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
      $component->setConfig( 'format',      $this->getConfig( 'format' ));
      $output .= $component->createComponent( $this->xcaldecl );
    }
    return $output;
  }
1189594
public function createSubscription(array $options = [], array $filters = [])
    {
        return $this->client->subscriptions->createFor($this, $options, $filters);
    }
1078907
private Collection<ClassDoc> subinterfaces(ClassDoc cd) {
        Collection<ClassDoc> ret = classToSubinterface.get(cd.qualifiedName());
        if (ret == null) {
            ret = new TreeSet<>(utils.makeComparatorForClassUse());
            SortedSet<ClassDoc> subs = classtree.subinterfaces(cd);
            if (subs != null) {
                ret.addAll(subs);
                for (ClassDoc sub : subs) {
                    ret.addAll(subinterfaces(sub));
                }
            }
            addAll(classToSubinterface, cd, ret);
        }
        return ret;
    }
891269
public function withRequiresSubscription($requiresSubscription)
    {
        $choices = [
            VideoInterface::REQUIRES_SUBSCRIPTION_NO,
            VideoInterface::REQUIRES_SUBSCRIPTION_YES,
        ];

        Assertion::choice($requiresSubscription, $choices);

        $instance = clone $this;

        $instance->requiresSubscription = $requiresSubscription;

        return $instance;
    }
667541
public static ReasonerQueryImpl create(ReasonerQueryImpl q, ConceptMap sub){
        return q.withSubstitution(sub).inferTypes();
    }
874936
public InternalContext createSubContext(VariantIndexer[] indexers, InternalContext localContext, int varSize) {
        Object[][] myParentScopes = this.parentScopes;
        //cal the new-context's parent-scopes
        Object[][] scopes;
        if (myParentScopes == null) {
            scopes = new Object[][]{this.vars};
        } else {
            scopes = new Object[myParentScopes.length + 1][];
            scopes[0] = this.vars;
            System.arraycopy(myParentScopes, 0, scopes, 1, myParentScopes.length);
        }

        InternalContext newContext = new InternalContext(template, localContext.out, Vars.EMPTY,
                indexers, varSize, scopes);
        newContext.localContext = localContext;
        return newContext;
    }
1090091
@Override
    public ConsumerDispatcher createSubscriptionConsumerDispatcher(ConsumerDispatcherState subState)
                    throws
                    SIDiscriminatorSyntaxException,
                    SISelectorSyntaxException,
                    SIResourceException,
                    SISelectorSyntaxException,
                    SIDiscriminatorSyntaxException,
                    SINonDurableSubscriptionMismatchException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "createSubscriptionConsumerDispatcher", subState);

        final ConsumerDispatcher cd = _pubSubRealization.
                        createSubscriptionConsumerDispatcher(subState);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "createSubscriptionConsumerDispatcher", cd);

        return cd;
    }
169004
public function getSubFields(): array
    {
        $fields = [];

        foreach ($this->config->get('sub_fields') as $field) {
            $field->setParentKey($this->getKey());

            $fields[] = $field->toArray();
        }

        return $fields;
    }
946509
private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
    {
        foreach ($parentClass->fieldMappings as $fieldName) {
            $subClass->mapField($parentClass->mappings[$fieldName], $parentClass);
        }
        foreach ($parentClass->referenceMappings as $fieldName) {
            $mapping = $parentClass->mappings[$fieldName];
            if ($mapping['type'] == ClassMetadata::MANY_TO_ONE) {
                $subClass->mapManyToOne($mapping, $parentClass);
            } else {
                $subClass->mapManyToMany($mapping, $parentClass);
            }
        }
        foreach ($parentClass->childMappings as $fieldName) {
            $mapping = $parentClass->mappings[$fieldName];
            $subClass->mapChild($mapping, $parentClass);
        }
        foreach ($parentClass->childrenMappings as $fieldName) {
            $subClass->mapChildren($parentClass->mappings[$fieldName], $parentClass);
        }
        foreach ($parentClass->referrersMappings as $fieldName) {
            $subClass->mapReferrers($parentClass->mappings[$fieldName], $parentClass);
        }
        if ($parentClass->identifier) {
            $subClass->mapId($parentClass->mappings[$parentClass->identifier], $parentClass);
        }
        if ($parentClass->node) {
            $subClass->mapNode($parentClass->mappings[$parentClass->node], $parentClass);
        }
        if ($parentClass->nodename) {
            $subClass->mapNodename($parentClass->mappings[$parentClass->nodename], $parentClass);
        }
        if ($parentClass->parentMapping) {
            $subClass->mapParentDocument($parentClass->mappings[$parentClass->parentMapping], $parentClass);
        }
        if ($parentClass->localeMapping) {
            $subClass->mapLocale($parentClass->mappings[$parentClass->localeMapping], $parentClass);
        }
        if ($parentClass->depthMapping) {
            $subClass->mapDepth($parentClass->mappings[$parentClass->depthMapping], $parentClass);
        }
        if ($parentClass->versionNameField) {
            $subClass->mapVersionName($parentClass->mappings[$parentClass->versionNameField], $parentClass);
        }
        if ($parentClass->versionCreatedField) {
            $subClass->mapVersionCreated($parentClass->mappings[$parentClass->versionCreatedField], $parentClass);
        }
        if ($parentClass->lifecycleCallbacks) {
            $subClass->mapLifecycleCallbacks($parentClass->lifecycleCallbacks);
        }

        $subClass->setReferenceable($parentClass->referenceable);

        // Versionable defaults to false - only set on child class if it is non-false
        if ($parentClass->versionable) {
            $subClass->setVersioned($parentClass->versionable);
        }

        $subClass->setTranslator($parentClass->translator);
        $subClass->setNodeType($parentClass->nodeType);
        $subClass->setCustomRepositoryClassName($parentClass->customRepositoryClassName);
    }