From fb1d7655f16e4d584fc765d1ca2e490a9b0581be Mon Sep 17 00:00:00 2001 From: jubianchi Date: Sat, 20 Jan 2018 09:16:06 +0100 Subject: [PATCH] fix: Versions correctly merged and checked Closes #28 --- src/application.php | 7 +++++++ src/functions.php | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/src/application.php b/src/application.php index fc2bc34..239b98b 100644 --- a/src/application.php +++ b/src/application.php @@ -50,11 +50,18 @@ $application->register('render') } $configuration = readConfiguration($inputFile); + $configurationVersion = (string) ($configuration['version'] ?? 1); if (!$input->getOption('ignore-override') && file_exists($overrideFile)) { $override = readConfiguration($overrideFile); + $overrideVersion = (string) ($override['version'] ?? 1); + + if ($configurationVersion !== $overrideVersion) { + throw new Console\Exception\LogicException('Version mismatch: file ' . $inputFile . ' specifies version ' . $configurationVersion . ' but file ' . $overrideFile . ' uses version ' . $overrideVersion); + } $configuration = array_merge_recursive($configuration, $override); + $configuration['version'] = $configurationVersion; } $services = fetchServices($configuration); diff --git a/src/functions.php b/src/functions.php index 8dbf7b2..6b94b3c 100644 --- a/src/functions.php +++ b/src/functions.php @@ -28,6 +28,15 @@ function readConfiguration(string $path) : array } } +function validateVersion(array $configuration) : array +{ + if (isset($configuration['version']) === false) { + return true; + } + + +} + /** * @public *