Convert CompilerExtensions constants to enum cases
This commit is contained in:
parent
baf11f5cb9
commit
d884d0fbda
3 changed files with 8 additions and 11 deletions
|
@ -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';
|
||||
}
|
|
@ -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()),
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue