@noinspection PhpMissingParentCallCommonInspection

@inheritdoc
776415
final public function getRelationships($model, $isPrimary, array $includeRelationships)
    {
        $includables = array();
        foreach ($includeRelationships as $key => $relation) {
            $relationship = $this->loadRelation($model, $relation, $includeRelationships);
            $includables[$this->changeKeyToDashed($key)] = [self::DATA => $relationship ];
        }
        return $includables;
    }
1204929
private function makeParentActive($parent)
    {
        if (! is_null($parent)
            && method_exists($parent, 'activeParentage')
            && $parent->activeParentage()
        ) {
            $parent->setActive(true);
        }
    }
1084720
protected function useParentMethodAndExternals($method, $parameters, $includeExternals = false, $returnOne = false)
    {
        $result = call_user_func_array([
            $this,
            sprintf('parent::%s', $method),
        ], $parameters);
        if ($includeExternals === true && (($returnOne === true && $result === null) || $returnOne === false)) {
            $result = $this->useExternalSchemas($method, $parameters, $result, $returnOne);
        }
        return $result;
    }
462975
public function setParent($parent)
    {
        if ($parent !== null && !$parent instanceof self) {
            throw new \InvalidArgumentException('An entry may only have another entry as parent');
        }

        $this->parent = $parent;
    }
575903
public function getParent($n = null)
	{
		return ($n > 1) ? $this->parent->getParent(--$n) : $this->parent;
	}
573139
protected function parseParameter( ADT_PHP_Function $parent, $matches )
	{
		$parameter	= new ADT_PHP_Parameter( $matches[5] );
		$parameter->setParent( $parent );
		$parameter->setLine( $this->lineNumber );
		$parameter->setCast( $matches[2] );
		$parameter->setReference( (bool) $matches[4] );

		if( isset( $matches[6] ) )
			$parameter->setDefault( $matches[7] );
		return $parameter;
	}
106588
public function setParent($object) {
		
		if (! is_object($object)) {
			throw new \InvalidArgumentException("Expecting object, given: ".gettype($object));
		}
		
		$this->parent = $object;
		return $this;
	}
1096075
private function ensureParentAndKey($parent, $key)
    {
        if (!$this->parent)
        {
            $this->parent = $parent;
        }
        if (!$this->key)
        {
            $this->key = $key;
        }
        if ($this->parent != $parent)
        {
            throw new \Exception('Internal Error. Relation retrieved from two different Objects.');
        }
        if ($this->key != $key)
        {
            throw new \Exception('Internal Error. Relation retrieved from two different keys.');
        }
    }
979786
private function skip(ContextInterface $context)
    {
        $dataStack = $context->getDataStack();
        $metadataStack = $context->getMetadataStack();
        $references = [];
        $depth = 0;

        for ($index = count($metadataStack) - 1; $index >= 0; --$index) {
            $metadata = $metadataStack[$index];
            $data = $dataStack[$index];

            if ($metadata instanceof ClassMetadataInterface) {
                $hash = spl_object_hash($data);

                if (!isset($references[$hash])) {
                    $references[$hash] = 0;
                }

                if (++$references[$hash] > $this->circularReferenceLimit) {
                    return true;
                }
            }

            if ($metadata instanceof TypeMetadataInterface) {
                ++$depth;
            }

            if (!$metadata instanceof PropertyMetadataInterface) {
                continue;
            }

            ++$depth;

            if (!$metadata->hasMaxDepth()) {
                continue;
            }

            if ($depth > $metadata->getMaxDepth()) {
                return true;
            }
        }

        return false;
    }
579299
public function build(): PauseOnAsyncCallRequest
	{
		$instance = new PauseOnAsyncCallRequest();
		if ($this->parentStackTraceId === null) {
			throw new BuilderException('Property [parentStackTraceId] is required.');
		}
		$instance->parentStackTraceId = $this->parentStackTraceId;
		return $instance;
	}
1145769
protected function initNodeTrait(?NodeInterface $parent = null, ?string $name = null)
    {
        $this->nodeName = $name ?? spl_object_hash($this);

        if (!$parent) {
            $this->nodeRoot = $this;
            $this->nodeParent = $this;
        } else {
            $this->nodeRoot = $parent->getRoot();
            $this->nodeParent = $parent;
            /** @noinspection PhpParamsInspection */
            $parent->addChild($this);
        }
    }
420317
public function setNullParent()
    {
        if ($this->hasParent()) {
            unset($this->parent->children);
        }
        unset($this->parent);
        $this->setParentId(static::$nullParent);
    }
412744
public function detectParent()
    {
        // Look for a string, then a number (the parent id), followed by a non-action
        // string, then possiby a number and/or an action string and then the end
        $pattern = '#([a-z-]+)/(\d+)/(?!'.implode('|', $this->actions).')[a-z-]+(?:/\d+)?(/('.implode('|', $this->actions).'))?$#i';
        if (preg_match($pattern, $this->path, $matches)) {
            return [$matches[1], $matches[2]];
        }

        return false;
    }
667215
public static function validate($object, ExecutionContextInterface $context)
    {
        if (!method_exists($object, 'getParent')) {
            return;
        }

        $tempObject = $object->getParent();

        while ($tempObject !== null) {
            if ($tempObject === $object) {
                $context->buildViolation(
                    'Circular reference error. '
                    . 'An object can not reference with a parent to itself nor to an ancestor of itself'
                )
                    ->atPath('parent')
                    ->addViolation();

                break;
            }

            $tempObject = $tempObject->getParent();
        }
    }
1139611
public function filter()
    {
        $opts = func_get_args();
        $callable = array_shift($opts);

        // allow for a false call
        if (!is_callable($callable)) {
            return $this;
        }

        array_unshift($opts, $this);
        return call_user_func_array($callable, $opts);
    }
1174681
public function setParent($parent)
    {
        if ($parent !== null &&  !$parent instanceof BaseEntry) {
            throw new \InvalidArgumentException('An entry may only have another entry as parent');
        }

        $this->parent = $parent;
    }
329681
private function parentIsNotIn($conjunction, array $parentModelIds)
    {
        if (!empty($this->expression)) {
            $this->expression[] = $conjunction;
        }

        $expression = [];
        foreach ($parentModelIds as $parentModelId) {
            $index             = \count($this->variables);
            $expression[]      = \sprintf(self::PARENT_IS_NOT_EXPRESSION, $index);
            $this->variables[] = $parentModelId;
        }
        $this->expression[] = '(' . \implode(' and ', $expression) . ')';
        $this->compiled     = null;

        return $this;
    }