todo: need to make this return a cloned instance rather than mutating state,
but the TreeBuilder relies on this effect atm

@param  InternalNode $link_target [description]

@return self
544913
public function withSuffixLink(InternalNode $link_target): self
    {
        if ($this->suffix_link !== null) {
            throw new \Exception("Trying to link node more than once.");
        }
        $this->suffix_link = $link_target;

        return $this;
    }
3270
public Builder newBuilder(String link) {
        Builder builder = new Builder();
        Builder.ParseResult result = builder.parse(this, link);
        return result == Builder.ParseResult.SUCCESS ? builder : null;
    }
582718
public static function createInvalidLinkTypeReturned(string $path, string $type): self
    {
        return new self(
            sprintf(
                'The link normalizer callback needs to return a %s|null, "%s" given at path: "%s"',
                LinkInterface::class,
                $type,
                $path
            )
        );
    }
644855
public function CloneInstance()
	{
		// Clone in this sense means be able to have a different current position so creating a new
		// DOMXPathNavigator instance should be sufficient. There is no need to clone the current node.
		return is_null( $this->domNode )
			? $this
			: new DOMXPathNavigator( $this->domNode, $this->nsManager, $this->nsTable );
	}
558856
function clone(target) {
  if (target == null || typeof target !== "object") return target;
  var cloned = target.constructor ? target.constructor() : Object.create(null);
  for (var attr in target) {
    if (target.hasOwnProperty(attr)) {
      cloned[attr] = target[attr];
    }
  }
  return cloned;
}
1228704
public function build(): CopyToRequest
	{
		$instance = new CopyToRequest();
		if ($this->nodeId === null) {
			throw new BuilderException('Property [nodeId] is required.');
		}
		$instance->nodeId = $this->nodeId;
		if ($this->targetNodeId === null) {
			throw new BuilderException('Property [targetNodeId] is required.');
		}
		$instance->targetNodeId = $this->targetNodeId;
		$instance->insertBeforeNodeId = $this->insertBeforeNodeId;
		return $instance;
	}
788886
public function ModifyDaftNestedObjectTreeInsert(
        DaftNestedWriteableObject $newLeaf,
        DaftNestedWriteableObject $referenceLeaf,
        bool $before = DaftNestedWriteableObjectTree::INSERT_AFTER,
        bool $above = null
    ) : DaftNestedWriteableObject {
        if ($newLeaf->GetId() === $referenceLeaf->GetId()) {
            throw new InvalidArgumentException('Cannot modify leaf relative to itself!');
        }

        if ((bool) $above) {
            $this->ModifyDaftNestedObjectTreeInsertAbove($newLeaf, $referenceLeaf);
        } elseif (DaftNestedWriteableObjectTree::DEFINITELY_BELOW === $above) {
            $this->ModifyDaftNestedObjectTreeInsertBelow($newLeaf, $referenceLeaf);
        } else {
            $this->ModifyDaftNestedObjectTreeInsertAdjacent($newLeaf, $referenceLeaf, $before);
        }

        return $this->RebuildAfterInsert($newLeaf);
    }
17379
protected function setTarget($target)
    {
        if ('*' == $target) {
            $this->target = $target;

            return $this;
        }
        if (is_string($target)) {
            $target = new Uri($target);
        }

        if (! $target instanceof UriInterface) {
            throw new InvalidArgumentException(sprintf(
                'Invalid target provided; must be an string or instance of '
                . '"%s", "%s" received.',
                'Psr\\Http\\Message\\UriInterface',
                is_object($target) ? get_class($target) : gettype($target)
            ));
        }
        $this->target = (string) $target->withFragment('');

        return $this;
    }
179217
public function GetNamedLink($name, $link, $target = null)
    {
        $result = '';
        if (strlen($name) != 0) {
            $result = $name;
            if (strlen($link) != 0) {
                $result = "<a href=\"".$link."\"".(is_null($target) ? "" : " target=\"".$target."\"").">".$result."</a>";
            }
        }
        return $result;
    }
464239
protected function createLink($source, $target)
    {
        $success = $this->filesystem->relativeSymlink($source, $target);
        if (!$success) {
            throw new RuntimeException("Could not create symlink at $target");
        }
    }
702807
public function setTarget($target = self::ODMENUTARGET_SELF)
    {
        $targets    = $this->getTargetConstants();
        $target     = (string) $target;
        if (!in_array($target, $targets)) { $target = self::ODMENUTARGET_SELF; }

        $this->target = $target;

        return $this;
    }
1310400
public function getOneToOne($target, $key = null, $target_key = null){
        $factory = $this->_db->factory($target);
        if(null === $key){
            $key = $this->getPK();
        }
        if(null === $target_key){
            $target_key = $factory->getPK();
        }
        
        return $factory->findOneBy($target_key, $this->get($key));
    }
863251
function via( $key ) {

        if ( !$this->parent_ ) throw new \LogicException( 'Cannot set reference key on basic Result' );

        $clone = clone $this;

        if ( $clone->single ) {

            $clone->parentKey = $key;

        } else {

            $clone->key = $key;

        }

        return $clone;

    }
517121
public function hasLinkTo(ResourceNode $parent, ResourceNode $target)
    {
        $nodes = $this->resourceNodeRepo
            ->findBy(array('parent' => $parent, 'class' => 'Claroline\CoreBundle\Entity\Resource\ResourceShortcut'));

        foreach ($nodes as $node) {
            $shortcut = $this->getResourceFromNode($node);
            if ($shortcut->getTarget() == $target) {
                return true;
            }
        }

        return false;
    }
896429
public function insertBefore($targets) {
    foreach ($this->nodes as $node) {
      $node->insertBefore($targets);
    }
    return $this;
  }
316130
protected function createFolder( $parentNode, $target )
    {
        // Grab settings from the ini file:
        $webdavINI = eZINI::instance( self::WEBDAV_INI_FILE );
        $folderClassID = $webdavINI->variable( 'FolderSettings', 'FolderClass' );
        $languageCode = eZContentObject::defaultLanguage();

        $contentObject = eZContentObject::createWithNodeAssignment( $parentNode, $folderClassID, $languageCode );
        if ( $contentObject )
        {
            $db = eZDB::instance();
            $db->begin();
            $version = $contentObject->version( 1 );
            $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
            $version->store();

            $contentObjectID = $contentObject->attribute( 'id' );
            $contentObjectAttributes = $version->contentObjectAttributes();

            // @todo @as avoid using [0] (could be another index in some classes)
            $contentObjectAttributes[0]->setAttribute( 'data_text', basename( $target ) );
            $contentObjectAttributes[0]->store();
            $db->commit();

            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
                                                                                         'version' => 1 ) );
            return true; // @as self::OK_CREATED;
        }
        else
        {
            return false; // @as self::FAILED_FORBIDDEN;
        }
    }
158175
private function copyRecursive($source, $target)
    {
        if (!is_dir($source)) {
            $this->filesystem->ensureDirectoryExists(dirname($target));
            copy($source, $target);

            return;
        }

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        $this->filesystem->ensureDirectoryExists($target);

        foreach ($iterator as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $iterator->getSubPathName();
            if ($file->isDir()) {
                $this->filesystem->ensureDirectoryExists($targetPath);
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }