Sets the Definition to inherit from.

@return $this

@throws InvalidArgumentException when parent cannot be set
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;
    }
164624
protected function inheritFromParent(BaseQuery $parent)
    {
        parent::inheritFromParent($parent);

        if ($parent instanceof Select) {
            $parent->copyTo($this);
        } 
    }
1002308
public function setParent($parent)
    {
        if (!$parent instanceof ClassDescriptor && !$parent instanceof InterfaceDescriptor && $parent !== null) {
            throw new \InvalidArgumentException('Constants can only have an interface or class as parent');
        }

        $fqsen = $parent !== null
            ? $parent->getFullyQualifiedStructuralElementName() . '::' . $this->getName()
            : $this->getName();

        $this->setFullyQualifiedStructuralElementName($fqsen);

        $this->parent = $parent;
    }
106588
public function setParent($object) {
		
		if (! is_object($object)) {
			throw new \InvalidArgumentException("Expecting object, given: ".gettype($object));
		}
		
		$this->parent = $object;
		return $this;
	}
832170
public function setAsRoot()
    {
        $this->handleNewNodes();
        if (!$this->isRoot()) { // Only if it is not already root
            if ($this->fireModelEvent('updatingParent') === false) {
                return $this;
            }
            $oldDescendants                         = $this->getOldDescendants();
            $this->{$this->getTreeColumn('path')}   = $this->getKey() . '/';
            $this->{$this->getTreeColumn('parent')} = null;
            $this->setRelation('parent', null);
            $this->{$this->getTreeColumn('level')} = 0;
            $this->save();
            $this->fireModelEvent('updatedParent', false);
            $this->updateDescendants($this, $oldDescendants);
        }
        return $this;
    }
570359
public function setParent(\Neobazaar\Entity\Document $parent = null)
    {
        $this->parent = $parent;
    
        return $this;
    }
368576
def _set_parent(self, parent=None):
        
        if parent is not None:
            if not isinstance(parent, Parentable):
                raise ValueError('Parent object must implement Parentable interface.')
            if parent is self or parent._contains(self):
                raise ValueError('Self references are not allowed.')
        self._parent = parent if parent is not None else None
534178
public function setParent($parent)
    {
        if (empty($parent) || $this->getRefId() == $parent->getRefId() ||
            $parent->hasAncestor($this) || $this->hasReachedAncestorLimit()) {
            return false;
        }
        unset($this->parent);
        unset($parent->children);
        $this->trigger(static::$eventParentChanged);
        $parent->trigger(static::$eventChildAdded);
        return $this->{$this->parentAttribute} = $parent->getRefId();
    }
125443
public function setParent(FilterBuilderWithChildren $parent)
    {
        if ($this->parent && $this->parent !== $parent) {
            $this->parent->remove($this);
        }

        $this->parent = $parent;
        $this->parent->add($this);

        return $this;
    }
1014471
protected function construct():parent
	{
		$name= $this->line->pregGet('/(?<=^~)[\w-]*/');
		$this->name=$name;

		$this->loadConfig($name,$this->htsl);

		$this->param= $this->line->pregGet('/^~[\w-]*\( (.*) \)/',1);

		$this->structureName=$this->config['name']??$name;

		$this->id=strtoupper(uniqid());

		return $this;
	}
159351
public function set_parent(Node_Container $parent=null)
	{
		$this->parent = $parent;

		if($parent instanceof Node_Container_Document)
			$this->root = $parent;
		else
			$this->root = $parent->root();
	}
1144878
protected function fetchParent()
    {
        $parent = $this->getOption('parent');
        if ($parent instanceof MenuItem)
        {
            $this->setParentItem($parent);
        }

        return $this;
    }
698993
public function define($name, $parameters = [], $parent = null, $children = [])
    {
        if (is_array($parent)) {
            $children = $parent;
            $parent = null;
        }
        if ($parent) {
            if (!array_has($this->items, $parent))
                throw new InvalidArgumentException("{$parent} does not exist");

            $name = "{$parent}.children.{$name}";

            if (empty($parameters['icon'])) $parameters['icon'] = 'fa-circle-o';
        } else {
            if (empty($parameters['icon'])) $parameters['icon'] = '';
        }
        if (empty($parameters['sort'])) $parameters['sort'] = 10;

        array_set($this->items, $name, $parameters);

        foreach ($children as $childName => $child) {
            $this->define($childName, $child, $name);
        }
    }
653121
public function setParent(\Enhavo\Bundle\NavigationBundle\Model\NodeInterface $parent = null)
    {
        $this->parent = $parent;

        return $this;
    }
1370921
public function detach() {
        if($this->__parent) {
            $this->__parent->offsetUnset($this->__name);
        }

        $this->__parent = NULL;
        $this->__name = NULL;
        return $this;
    }
117636
public function inheritFromParent()
    {
        if (!$this->hasParent()) {
            return $this;
        }
        $parent = $this->getParent();
        // recurse if
        if ($parent instanceof $this && $parent->hasParent()) {
            $this->parent = $parent->inheritFromParent();
            unset($parent);
        }
        if ($this->getType() === 'reference') {
            return $this->getParent();
        }
        if (!($this->getParent() instanceof $this)) {
            throw new \LogicException(\sprintf(
                'Inheritance not possible because of incompatible Types, child is instance of %s and parent is instance of %s',
                \get_class($this),
                \get_class($this->getParent())
            ));
        }

        // retrieve all getter/setters so we can check all properties for possible inheritance
        $getters = [];
        $setters = [];
        foreach (\get_class_methods($this) as $method) {
            $result = \preg_split('/^(get|set)(.*)$/', $method, null, PREG_SPLIT_NO_EMPTY);
            if (\count($result) === 2) {
                if ($result[0] === 'get') {
                    $getters[\lcfirst($result[1])] = $method;
                }
                if ($result[0] === 'set') {
                    $setters[\lcfirst($result[1])] = $method;
                }
            }
        }
        $properties = \array_keys(\array_merge($getters, $setters));

        foreach ($properties as $prop) {
            if (!isset($getters[$prop]) || !isset($setters[$prop])) {
                continue;
            }
            $getter = $getters[$prop];
            $setter = $setters[$prop];
            $currentValue = $this->{$getter}();
            // if it is unset, make sure it is equal to parent
            if ($currentValue === null) {
                $this->{$setter}($this->getParent()->{$getter}());
            }
            // if it is an array, add parent values
            if (\is_array($currentValue)) {
                $newValue = \array_merge($this->getParent()->{$getter}(), $currentValue);
                $this->{$setter}($newValue);

                continue;
            }
        }

        return $this;
    }
474185
def inherit_definition(definition, inherit)
      unless definition.parents.include?(inherit)
        definition.parents << inherit
      end
    end