@param  array<string>  $diff_files

@return array<string, string>
171911
public function getReferencedFilesFromDiff(array $diff_files, bool $include_referencing_files = true)
    {
        $all_inherited_files_to_check = $diff_files;

        while ($diff_files) {
            $diff_file = array_shift($diff_files);

            $dependent_files = $this->file_reference_provider->getFilesInheritingFromFile($diff_file);

            $new_dependent_files = array_diff($dependent_files, $all_inherited_files_to_check);

            $all_inherited_files_to_check = array_merge($all_inherited_files_to_check, $new_dependent_files);
            $diff_files = array_merge($diff_files, $new_dependent_files);
        }

        $all_files_to_check = $all_inherited_files_to_check;

        if ($include_referencing_files) {
            foreach ($all_inherited_files_to_check as $file_name) {
                $dependent_files = $this->file_reference_provider->getFilesReferencingFile($file_name);
                $all_files_to_check = array_merge($dependent_files, $all_files_to_check);
            }
        }

        return array_combine($all_files_to_check, $all_files_to_check);
    }
1305442
public static function getFiles()
    {
        if (self::$_files === null) {
            self::$_files = [];
            if (isset($_FILES) && is_array($_FILES)) {
                foreach ($_FILES as $class => $info) {
                    self::getUploadFilesRecursive($class, $info['name'], $info['error']);
                }
            }
        }
        return self::$_files;
    }
967155
def files_array(files)
      return [] unless files
      files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)
    end
1075524
private static function normaliseMultiFile(array $files)
    {
        $output = [];
        /* Second parcour. */
        foreach (array_keys($files) as $value) {
            self::normaliseFile($output, $files[ $value ], $value);
        }

        return $output;
    }
1273098
public function preCommitHook($changed_files) {
    $collection = $this->collectionBuilder();
    $collection->setProgressIndicator(NULL);
    $collection->addCode(
      function () use ($changed_files) {
        return $this->invokeCommands([
          'tests:phpcs:sniff:files' => ['file_list' => $changed_files],
          'tests:twig:lint:files' => ['file_list' => $changed_files],
          'tests:yaml:lint:files' => ['file_list' => $changed_files],
        ]);
      }
    );

    $changed_files_list = explode("\n", $changed_files);
    if (in_array('composer.json', $changed_files_list)
      || in_array('composer.lock', $changed_files_list)) {
      $collection->addCode(
        function () use ($changed_files) {
          return $this->invokeCommand('tests:composer:validate');
        }
      );
    }

    $result = $collection
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->run();

    if ($result->wasSuccessful()) {
      $this->say("<info>Your local code has passed git pre-commit validation.</info>");
    }

    return $result;
  }
546956
private function getHunkStartTokens(string $diffLine): array
    {
        $tokenList = [];

        if (preg_match(self::HUNK_START_REGEX, $diffLine, $matches)) {
            // File deletion
            if ($this->hasToken($matches, Token::FILE_DELETION_LINE_COUNT)) {
                $tokenList = [
                    new Token(Token::FILE_DELETION_LINE_COUNT, $matches[Token::FILE_DELETION_LINE_COUNT]),
                    new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]),
                    new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT])
                ];

            // File creation
            } elseif ($this->hasToken($matches, Token::FILE_CREATION_LINE_COUNT)) {
                $tokenList = [
                    new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]),
                    new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]),
                    new Token(Token::FILE_CREATION_LINE_COUNT, $matches[Token::FILE_CREATION_LINE_COUNT]),
                ];

            // Standard Case
            } else {
                $tokenList = [
                    new Token(Token::HUNK_ORIGINAL_START, $matches[Token::HUNK_ORIGINAL_START]),
                    new Token(Token::HUNK_ORIGINAL_COUNT, $matches[Token::HUNK_ORIGINAL_COUNT]),
                    new Token(Token::HUNK_NEW_START, $matches[Token::HUNK_NEW_START]),
                    new Token(Token::HUNK_NEW_COUNT, $matches[Token::HUNK_NEW_COUNT])
                ];
            }
        }

        return $tokenList;
    }
