Skip to content

Commit

Permalink
changed Plugin::addFiles: renamed from processFiles and reversed or…
Browse files Browse the repository at this point in the history
…der of `defines`
  • Loading branch information
hiqsol committed Apr 11, 2017
1 parent 66521da commit dc0397a
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protected function processPackage(CompletePackageInterface $package)
}

if (is_array($files)) {
$this->processFiles($package, $files);
$this->addFiles($package, $files);
}
if ($package instanceof RootPackageInterface) {
$this->loadDotEnv($package);
Expand All @@ -175,14 +175,30 @@ protected function loadDotEnv(RootPackageInterface $package)
}
}

protected function processFiles(CompletePackageInterface $package, array $files)
/**
* Adds given files to the list of files to be processed.
* Prepares `defines` in reversed order (outer package first) because
* constants cannot be redefined.
* @param CompletePackageInterface $package
* @param array $files
*/
protected function addFiles(CompletePackageInterface $package, array $files)
{
foreach ($files as $name => $paths) {
foreach ((array) $paths as $path) {
$paths = (array) $paths;
if ($name === 'defines') {
$paths = array_reverse($paths);
}
foreach ($paths as $path) {
if (!isset($this->files[$name])) {
$this->files[$name] = [];
}
array_push($this->files[$name], $this->preparePath($package, $path));
$path = $this->preparePath($package, $path);
if ($name === 'defines') {
array_unshift($this->files[$name], $path);
} else {
array_push($this->files[$name], $path);
}
}
}
}
Expand Down

0 comments on commit dc0397a

Please sign in to comment.