diff --git a/src/ncc/Enums/CompilerExtensions.php b/src/ncc/Enums/CompilerExtensions.php index 0c280d6..04fcc60 100644 --- a/src/ncc/Enums/CompilerExtensions.php +++ b/src/ncc/Enums/CompilerExtensions.php @@ -22,11 +22,7 @@ namespace ncc\Enums; - final class CompilerExtensions + enum CompilerExtensions : string { - public const PHP = 'php'; - - public const ALL = [ - CompilerExtensions::PHP - ]; + case PHP = 'php'; } \ No newline at end of file diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index e84f69e..c33b5a8 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -160,7 +160,7 @@ return match (strtolower($this->project_configuration->getProject()->getCompiler()->getExtension())) { - CompilerExtensions::PHP => match (strtolower($configuration->getBuildType())) + CompilerExtensions::PHP->value => match (strtolower($configuration->getBuildType())) { BuildOutputType::NCC_PACKAGE => (new NccCompiler($this))->build($build_configuration, $options), BuildOutputType::EXECUTABLE => (new ExecutableCompiler($this))->build($build_configuration, $options), @@ -258,7 +258,7 @@ { return match ($this->getProjectConfiguration()->getProject()->getCompiler()->getExtension()) { - CompilerExtensions::PHP => ComponentFileExtensions::PHP, + CompilerExtensions::PHP->value => ComponentFileExtensions::PHP, default => throw new NotSupportedException( sprintf('The compiler extension \'%s\' is not supported', $this->getProjectConfiguration()->getProject()->getCompiler()->getExtension()) ), @@ -485,7 +485,7 @@ throw new IOException(sprintf('Project source directory "%s" was not created', $project_src)); } - $project = new ProjectConfiguration\Project(new ProjectConfiguration\Compiler(CompilerExtensions::PHP)); + $project = new ProjectConfiguration\Project(new ProjectConfiguration\Compiler(CompilerExtensions::PHP->value)); $assembly = new ProjectConfiguration\Assembly( Resolver::composerName($composer_json->getName()), Resolver::composerNameToPackage($composer_json->getName()), diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index b2017d5..a118006 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -77,7 +77,7 @@ /** @noinspection DegradedSwitchInspection */ switch($extension) { - case CompilerExtensions::PHP: + case CompilerExtensions::PHP->value: if($minimum_version === null) { @@ -185,7 +185,8 @@ } /** @noinspection InArrayMissUseInspection */ - if(!in_array($this->extension, CompilerExtensions::ALL, true)) + // TODO: Fix this, not a proper use of cases() + if(!in_array($this->extension, CompilerExtensions::cases(), true)) { throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported'); }