@param \Jodit\Config $source

@return \Jodit\File[]
@throws \Exception
497720
public function move(Config $source) {
		$files = $_FILES[$source->defaultFilesKey];
		/**
		 * @var $output File[]
		 */
		$output = [];

		try {
			if (isset($files) and is_array($files) and isset($files['name']) and is_array($files['name']) and count($files['name'])) {
				foreach ($files['name'] as $i => $file) {
					if ($files['error'][$i]) {
						throw new \Exception(isset(Helper::$upload_errors[$files['error'][$i]]) ? Helper::$upload_errors[$files['error'][$i]] : 'Error', $files['error'][$i]);
					}

					$path     = $source->getPath();
					$tmp_name = $files['tmp_name'][$i];
					$new_path = $path . Helper::makeSafe($files['name'][$i]);

					if (!move_uploaded_file($tmp_name, $new_path)) {
						if (!is_writable($path)) {
							throw new \Exception('Destination directory is not writeble', Consts::ERROR_CODE_IS_NOT_WRITEBLE);
						}

						throw new \Exception('No files have been uploaded', Consts::ERROR_CODE_NO_FILES_UPLOADED);
					}

					$file = new File($new_path);

					try {
						$this->accessControl->checkPermission($this->getUserRole(), $this->action, $source->getRoot(), pathinfo($file->getPath(), PATHINFO_EXTENSION));
					} catch (\Exception $e) {
						$file->remove();
						throw $e;
					}

					if (!$file->isGoodFile($source)) {
						$file->remove();
						throw new \Exception('File type is not in white list', Consts::ERROR_CODE_FORBIDDEN);
					}

					if ($source->maxFileSize and $file->getSize() > Helper::convertToBytes($source->maxFileSize)) {
						$file->remove();
						throw new \Exception('File size exceeds the allowable', Consts::ERROR_CODE_FORBIDDEN);
					}

					$output[] = $file;
				}
			}
		} catch (\Exception $e) {
			foreach ($output as $file) {
				$file->remove();
			}
			throw $e;
		}

		return $output;
	}
851260
private function getFileContents($source)
    {
        $this->assertSourceExists($source);
        $this->assertSourceIsNotFolder($source);
        $content = file_get_contents($source, true);

        $this->assertContentIsProperLoaded($source, $content);
        $this->assertContentIsNotEmpty($source, $content);

        return $content;
    }
776309
public function findSources(string $sources): array
  {
    $patterns = $this->sourcesToPatterns($sources);

    $sources = [];
    foreach ($patterns as $pattern)
    {
      $tmp     = $this->findSourcesInPattern($pattern);
      $sources = array_merge($sources, $tmp);
    }

    $sources = array_unique($sources);
    sort($sources);

    return $sources;
  }
420541
public function get_file_reference($source) {
        if ($source && $this->has_moodle_files()) {
            $params = @json_decode(base64_decode($source), true);
            if (!is_array($params) || empty($params['contextid'])) {
                throw new repository_exception('invalidparams', 'repository');
            }
            $params = array(
                'component' => empty($params['component']) ? ''   : clean_param($params['component'], PARAM_COMPONENT),
                'filearea'  => empty($params['filearea'])  ? ''   : clean_param($params['filearea'], PARAM_AREA),
                'itemid'    => empty($params['itemid'])    ? 0    : clean_param($params['itemid'], PARAM_INT),
                'filename'  => empty($params['filename'])  ? null : clean_param($params['filename'], PARAM_FILE),
                'filepath'  => empty($params['filepath'])  ? null : clean_param($params['filepath'], PARAM_PATH),
                'contextid' => clean_param($params['contextid'], PARAM_INT)
            );
            // Check if context exists.
            if (!context::instance_by_id($params['contextid'], IGNORE_MISSING)) {
                throw new repository_exception('invalidparams', 'repository');
            }
            return file_storage::pack_reference($params);
        }
        return $source;
    }
732596
public function normalize($source)
    {
        $fileSystem = new Filesystem();

        // if the source is a file info, it must exists and be readable
        if ($source instanceof SplFileInfo) {

            if (!$fileSystem->exists($source->getRealPath())) {
                throw new Exception('Unable to find '.$source.' during normalization process');
            }

            // the source is already normalized
            return $source;
        }

        // if the source is not an instance of SplInfo, it should be a string
        if (!is_string($source)) {
            throw new Exception(
                'The source should be a string if it is not an instance of SplInfo (instead of '.gettype($source).')'
            );
        }
        $path = $source;

        // if the file does not exists, try to add the application path before
        if (!$fileSystem->exists($source)) {

            if (!$fileSystem->exists($this->applicationPath.'/'.$source)) {
                throw new Exception(
                    'File '.$source.' not found, searched in '
                    .implode(', ', [$source, $this->applicationPath.'/'.$source])
                );
            }
            $path = $this->applicationPath.'/'.$source;
        }
        // normalize source using SplInfo
        $source = new SplFileInfo($path);

        return $source;
    }
1165310
public static function mergeConfigurations($target, $source)
    {
        foreach (['attributes', 'entities', 'relationships', 'autocode', 'languages', 'frameworks', 'orms'] as $configurationPart) {
            if (isset($source[$configurationPart])) {
                $target[$configurationPart] = self::mergeArrays($target[$configurationPart], $source[$configurationPart]);
            }
        }

        return $target;
    }