400603
public function getDiff(array $files = null, $staged = false)
    {
        $diffs = array();

        if (is_null($files)) {
            $files    = array();
            $status   = $this->getStatus();
            $modified = ($staged ? 'x' : 'y');

            foreach ($status as $entry) {
               if ($entry[$modified] !== 'M') {
                        continue;
                }

                $files[] = $entry['file'];
            }
        }

        $files = array_map(array($this, 'resolveLocalPath'), $files);

        foreach ($files as $file) {
            $args = array();

            if ($staged) {
                $args[] = '--staged';
            }

            $args[] = $this->translatePathspec($file);

            /** @var CallResult $result */
            $result = $this->getGit()->{'diff'}($this->getRepositoryPath(), $args);
            $result->assertSuccess(sprintf('Cannot show diff for %s from "%s"',
                $file, $this->getRepositoryPath()
            ));

            $diffs[$file] = $result->getStdOut();
        }

        return $diffs;
    }
249117
private function getFiles()
    {
        $process = new Process('git diff --cached --name-status --diff-filter=ACMR');
        $process->run();

        if ($process->isSuccessful()) {
            return array_filter(explode("\n", $process->getOutput()));
        }

        return [];
    }
1057724
public static function getArrayDiffRecursively($array1, $array2)
    {
        $diff_array = [];

        // value 비교
        if (!is_array($array1)) {
            if ($array1 != $array2) {
                return $array1;
            } else {
                return [];
            }
        }

        // array 비교
        foreach ($array1 as $key => $value) {
            if (is_array($value)) {
                if (!is_array($array2[$key])) {
                    $diff_array[$key] = $value;
                } else {
                    $sub_diff_array = ArrayUtils::getArrayDiffRecursively($value, $array2[$key]);
                    if (count($sub_diff_array)) {
//                        $diff_array[$key] = $sub_diff_array;
                        $diff_array[$key] = $value;
                    }
                }
            } elseif ($array2[$key] != $value) {
                $diff_array[$key] = $value;
            }
        }
        return $diff_array;
    }
1198103
private static function getDirFiles($absolute_dir, $relative_dir, &$files) {
        $handler = opendir($absolute_dir);
        if ( $handler != false ) {
            while ( $filename = readdir($handler) ) {
                if ( $filename != "." && $filename != ".." ) {
                    if ( is_dir($absolute_dir."/".$filename) ) {
                        self::getDirFiles($absolute_dir."/".$filename, $relative_dir.$filename."/", $files);
                    } else {
                        $files[] = $relative_dir.$filename;
                    }
                }
            }
            closedir($handler);
        }
    }
748943
function diff () {
  const files = getConfigFiles()

  debug('diff files: %o', files)

  const output = []

  files.forEach(f => {
    const result = jsDiff.structuredPatch(f[0].name, f[1].name, f[0].content, f[1].content)

    debug('diff result: %o', result)

    output.push('-------------------------------------------------\n')
    // eslint-disable-next-line max-len
    output.push(`diff ${chalk.blue(result.newFileName)} ${chalk.blue(result.oldFileName)}\n`)
    output.push('-------------------------------------------------\n')

    result.hunks.forEach(hunk => {
      fillLineNumber(hunk)

      const lines = hunk.lines.map(line => {
        if (line.startsWith('+')) {
          return chalk.green(line)
        }
        if (line.startsWith('-')) {
          return chalk.red(line)
        }
        return line
      })

      output.push(lines.join('\n'))
      output.push('\n')
    })

    output.push('\n')
  })

  console.log(output.join(''))
}
1041069
public function createUploadedFilesFromArray(array $files)
    {
        $uploadedFiles = [];

        if (isset($files['tmp_name']) && ! is_array($files['tmp_name'])) {
            $uploadedFiles[] = $this->createUploadedFile(
                $files['tmp_name'],
                $files['size'],
                $files['error'],
                $files['name'],
                $files['type']
            );
        } elseif (isset($files['tmp_name']) && is_array($files['tmp_name'])) {
            foreach ($files['tmp_name'] as $key => $file) {
                $uploadedFiles[] = $this->createUploadedFile(
                    $file,
                    $files['size'][$key],
                    $files['error'][$key],
                    $files['name'][$key],
                    $files['type'][$key]
                );
            }
        } else {
            foreach ($files as $key => $value) {
                $uploadedFiles[$key] = $this->createUploadedFilesFromArray($value);
            }
        }

        return $uploadedFiles;
    }
