From 3adc1b81fbaad5a4c4b263237a39cee886c34a3e Mon Sep 17 00:00:00 2001 From: netkas Date: Wed, 18 Sep 2024 15:20:04 -0400 Subject: [PATCH] Improve error handling for compiler extensions --- src/ncc/Objects/ProjectConfiguration/Compiler.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index 318a9da..1c12dff 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -103,7 +103,6 @@ */ public function getExtension(): CompilerExtensions { - // TODO: Update usages from here return $this->extension; } @@ -243,9 +242,12 @@ throw new ConfigurationException('The property \'project.compiler.extension\' must not be null.'); } - return new self(Functions::array_bc($data, 'extension'), - Functions::array_bc($data, 'maximum_version'), - Functions::array_bc($data, 'minimum_version') - ); + $extension = CompilerExtensions::tryFrom(Functions::array_bc($data, 'extension')); + if($extension === null) + { + throw new ConfigurationException('The property \'project.compiler.extension\' is not a valid extension'); + } + + return new self($extension, Functions::array_bc($data, 'maximum_version'), Functions::array_bc($data, 'minimum_version')); } } \ No newline at end of file