1334004
public function joinToSql(string $source = null): array
    {
        $sql = $params = [];

        foreach ($this->join as $join) {
            $join = $this->prepareJoin($join);

            if ($source != $join['source']) {
                continue;
            }

            $sqlPart = ($join['type'] ? $join['type'] . ' ' : '') . 'JOIN ' . $join['table'];

            $join['alias'] && $sqlPart .= ' AS ' . $join['alias'];

            $join['on'] && $sqlPart .= ' ON ' . $join['on'];

            $params = array_merge($params, $join['params']);

            $sql[] = $sqlPart;
        }

        $sql = implode(' ', $sql);

        return [$sql, $params];
    }
833405
private function zip($source, $destination)
    {
        if (!extension_loaded('zip')) {
            throw new Exception("ZIP extension not available");
        }

        $source = realpath($source);
        if (!is_dir($source)) {
            throw new FileException("Source must be a directory.");
        }

        $zip = new ZipArchive();
        $shouldOverwrite = $this->isOverwrite() ? ZipArchive::OVERWRITE : 0;
        if (!$zip->open($destination, ZipArchive::CREATE | $shouldOverwrite)) {
            throw new FileException("Couldn't open zip file.");
        }

        /* @var $iterator RecursiveIteratorIterator|RecursiveDirectoryIterator */
        $dirIterator = new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS);
        $iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::SELF_FIRST);
        while ($iterator->valid()) {
            if ($iterator->isDir()) {
                $zip->addEmptyDir($iterator->getSubPathName());
            } else if ($iterator->isFile()) {
                $zip->addFromString($iterator->getSubPathName(), file_get_contents($iterator->key()));
            }
            $iterator->next();
        }

        return $zip->close();
    }
215392
public static function loadExtensionsFiles($files, array $config = []) : array
    {
        $callbacks = [];
        $files     = !is_array($files) ? static::findExtensionsFiles($files) : $files;
        foreach ($files as $file) {
            $item = require  $file;
            if ($item instanceof \Closure) {
                $callbacks[] = $item;
            }
            if (is_array($item)) {
                $config = array_replace_recursive($config, $item);
            }
        }
        foreach ($callbacks as $callback) {
            $config = $callback($config);
        }
        return $config;
    }
6245
public function relGlob($source)
    {
        $list = (array)$this->glob($source);
        foreach ($list as $key => $item) {
            $list[$key] = FS::getRelative($item, $this->root, '/');
        }

        return $list;
    }
1044999
public function readSource($source)
    {
        $document = new \DOMDocument();
        $errorToExceptionContext = new ErrorToExceptionContext(E_WARNING, function () use ($source, $document) {
            $document->loadXML($source);
        });
        $errorToExceptionContext->invoke();

        return $this->readDocument($document);
    }
1144892
public function getAllPhpFilesFromSources(array $sources) : PhpFileSet
    {
        return array_reduce(
            $sources,
            function (PhpFileSet $set, string $source) {
                return $set->addAll($this->find(new \SplFileInfo($source)));
            },
            new PhpFileSet()
        );
    }
803009
protected function parseSource(
        $source,
        DocumentFactoryInterface $documentFactory,
        ElementProcessorInterface $elementProcessor,
        ContextInterface $context
    ) {
        try {
            $parser = new Parser($documentFactory, $elementProcessor, $context);
            $things = $parser->parse($source);
            $gateway = new ThingGateway($this->iri);
            return (object)['items' => $gateway->export($things)];
        } catch (\OutOfBoundsException $e) {
            throw new OutOfBoundsException($e->getMessage(), $e->getCode());
        } catch (\RuntimeException $e) {
            throw new RuntimeException($e->getMessage(), $e->getCode());
        }
    }
497585
public function Concat( $source )
	{

		$source = is_array($source) ? $source : ( $source instanceof Queryable ? $source->toList() : iterator_to_array($source) );

		return $this
					->getClone()
					->setRepository( array_merge( $this->repository , $source ) );

	}
251022
private function getNonExistingFields(Source $source)
    {
        $fields = array();
        $fields += array(
            'send' => array(
                'type' => 'button',
                'value' => $this->t('send_again'),
                'ajax' => array(
                    'service' => 'invoice_add',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => 1,
                ),
            ),
        );
        return $fields;
    }
820841
public static function findFiles(InputInterface $input)
    {
        if ($input->hasParameterOption('--config-file')) {
            $file = $input->getParameterOption('--config-file');
            if (file_exists($file)) {
                return [$file];
            }

            throw new ConfigurationFileNotFoundException(
                sprintf("Couldn't find the configuration file: %s", $file)
            );
        }

        $format = $input->hasParameterOption('--config-format')
            ? $input->getParameterOption('--config-format')
            : static::$DEFAULT_TYPE
        ;

        return [
            sprintf("%s.%s", static::$NAME, $format),
            sprintf("%s.%s.dist", static::$NAME, $format)
        ];
    }
1310056
public function getContent(Smarty_Template_Source $source)
    {
        if ($source->timestamp) {
            return file_get_contents($source->filepath);
        }
        if ($source instanceof Smarty_Config_Source) {
            throw new SmartyException("Unable to read config {$source->type} '{$source->name}'");
        }
        throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
    }