905331
public function getConflicts(array $files)
    {
        $conflicts = array();

        // flip so the files are hash keys to speed lookups
        $files = array_flip($files);

        $fileInfo = $this->getFileInfo();

        foreach ($files as $file => $garbage) {
            if (array_key_exists($file, $fileInfo)) {
                $fileFileInfo = $fileInfo[$file];
                if (isset($fileFileInfo['Conflicts'])
                    && is_array($fileFileInfo['Conflicts'])
                ) {
                    foreach ($fileFileInfo['Conflicts'] as $conflict) {
                        if (array_key_exists($conflict, $files)) {
                            if (!isset($conflicts[$file])) {
                                $conflicts[$file] = array();
                            }
                            $conflicts[$file][] = $conflict;
                        }
                    }
                }
            }
        }

        return $conflicts;
    }
963059
protected function convertToUploadedFileObjects(array $files): array
	{
		$uploadedFiles = [];

		foreach($files as $name => $file)
		{
			if(is_array($file['name']))
			{
				foreach($this->normalizeMultiUpload($file) as $file)
				{
					$uploadedFiles[$name][] = $this->createUploadedFile($file);
				}
			}
			else
			{
				$uploadedFiles[$name] = $this->createUploadedFile($file);
			}
		}

		return $uploadedFiles;
	}
374756
private static function convertFilesArray($files) {
		
		$result = [];

		foreach($files as $field => $data) {
			
			foreach($data as $key => $val) {
				
				$result[$field] = [];
				
				if(false === is_array($val)) {
					$result[$field] = $data;
				} 
				else {
					
					$res = [];
					static :: filesFlip($res, [], $data);
					$result[$field] += $res;
				}
			}
		}

		return $result;
	}
311447
public static function multiple(
        array $files
    ) {
        $out = [];
        foreach ($files as $file) {
            $out[] = static::info($file);
        }

        return $out;
    }
172367
public function readDiffLogs(array $logs)
    {
        $diffs = array();
        $lineNumOld = 0;
        $lineNumNew = 0;
        foreach ($logs as $log) {
            if ('diff' === substr($log, 0, 4)) {
                if (isset($diff)) {
                    $diffs[] = $diff;
                }

                $diff = new Diff();
                if (preg_match('/^diff --[\S]+ a\/?(.+) b\/?/', $log, $name)) {
                    $diff->setFile($name[1]);
                }
                continue;
            }

            if ('index' === substr($log, 0, 5)) {
                $diff->setIndex($log);
                continue;
            }

            if ('---' === substr($log, 0, 3)) {
                $diff->setOld($log);
                continue;
            }

            if ('+++' === substr($log, 0, 3)) {
                $diff->setNew($log);
                continue;
            }

            // Handle binary files properly.
            if ('Binary' === substr($log, 0, 6)) {
                $m = array();
                if (preg_match('/Binary files (.+) and (.+) differ/', $log, $m)) {
                    $diff->setOld($m[1]);
                    $diff->setNew("    {$m[2]}");
                }
            }

            if (!empty($log)) {
                switch ($log[0]) {
                    case '@':
                        // Set the line numbers
                        preg_match('/@@ -([0-9]+)/', $log, $matches);
                        $lineNumOld = $matches[1] - 1;
                        $lineNumNew = $matches[1] - 1;
                        break;
                    case '-':
                        $lineNumOld++;
                        break;
                    case '+':
                        $lineNumNew++;
                        break;
                    default:
                        $lineNumOld++;
                        $lineNumNew++;
                }
            } else {
                $lineNumOld++;
                $lineNumNew++;
            }

            if ($diff) {
                $diff->addLine($log, $lineNumOld, $lineNumNew);
            }
        }

        if (isset($diff)) {
            $diffs[] = $diff;
        }

        return $diffs;
    }