From dc0397a5dc28a7d205de7cd302ead9f6a41fd31b Mon Sep 17 00:00:00 2001 From: Andrii Vasyliev Date: Tue, 11 Apr 2017 16:38:55 +0200 Subject: [PATCH] changed `Plugin::addFiles`: renamed from processFiles and reversed order of `defines` --- src/Plugin.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 057f36a..33987c0 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -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); @@ -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); + } } } }