@param string $source
@param string $target

@return static
328615
public static function create($source, $target)
    {
        $message = sprintf('Dependency `%s` not found, required by `%s`', $target, $source);
        $exception = new static($message, 0, null, $source, $target);

        return $exception;
    }
1062081
protected static function addMissingParts($source, $target)
    {
        $pattern = '/'.preg_replace('/[0-9]+/', '[0-9]+', preg_quote($target, '/')).'$/';

        $result = preg_replace($pattern, $target, $source, 1, $count);

        return $count ? $result : $target;
    }
723494
protected static function mergeArrays($target, $source)
    {
        foreach ($source as $node => $values) {
            if (!array_key_exists($node, $target)) {
                $target[$node] = $values;
            } elseif (is_array($values)) {
                $target[$node] = self::mergeArrays($target[$node], $values);
            } else {
                $target[$node] = $values;
            }
        }

        return $target;
    }
306864
private function checkTextTarget($source, $target): void
    {
        $text_array = $this->text_array;
        if (!(\array_key_exists($source, $text_array))) {
            throw new TencentAIException(90701);
        }
        if (!(\in_array($target, $text_array[$source], true))) {
            throw new TencentAIException(90702);
        }
    }
653277
public function addEdge( $source, $target, $value = 1 )
	{
		return $this->edgeSet->addEdge( $source, $target, $value );
	}
861533
private function checkImageTarget($source, $target): void
    {
        $image_array = $this->image_array;
        if (!(\array_key_exists($source, $image_array))) {
            throw new TencentAIException(90703);
        }
        if (!(\in_array($target, $image_array[$source], true))) {
            throw new TencentAIException(90704);
        }
    }
116190
public function getGrade( $source, $target )
	{
		if( $this->isEdge( $source, $target ) )
			return 1;
		$nodes = $this->getTargetNodes( $source );
		foreach( $nodes as $node )
		{
			$way = $this->getGrade( $node, $target );
			return ++$way;
		}
		return false;
	}
289385
protected static function createLink( $source, $target )
	{
		if( file_exists( $target ) === false && @symlink( $source, $target ) === false )
		{
			$source = realpath( __DIR__ . '/' . $source );

			if( symlink( $source, $target ) === false ) {
				throw new \RuntimeException( sprintf( 'Failed to create symlink for "%1$s" to "%2$s"', $source, $target ) );
			}
		}
	}
1337156
private function link(string $source, string $target): bool
    {
        if (!@link($source, $target)) {
            $message = 'Could not create link.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return true;
    }
108645
public function write($source, string $target): void
    {
        $source->move(\dirname($target), basename($target));
    }
1247549
protected function copy($source, $target): void
    {
        // skip, if not exists
        if (!file_exists($source)) {
            return;
        }
        // skip, if target exists
        if (is_file($target) && !is_dir($target)) {
            $this->installer->getIo()->write(
                sprintf('  - File <comment>%s</comment> already exists', $target),
                true,
                IOInterface::VERBOSE
            );
            return;
        }

        // Check the renaming of file for direct moving (file-to-file)
        $isRenameFile = substr($target, -1) !== '/' && !is_dir($source);

        if (file_exists($target) && !is_dir($target) && !$isRenameFile) {
            throw new \InvalidArgumentException('Destination directory is not a directory');
        }

        try {
            if ($isRenameFile) {
                $this->getFilesystem()->mkdir(\dirname($target));
            } else {
                $this->getFilesystem()->mkdir($target);
            }
        } catch (IOException $e) {
            throw new \InvalidArgumentException(
                sprintf('Could not create directory `%s`', $target)
            );
        }

        if (false === file_exists($source)) {
            throw new \InvalidArgumentException(
                sprintf('Source directory or file `%s` does not exist', $source)
            );
        }

        if (is_dir($source)) {
            $finder = new Finder;
            $finder->files()->in($source);

            foreach ($finder as $file) {
                try {
                    $this->getFilesystem()->copy($file, $target . DS . $file->getRelativePathname());
                } catch (IOException $e) {
                    throw new \InvalidArgumentException(
                        sprintf('Could not copy `%s`', $file->getBaseName())
                    );
                }
            }
        } else {
            try {
                if ($isRenameFile) {
                    $this->getFilesystem()->copy($source, $target);
                } else {
                    $this->getFilesystem()->copy($source, $target . '/' . basename($source));
                }
            } catch (IOException $e) {
                throw new \InvalidArgumentException(sprintf('Could not copy `%s`', $source));
            }
        }

        $this->installer->getIo()->write(
            sprintf('  - Copied file(s) from <comment>%s</comment> to <comment>%s</comment>', $source, $target),
            true,
            IOInterface::VERBOSE
        );
    }
1331827
protected function mergeMetadata($source, $target)
    {
        if ($source instanceof \ArrayAccess) {
            if ($target instanceof \ArrayAccess) {
                if ($source instanceof MetadataInterface) {
                    $metadata = $source->getMetadata();
                    foreach ($metadata as $offset => $value) {
                        $target->offsetSet($offset, $value);
                    }
                } else {
                    throw new \RuntimeException('Source had to make all metadata available!');
                }
            } else {
                throw new \RuntimeException('Source metadata can not be merged!');
            }
        }
    }
803510
public function moveFile($source, $target, $file)
    {
        if (file_exists($source.$file)) {
            rename($source.$file, $target.$file);
        }
    }
906420
public function uncompress($source, $target)
    {
        $bz = @bzopen($source, 'r');
        $fh = @fopen($target, 'wb');

        if ($fh === false || $bz === false) {
            return false;
        }

        while (!feof($bz)) {
            if (fwrite($fh, bzread($bz, 1024)) === false) {
                return false;
            }
        }

        fclose($fh);
        bzclose($bz);

        return true;
    }
1097431
public function copy($source, $target)
    {
        $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
        $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);

        if (!file_exists($target)) {
            mkdir($target, 0777, true);
        }

        foreach ($ri as $file) {
            $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathName();
            if ($file->isDir()) {
                if (!file_exists($targetPath)) {
                    mkdir($targetPath);
                }
            } else {
                copy($file->getPathname(), $targetPath);
            }
        }
    }
50362
private function createMapping(AbstractTable $source, AbstractTable $target)
    {
        $mapping = [];
        foreach ($target->getColumns() as $name => $column) {
            if ($source->hasColumn($name)) {
                $mapping[$name] = $column->getName();
            }
        }

        return $mapping;
    }
839299
protected static function mergeObjects(stdClass &$target, stdClass ...$sources): void
    {
        foreach ($sources as $source) {
            foreach ($source as $key => $value) {
                if (str_starts_with($key, 'i__')) {
                    continue;
                }

                if (isset($target->$key) && is_object($value) && is_object($target->$key)) {
                    static::mergeObjects($target->$key, $value);
                } else {
                    $target->$key = $value;
                }
            }
        }
    }