diff --git a/CHANGELOG.md b/CHANGELOG.md index d25f8d1..a2976aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -140,6 +140,13 @@ features. - Removed unused exception `InvalidProjectException` in `\ncc\Exceptions` in favor of `ConfigurationException` - Removed unused exception `InvalidProjectNameException` in `\ncc\Exceptions` in favor of `ConfigurationException` - Removed unused exception `BuildConfigurationNotFoundException` in `\ncc\Exceptions` in favor of `ConfigurationException` + - Removed unused exception `InvalidBuildConfigurationException` in `\ncc\Exceptions` (not used) + - Removed unused exception `InvalidPropertyValue` in `\ncc\Exceptions` in favor of `ConfigurationException` + - Removed unused exception `InvalidVersionConfiguration` in `\ncc\Exceptions` (not used) + - Removed unused exception `InvalidDependencyConfiguraiton` in `\ncc\Exceptions` (not used) + - Removed unused exception `ProjectConfigurationNotFoundException` in `\ncc\Exceptions` in favor of `ConfigurationException` + - Removed unused exception `UndefinedExecutionPolicyExpection` in `\ncc\Exceptions` in favor of `ConfigurationException` + - Removed unused exception `InvalidExecutionPolicyName` in `\ncc\Exceptions` (not used) diff --git a/scratch/exceptions_plan.txt b/scratch/exceptions_plan.txt index 2b2b345..b423d0a 100644 --- a/scratch/exceptions_plan.txt +++ b/scratch/exceptions_plan.txt @@ -6,15 +6,15 @@ ConfigurationException * INVALID_PACKAGE_NAME * INVALID_VERSION_NUMBER * INVALID_PROJECT_NAME - BUILD_CONFIGURATION_NOT_FOUND - INVALID_PROJECT_BUILD_CONFIGURATION - INVALID_PROPERTY_VALUE - INVALID_VERSION_CONFIGURATION - INVALID_BUILD_CONFIGURATION - INVALID_DEPENDENCY_CONFIGURATION - PROJECT_CONFIGURATION_NOT_FOUND - UNDEFINED_EXECUTION_POLICY - INVALID_EXECUTION_POLICY_NAME + * BUILD_CONFIGURATION_NOT_FOUND + * INVALID_PROJECT_BUILD_CONFIGURATION + * INVALID_PROPERTY_VALUE + * INVALID_VERSION_CONFIGURATION + * INVALID_BUILD_CONFIGURATION + * INVALID_DEPENDENCY_CONFIGURATION + * PROJECT_CONFIGURATION_NOT_FOUND + * UNDEFINED_EXECUTION_POLICY + * INVALID_EXECUTION_POLICY_NAME AuthenticationException ACCESS_DENIED @@ -80,7 +80,7 @@ IntegrityException CONSTANT_READ_ONLY INVALID_CONSTANT_NAME COMPONENT_DECODE_EXCEPTION - * RESOURCE_CHECKSUM_EXCEPTION + RESOURCE_CHECKSUM_EXCEPTION AutoLoadException AUTOLOAD_GENERATOR \ No newline at end of file diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index 91dec59..206f836 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -31,7 +31,6 @@ use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\PathNotFoundException; use ncc\Exceptions\ProjectAlreadyExistsException; - use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Managers\ProjectManager; use ncc\Objects\CliHelpSection; use ncc\Objects\ProjectConfiguration\Compiler; @@ -45,10 +44,10 @@ * * @param $args * @return void + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException * @throws PathNotFoundException - * @throws ProjectConfigurationNotFoundException */ public static function start($args): void { @@ -65,10 +64,10 @@ * * @param $args * @return void + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException * @throws PathNotFoundException - * @throws ProjectConfigurationNotFoundException */ public static function createProject($args): void { diff --git a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php index d4aba9a..d6c891b 100644 --- a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php +++ b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php @@ -1,26 +1,26 @@ Authors) && count($composer_package->Authors) > 0) + if(Functions::cbool(!is_null($composer_package->Authors) && count($composer_package->Authors) > 0 && Functions::getConfigurationProperty('composer.extension.display_authors'))) { Console::out(sprintf('Authors for package %s:', $composer_package->Name)); foreach($composer_package->Authors as $author) diff --git a/src/ncc/Classes/NccExtension/PackageCompiler.php b/src/ncc/Classes/NccExtension/PackageCompiler.php index 801390a..3f18be3 100644 --- a/src/ncc/Classes/NccExtension/PackageCompiler.php +++ b/src/ncc/Classes/NccExtension/PackageCompiler.php @@ -32,13 +32,12 @@ use ncc\Classes\PhpExtension\PhpCompiler; use ncc\CLI\Main; use ncc\Exceptions\AccessDeniedException; - use ncc\Exceptions\BuildConfigurationNotFoundException; use ncc\Exceptions\BuildException; + use ncc\Exceptions\ConfigurationException; use ncc\Exceptions\IOException; use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\NotSupportedException; use ncc\Exceptions\PathNotFoundException; - use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\RunnerExecutionException; use ncc\Interfaces\CompilerInterface; use ncc\Managers\ProjectManager; @@ -60,13 +59,12 @@ * @param string $build_configuration * @return string * @throws AccessDeniedException - * @throws BuildConfigurationNotFoundException * @throws BuildException + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException * @throws NotSupportedException * @throws PathNotFoundException - * @throws ProjectConfigurationNotFoundException */ public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DEFAULT): string { @@ -205,8 +203,8 @@ * @param ProjectConfiguration $configuration * @param string $build_configuration * @return string - * @throws BuildConfigurationNotFoundException * @throws IOException + * @throws ConfigurationException */ public static function writePackage(string $path, Package $package, ProjectConfiguration $configuration, string $build_configuration=BuildConfigurationValues::DEFAULT): string { diff --git a/src/ncc/Classes/PhpExtension/PhpCompiler.php b/src/ncc/Classes/PhpExtension/PhpCompiler.php index ec87bfd..8f9a0c6 100644 --- a/src/ncc/Classes/PhpExtension/PhpCompiler.php +++ b/src/ncc/Classes/PhpExtension/PhpCompiler.php @@ -1,24 +1,24 @@ project_file_path) && !is_file($this->project_file_path)) { - throw new ProjectConfigurationNotFoundException('The project configuration file \'' . $this->project_file_path . '\' was not found'); + throw new ConfigurationException('The project configuration file \'' . $this->project_file_path . '\' was not found'); } $this->project_configuration = ProjectConfiguration::fromFile($this->project_file_path); @@ -250,10 +248,10 @@ * Returns the ProjectConfiguration object * * @return ProjectConfiguration + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException * @throws PathNotFoundException - * @throws ProjectConfigurationNotFoundException */ public function getProjectConfiguration(): ProjectConfiguration { @@ -282,13 +280,12 @@ * @param string $build_configuration * @return string * @throws AccessDeniedException - * @throws BuildConfigurationNotFoundException * @throws BuildException + * @throws ConfigurationException * @throws IOException * @throws MalformedJsonException - * @throws PathNotFoundException - * @throws ProjectConfigurationNotFoundException * @throws NotSupportedException + * @throws PathNotFoundException */ public function build(string $build_configuration=BuildConfigurationValues::DEFAULT): string { diff --git a/src/ncc/Objects/ProjectConfiguration.php b/src/ncc/Objects/ProjectConfiguration.php index 75cfa13..849a869 100644 --- a/src/ncc/Objects/ProjectConfiguration.php +++ b/src/ncc/Objects/ProjectConfiguration.php @@ -26,16 +26,11 @@ use Exception; use ncc\Enums\Options\BuildConfigurationValues; - use ncc\Exceptions\BuildConfigurationNotFoundException; use ncc\Exceptions\ConfigurationException; - use ncc\Exceptions\InvalidConstantNameException; - use ncc\Exceptions\InvalidProjectBuildConfiguration; - use ncc\Exceptions\InvalidPropertyValueException; use ncc\Exceptions\IOException; use ncc\Exceptions\MalformedJsonException; + use ncc\Exceptions\NotSupportedException; use ncc\Exceptions\PathNotFoundException; - use ncc\Exceptions\RuntimeException; - use ncc\Exceptions\UndefinedExecutionPolicyException; use ncc\Interfaces\BytecodeObjectInterface; use ncc\Objects\ProjectConfiguration\Assembly; use ncc\Objects\ProjectConfiguration\Build; @@ -102,11 +97,8 @@ * * @param bool $throw_exception * @return bool - * @throws BuildConfigurationNotFoundException * @throws ConfigurationException - * @throws InvalidPropertyValueException - * @throws RuntimeException - * @throws UndefinedExecutionPolicyException + * @throws NotSupportedException */ public function validate(bool $throw_exception=True): bool { @@ -146,7 +138,7 @@ { if($throw_exception) { - throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main uses an execution policy "%s" but no policies are defined', $this->build->main)); + throw new ConfigurationException(sprintf('Build configuration build.main uses an execution policy "%s" but no policies are defined', $this->build->main)); } return false; @@ -167,7 +159,7 @@ { if($throw_exception) { - throw new UndefinedExecutionPolicyException(sprintf('Build configuration build.main points to a undefined execution policy "%s"', $this->build->main)); + throw new ConfigurationException(sprintf('Build configuration build.main points to a undefined execution policy "%s"', $this->build->main)); } return false; } @@ -208,8 +200,7 @@ * * @param string $build_configuration * @return array - * @throws BuildConfigurationNotFoundException - * @throws UndefinedExecutionPolicyException + * @throws ConfigurationException */ public function getRequiredExecutionPolicies(string $build_configuration=BuildConfigurationValues::DEFAULT): array { @@ -244,7 +235,7 @@ { if(!in_array($unit, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The property \'' . $key . '\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); + throw new ConfigurationException('The property \'' . $key . '\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); } if(!in_array($unit, $required_policies, true)) @@ -261,7 +252,7 @@ { if(!in_array($unit, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The property \'build.pre_build\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); + throw new ConfigurationException('The property \'build.pre_build\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); } if(!in_array($unit, $required_policies, true)) @@ -277,7 +268,7 @@ { if(!in_array($unit, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The property \'build.pre_build\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); + throw new ConfigurationException('The property \'build.pre_build\' in the project configuration calls for an undefined execution policy \'' . $unit . '\''); } if(!in_array($unit, $required_policies, true)) @@ -328,7 +319,7 @@ { if(!in_array($execution_policy?->exit_handlers->success->run, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->success->run . '\''); + throw new ConfigurationException('The execution policy \'' . $execution_policy?->name . '\' Success exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->success->run . '\''); } if(!in_array($execution_policy?->exit_handlers->success->run, $required_policies, true)) @@ -341,7 +332,7 @@ { if(!in_array($execution_policy?->exit_handlers->warning->run, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->warning->run . '\''); + throw new ConfigurationException('The execution policy \'' . $execution_policy?->name . '\' Warning exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->warning->run . '\''); } if(!in_array($execution_policy?->exit_handlers->warning->run, $required_policies, true)) @@ -354,7 +345,7 @@ { if(!in_array($execution_policy?->exit_handlers->error->run, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The execution policy \'' . $execution_policy?->name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->error->run . '\''); + throw new ConfigurationException('The execution policy \'' . $execution_policy?->name . '\' Error exit handler points to a undefined execution policy \'' . $execution_policy?->exit_handlers->error->run . '\''); } if(!in_array($execution_policy?->exit_handlers->error->run, $required_policies, true)) @@ -407,7 +398,7 @@ * @param BuildConfiguration $configuration * @param array $defined_polices * @return array - * @throws UndefinedExecutionPolicyException + * @throws ConfigurationException */ private function processBuildPolicies(BuildConfiguration $configuration, array $defined_polices): array { @@ -419,7 +410,7 @@ { if (!in_array($unit, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->name . '\' calls for an undefined execution policy \'' . $unit . '\''); + throw new ConfigurationException(sprintf("The property 'pre_build' in the build configuration '%s' calls for an undefined execution policy '%s'", $configuration->name, $unit)); } $required_policies[] = $unit; @@ -432,7 +423,7 @@ { if (!in_array($unit, $defined_polices, true)) { - throw new UndefinedExecutionPolicyException('The property \'pre_build\' in the build configuration \'' . $configuration->name . '\' calls for an undefined execution policy \'' . $unit . '\''); + throw new ConfigurationException(sprintf("The property 'post_build' in the build configuration '%s' calls for an undefined execution policy '%s'", $configuration->name, $unit)); } $required_policies[] = $unit; diff --git a/src/ncc/Objects/ProjectConfiguration/Build.php b/src/ncc/Objects/ProjectConfiguration/Build.php index fc797f3..7f0f4be 100644 --- a/src/ncc/Objects/ProjectConfiguration/Build.php +++ b/src/ncc/Objects/ProjectConfiguration/Build.php @@ -25,7 +25,6 @@ namespace ncc\Objects\ProjectConfiguration; use ncc\Enums\Options\BuildConfigurationValues; - use ncc\Exceptions\BuildConfigurationNotFoundException; use ncc\Exceptions\ConfigurationException; use ncc\Interfaces\BytecodeObjectInterface; use ncc\Objects\ProjectConfiguration\Build\BuildConfiguration; @@ -170,7 +169,6 @@ * * @param bool $throw_exception * @return bool - * @throws BuildConfigurationNotFoundException * @throws ConfigurationException */ public function validate(bool $throw_exception=True): bool @@ -256,7 +254,7 @@ * * @param string $name * @return BuildConfiguration - * @throws BuildConfigurationNotFoundException + * @throws ConfigurationException */ public function getBuildConfiguration(string $name): BuildConfiguration { @@ -273,7 +271,7 @@ } } - throw new BuildConfigurationNotFoundException('The build configuration ' . $name . ' does not exist'); + throw new ConfigurationException(sprintf('The build configuration "%s" does not exist', $name)); } /** diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index 53b639e..91a017d 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -28,7 +28,6 @@ use ncc\Enums\CompilerExtensions; use ncc\Enums\CompilerExtensionSupportedVersions; use ncc\Exceptions\ConfigurationException; - use ncc\Exceptions\InvalidPropertyValueException; use ncc\Exceptions\NotSupportedException; use ncc\Interfaces\BytecodeObjectInterface; use ncc\ThirdParty\jelix\Version\VersionComparator; @@ -67,7 +66,6 @@ * @param bool $throw_exception * @return bool * @throws ConfigurationException - * @throws InvalidPropertyValueException * @throws NotSupportedException */ public function validate(bool $throw_exception=True): bool @@ -76,7 +74,7 @@ { if($throw_exception) { - throw new InvalidPropertyValueException('The property \'extension\' must not be null.'); + throw new ConfigurationException('The property \'extension\' must not be null.'); } return False; @@ -86,7 +84,7 @@ { if($throw_exception) { - throw new InvalidPropertyValueException('The property \'minimum_version\' must not be null.'); + throw new ConfigurationException('The property \'minimum_version\' must not be null.'); } return False; @@ -96,7 +94,7 @@ { if($throw_exception) { - throw new InvalidPropertyValueException('The property \'maximum_version\' must not be null.'); + throw new ConfigurationException('The property \'maximum_version\' must not be null.'); } return False; diff --git a/src/ncc/Objects/ProjectConfiguration/Project.php b/src/ncc/Objects/ProjectConfiguration/Project.php index f52d7ad..63a1723 100644 --- a/src/ncc/Objects/ProjectConfiguration/Project.php +++ b/src/ncc/Objects/ProjectConfiguration/Project.php @@ -24,8 +24,8 @@ namespace ncc\Objects\ProjectConfiguration; - use ncc\Exceptions\InvalidPropertyValueException; - use ncc\Exceptions\RuntimeException; + use ncc\Exceptions\ConfigurationException; + use ncc\Exceptions\NotSupportedException; use ncc\Interfaces\BytecodeObjectInterface; use ncc\Utilities\Functions; @@ -64,8 +64,8 @@ * * @param bool $throw_exception * @return bool - * @throws InvalidPropertyValueException - * @throws RuntimeException + * @throws ConfigurationException + * @throws NotSupportedException */ public function validate(bool $throw_exception=True): bool {