function Comparer::doCompare
File
-
vendor/
composer/ composer/ src/ Composer/ Package/ Comparer/ Comparer.php, line 81
Class
- Comparer
- class Comparer
Namespace
Composer\Package\ComparerCode
public function doCompare() : void {
$source = [];
$destination = [];
$this->changed = [];
$currentDirectory = Platform::getCwd();
chdir($this->source);
$source = $this->doTree('.', $source);
if (!is_array($source)) {
return;
}
chdir($currentDirectory);
chdir($this->update);
$destination = $this->doTree('.', $destination);
if (!is_array($destination)) {
exit;
}
chdir($currentDirectory);
foreach ($source as $dir => $value) {
foreach ($value as $file => $hash) {
if (isset($destination[$dir][$file])) {
if ($hash !== $destination[$dir][$file]) {
$this->changed['changed'][] = $dir . '/' . $file;
}
}
else {
$this->changed['removed'][] = $dir . '/' . $file;
}
}
}
foreach ($destination as $dir => $value) {
foreach ($value as $file => $hash) {
if (!isset($source[$dir][$file])) {
$this->changed['added'][] = $dir . '/' . $file;
}
}
}
}