diff --git a/src/ncc/Abstracts/BuiltinRemoteSourceType.php b/src/ncc/Abstracts/BuiltinRemoteSourceType.php new file mode 100644 index 0000000..7568d42 --- /dev/null +++ b/src/ncc/Abstracts/BuiltinRemoteSourceType.php @@ -0,0 +1,37 @@ +getVersion($version_entry, false); diff --git a/src/ncc/CLI/Management/ProjectMenu.php b/src/ncc/CLI/Management/ProjectMenu.php index 6cfe135..b7ce09e 100644 --- a/src/ncc/CLI/Management/ProjectMenu.php +++ b/src/ncc/CLI/Management/ProjectMenu.php @@ -26,13 +26,20 @@ namespace ncc\CLI\Management; use ncc\Abstracts\CompilerExtensionDefaultVersions; use ncc\Abstracts\CompilerExtensions; use ncc\Abstracts\CompilerExtensionSupportedVersions; + use ncc\Exceptions\AccessDeniedException; + use ncc\Exceptions\DirectoryNotFoundException; + use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\InvalidPackageNameException; use ncc\Exceptions\InvalidProjectNameException; + use ncc\Exceptions\IOException; + use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\ProjectAlreadyExistsException; + use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Managers\ProjectManager; use ncc\Objects\CliHelpSection; use ncc\Objects\ProjectConfiguration\Compiler; use ncc\Utilities\Console; + use ncc\Utilities\Functions; class ProjectMenu { @@ -41,6 +48,12 @@ namespace ncc\CLI\Management; * * @param $args * @return void + * @throws AccessDeniedException + * @throws DirectoryNotFoundException + * @throws FileNotFoundException + * @throws IOException + * @throws MalformedJsonException + * @throws ProjectConfigurationNotFoundException */ public static function start($args): void { @@ -50,13 +63,17 @@ namespace ncc\CLI\Management; } self::displayOptions(); - exit(0); - } /** * @param $args * @return void + * @throws AccessDeniedException + * @throws DirectoryNotFoundException + * @throws FileNotFoundException + * @throws IOException + * @throws MalformedJsonException + * @throws ProjectConfigurationNotFoundException */ public static function createProject($args): void { @@ -93,7 +110,7 @@ namespace ncc\CLI\Management; } // Remove basename from real_src - $real_src = \ncc\Utilities\Functions::removeBasename($real_src, $current_directory); + $real_src = Functions::removeBasename($real_src, $current_directory); // Fetch the rest of the information needed for the project //$compiler_extension = Console::getOptionInput($args, 'ce', 'Compiler Extension (php, java): '); @@ -242,7 +259,7 @@ namespace ncc\CLI\Management; new CliHelpSection(['create-makefile'], 'Generates a Makefile for the project'), ]; - $options_padding = \ncc\Utilities\Functions::detectParametersPadding($options) + 4; + $options_padding = Functions::detectParametersPadding($options) + 4; Console::out('Usage: ncc project {command} [options]'); Console::out('Options:' . PHP_EOL); diff --git a/src/ncc/Classes/BashExtension/BashRunner.php b/src/ncc/Classes/BashExtension/BashRunner.php index ff6ae82..c10b993 100644 --- a/src/ncc/Classes/BashExtension/BashRunner.php +++ b/src/ncc/Classes/BashExtension/BashRunner.php @@ -22,16 +22,11 @@ namespace ncc\Classes\BashExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\FileNotFoundException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class BashRunner implements RunnerInterface { diff --git a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php index f5593a7..a70bb18 100644 --- a/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php +++ b/src/ncc/Classes/ComposerExtension/ComposerSourceBuiltin.php @@ -48,7 +48,6 @@ namespace ncc\Classes\ComposerExtension; use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\RuntimeException; use ncc\Exceptions\UnsupportedCompilerExtensionException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Exceptions\UserAbortedOperationException; use ncc\Interfaces\ServiceSourceInterface; use ncc\Managers\ProjectManager; @@ -99,7 +98,6 @@ namespace ncc\Classes\ComposerExtension; * @throws ProjectConfigurationNotFoundException * @throws RuntimeException * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException * @throws UserAbortedOperationException */ public static function fetch(RemotePackageInput $packageInput): string @@ -138,7 +136,6 @@ namespace ncc\Classes\ComposerExtension; * @throws PackagePreparationFailedException * @throws ProjectConfigurationNotFoundException * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException * @throws UserAbortedOperationException */ public static function fromLocal(string $path): string @@ -196,7 +193,6 @@ namespace ncc\Classes\ComposerExtension; * @throws PackagePreparationFailedException * @throws ProjectConfigurationNotFoundException * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException */ private static function compilePackages(string $composer_lock_path): array { diff --git a/src/ncc/Classes/EnvironmentConfiguration.php b/src/ncc/Classes/EnvironmentConfiguration.php deleted file mode 100644 index ae169e5..0000000 --- a/src/ncc/Classes/EnvironmentConfiguration.php +++ /dev/null @@ -1,91 +0,0 @@ - $config) - { - $results[$name] = PhpConfiguration::fromArray($config); - } - - return $results; - } - - /** - * Returns an array of only the changed configuration values - * - * @return PhpConfiguration[] - */ - public static function getChangedValues(): array - { - $results = []; - - foreach(ini_get_all() as $name => $config) - { - $config = PhpConfiguration::fromArray($config); - if($config->LocalValue !== $config->GlobalValue) - { - $results[$name] = $config; - } - } - - return $results; - } - - /** - * @param string $file_path - * @return void - */ - public static function export(string $file_path) - { - $configuration = []; - foreach(self::getChangedValues() as $changedValue) - { - $configuration[$changedValue->getName()] = $changedValue->getValue(); - } - - // TODO: Implement ini writing process here - } - - public static function import(string $file_path) - { - // TODO: Implement ini reading process here - $configuration = []; - foreach($configuration as $item => $value) - { - ini_set($item, $value); - } - } - } \ No newline at end of file diff --git a/src/ncc/Classes/GitClient.php b/src/ncc/Classes/GitClient.php index 053b17e..6245ed7 100644 --- a/src/ncc/Classes/GitClient.php +++ b/src/ncc/Classes/GitClient.php @@ -66,7 +66,7 @@ namespace ncc\Classes; * @param string $branch * @throws GitCheckoutException */ - public static function checkout(string $path, string $branch) + public static function checkout(string $path, string $branch): void { Console::outVerbose('Checking out branch' . $branch); $process = new Process(["git", "checkout", $branch], $path); diff --git a/src/ncc/Classes/GithubExtension/GithubService.php b/src/ncc/Classes/GithubExtension/GithubService.php index 0331d75..4b8bcc2 100644 --- a/src/ncc/Classes/GithubExtension/GithubService.php +++ b/src/ncc/Classes/GithubExtension/GithubService.php @@ -204,8 +204,7 @@ namespace ncc\Classes\GithubExtension; if ($response->StatusCode != 200) throw new GithubServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode)); - $response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY); - return $response_decoded; + return Functions::loadJson($response->Body, Functions::FORCE_ARRAY); } /** diff --git a/src/ncc/Classes/HttpClient.php b/src/ncc/Classes/HttpClient.php index 192ce75..11b47e9 100644 --- a/src/ncc/Classes/HttpClient.php +++ b/src/ncc/Classes/HttpClient.php @@ -191,14 +191,11 @@ namespace ncc\Classes; /** * Displays the download progress in the console * - * @param $resource * @param $downloadSize * @param $downloaded - * @param $uploadSize - * @param $uploaded * @return void */ - public static function displayProgress($resource, $downloadSize, $downloaded, $uploadSize, $uploaded): void + public static function displayProgress($downloadSize, $downloaded): void { if(Main::getLogLevel() !== null) { @@ -223,7 +220,7 @@ namespace ncc\Classes; /** * Takes the return headers of a cURL request and parses them into an array. * - * @param string $headers + * @param string $input * @return array */ private static function parseHeaders(string $input): array diff --git a/src/ncc/Classes/LuaExtension/LuaRunner.php b/src/ncc/Classes/LuaExtension/LuaRunner.php index 78dcc32..599c5b2 100644 --- a/src/ncc/Classes/LuaExtension/LuaRunner.php +++ b/src/ncc/Classes/LuaExtension/LuaRunner.php @@ -22,15 +22,10 @@ namespace ncc\Classes\LuaExtension; - use ncc\Abstracts\Runners; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class LuaRunner implements RunnerInterface { diff --git a/src/ncc/Classes/NccExtension/PackageCompiler.php b/src/ncc/Classes/NccExtension/PackageCompiler.php index 480f9eb..8233e31 100644 --- a/src/ncc/Classes/NccExtension/PackageCompiler.php +++ b/src/ncc/Classes/NccExtension/PackageCompiler.php @@ -39,9 +39,9 @@ namespace ncc\Classes\NccExtension; use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\PackagePreparationFailedException; use ncc\Exceptions\ProjectConfigurationNotFoundException; + use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedProjectTypeException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Interfaces\CompilerInterface; use ncc\Managers\ProjectManager; use ncc\ncc; @@ -70,7 +70,6 @@ namespace ncc\Classes\NccExtension; * @throws PackagePreparationFailedException * @throws ProjectConfigurationNotFoundException * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException */ public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string { @@ -162,7 +161,7 @@ namespace ncc\Classes\NccExtension; * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException + * @throws RunnerExecutionException */ public static function compileExecutionPolicies(string $path, ProjectConfiguration $configuration): array { diff --git a/src/ncc/Classes/NccExtension/Runner.php b/src/ncc/Classes/NccExtension/Runner.php index 9637eb9..5a71e81 100644 --- a/src/ncc/Classes/NccExtension/Runner.php +++ b/src/ncc/Classes/NccExtension/Runner.php @@ -22,19 +22,14 @@ namespace ncc\Classes\NccExtension; - use ncc\Abstracts\Runners; use ncc\Abstracts\Scopes; use ncc\Exceptions\AccessDeniedException; - use ncc\Exceptions\ExecutionUnitNotFoundException; use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\IOException; use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\RunnerExecutionException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Managers\ExecutionPointerManager; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; - use ncc\Utilities\PathFinder; use ncc\Utilities\Resolver; class Runner @@ -47,21 +42,19 @@ namespace ncc\Classes\NccExtension; * @param ExecutionUnit $unit * @return void * @throws AccessDeniedException - * @throws UnsupportedRunnerException - * @throws ExecutionUnitNotFoundException * @throws FileNotFoundException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException */ - public static function temporaryExecute(string $package, string $version, ExecutionUnit $unit) + public static function temporaryExecute(string $package, string $version, ExecutionUnit $unit): void { if(Resolver::resolveScope() !== Scopes::System) - throw new AccessDeniedException('Cannot temporarily execute a unit with insufficent permissions'); + throw new AccessDeniedException('Cannot temporarily execute a unit with insufficient permissions'); $ExecutionPointerManager = new ExecutionPointerManager(); $ExecutionPointerManager->addUnit($package, $version, $unit, true); $ExecutionPointerManager->executeUnit($package, $version, $unit->ExecutionPolicy->Name); - $ExecutionPointerManager->cleanTemporaryUnits();; + $ExecutionPointerManager->cleanTemporaryUnits(); } } \ No newline at end of file diff --git a/src/ncc/Classes/PerlExtension/PerlRunner.php b/src/ncc/Classes/PerlExtension/PerlRunner.php index 5017af6..46ee10d 100644 --- a/src/ncc/Classes/PerlExtension/PerlRunner.php +++ b/src/ncc/Classes/PerlExtension/PerlRunner.php @@ -22,16 +22,11 @@ namespace ncc\Classes\PerlExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\FileNotFoundException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class PerlRunner implements RunnerInterface { diff --git a/src/ncc/Classes/PhpExtension/PhpCompiler.php b/src/ncc/Classes/PhpExtension/PhpCompiler.php index ab9a5f6..bc5142b 100644 --- a/src/ncc/Classes/PhpExtension/PhpCompiler.php +++ b/src/ncc/Classes/PhpExtension/PhpCompiler.php @@ -39,7 +39,7 @@ use ncc\Exceptions\IOException; use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackagePreparationFailedException; - use ncc\Exceptions\UnsupportedRunnerException; + use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\VersionNotFoundException; use ncc\Interfaces\CompilerInterface; use ncc\Managers\PackageLockManager; @@ -304,7 +304,6 @@ * @throws BuildException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException */ public function build(): ?Package { @@ -443,7 +442,7 @@ * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException + * @throws RunnerExecutionException */ public function compileExecutionPolicies(): void { diff --git a/src/ncc/Classes/PhpExtension/PhpInstaller.php b/src/ncc/Classes/PhpExtension/PhpInstaller.php index affea6b..323df19 100644 --- a/src/ncc/Classes/PhpExtension/PhpInstaller.php +++ b/src/ncc/Classes/PhpExtension/PhpInstaller.php @@ -288,15 +288,13 @@ * * @param string $src * @param string $output - * @param bool $ignore_units * @return string * @throws AccessDeniedException * @throws CollectorException * @throws FileNotFoundException * @throws IOException - * @throws NoUnitsFoundException */ - private function generateAutoload(string $src, string $output, bool $ignore_units=true): string + private function generateAutoload(string $src, string $output): string { // Construct configuration $configuration = new Config([$src]); @@ -317,10 +315,6 @@ $result = self::runCollector($factory, $configuration); // Exception raises when there are no files in the project that can be processed by the autoloader - if(!$result->hasUnits() && !$ignore_units) - { - throw new NoUnitsFoundException('No units were found in the project'); - } $template = IO::fread($configuration->getTemplate()); diff --git a/src/ncc/Classes/PhpExtension/PhpRunner.php b/src/ncc/Classes/PhpExtension/PhpRunner.php index 87621e3..89f9898 100644 --- a/src/ncc/Classes/PhpExtension/PhpRunner.php +++ b/src/ncc/Classes/PhpExtension/PhpRunner.php @@ -22,19 +22,13 @@ namespace ncc\Classes\PhpExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\IOException; - use ncc\Exceptions\RunnerExecutionException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class PhpRunner implements RunnerInterface { diff --git a/src/ncc/Classes/PythonExtension/Python2Runner.php b/src/ncc/Classes/PythonExtension/Python2Runner.php index d1f265f..b411a06 100644 --- a/src/ncc/Classes/PythonExtension/Python2Runner.php +++ b/src/ncc/Classes/PythonExtension/Python2Runner.php @@ -22,16 +22,11 @@ namespace ncc\Classes\PythonExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\FileNotFoundException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class Python2Runner implements RunnerInterface { diff --git a/src/ncc/Classes/PythonExtension/Python3Runner.php b/src/ncc/Classes/PythonExtension/Python3Runner.php index 443c170..bc6ff39 100644 --- a/src/ncc/Classes/PythonExtension/Python3Runner.php +++ b/src/ncc/Classes/PythonExtension/Python3Runner.php @@ -22,16 +22,11 @@ namespace ncc\Classes\PythonExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\FileNotFoundException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class Python3Runner implements RunnerInterface { diff --git a/src/ncc/Classes/PythonExtension/PythonRunner.php b/src/ncc/Classes/PythonExtension/PythonRunner.php index 86033ea..b3d5168 100644 --- a/src/ncc/Classes/PythonExtension/PythonRunner.php +++ b/src/ncc/Classes/PythonExtension/PythonRunner.php @@ -22,16 +22,11 @@ namespace ncc\Classes\PythonExtension; - use ncc\Abstracts\Runners; use ncc\Exceptions\FileNotFoundException; use ncc\Interfaces\RunnerInterface; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; - use ncc\Utilities\Base64; use ncc\Utilities\IO; - use ncc\Utilities\PathFinder; class PythonRunner implements RunnerInterface { diff --git a/src/ncc/Exceptions/BuildConfigurationNotFoundException.php b/src/ncc/Exceptions/BuildConfigurationNotFoundException.php index bea470d..cff197b 100644 --- a/src/ncc/Exceptions/BuildConfigurationNotFoundException.php +++ b/src/ncc/Exceptions/BuildConfigurationNotFoundException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/BuildException.php b/src/ncc/Exceptions/BuildException.php index 99e4196..4394f96 100644 --- a/src/ncc/Exceptions/BuildException.php +++ b/src/ncc/Exceptions/BuildException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/ComponentChecksumException.php b/src/ncc/Exceptions/ComponentChecksumException.php index c466eb5..9261aa7 100644 --- a/src/ncc/Exceptions/ComponentChecksumException.php +++ b/src/ncc/Exceptions/ComponentChecksumException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/ComponentDecodeException.php b/src/ncc/Exceptions/ComponentDecodeException.php index cb307d5..6d08524 100644 --- a/src/ncc/Exceptions/ComponentDecodeException.php +++ b/src/ncc/Exceptions/ComponentDecodeException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/ComposerDisabledException.php b/src/ncc/Exceptions/ComposerDisabledException.php index 4300464..5ecbf63 100644 --- a/src/ncc/Exceptions/ComposerDisabledException.php +++ b/src/ncc/Exceptions/ComposerDisabledException.php @@ -20,14 +20,13 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; + use Exception; use ncc\Abstracts\ExceptionCodes; use Throwable; - class ComposerDisabledException extends \Exception + class ComposerDisabledException extends Exception { /** * @param string $message diff --git a/src/ncc/Exceptions/ComposerException.php b/src/ncc/Exceptions/ComposerException.php index bf1a3f7..52bc4b7 100644 --- a/src/ncc/Exceptions/ComposerException.php +++ b/src/ncc/Exceptions/ComposerException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/ComposerNotAvailableException.php b/src/ncc/Exceptions/ComposerNotAvailableException.php index 62e328e..2f99a51 100644 --- a/src/ncc/Exceptions/ComposerNotAvailableException.php +++ b/src/ncc/Exceptions/ComposerNotAvailableException.php @@ -20,10 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - /** @noinspection PhpMissingFieldTypeInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/GitCheckoutException.php b/src/ncc/Exceptions/GitCheckoutException.php index bd81a82..aaad3c4 100644 --- a/src/ncc/Exceptions/GitCheckoutException.php +++ b/src/ncc/Exceptions/GitCheckoutException.php @@ -22,10 +22,11 @@ namespace ncc\Exceptions; + use Exception; use ncc\Abstracts\ExceptionCodes; use Throwable; - class GitCheckoutException extends \Exception + class GitCheckoutException extends Exception { /** * @param string $message diff --git a/src/ncc/Exceptions/IOException.php b/src/ncc/Exceptions/IOException.php index 7ae5e9f..51d8c98 100644 --- a/src/ncc/Exceptions/IOException.php +++ b/src/ncc/Exceptions/IOException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InstallationException.php b/src/ncc/Exceptions/InstallationException.php index 2f775f1..de66444 100644 --- a/src/ncc/Exceptions/InstallationException.php +++ b/src/ncc/Exceptions/InstallationException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InternalComposerNotAvailableException.php b/src/ncc/Exceptions/InternalComposerNotAvailableException.php index 6271b56..1d4808c 100644 --- a/src/ncc/Exceptions/InternalComposerNotAvailableException.php +++ b/src/ncc/Exceptions/InternalComposerNotAvailableException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InvalidConstantNameException.php b/src/ncc/Exceptions/InvalidConstantNameException.php index 1b245bd..836848b 100644 --- a/src/ncc/Exceptions/InvalidConstantNameException.php +++ b/src/ncc/Exceptions/InvalidConstantNameException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InvalidPackageException.php b/src/ncc/Exceptions/InvalidPackageException.php index 5738ba7..5af8de4 100644 --- a/src/ncc/Exceptions/InvalidPackageException.php +++ b/src/ncc/Exceptions/InvalidPackageException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InvalidProjectBuildConfiguration.php b/src/ncc/Exceptions/InvalidProjectBuildConfiguration.php index 5e06619..b5ec73a 100644 --- a/src/ncc/Exceptions/InvalidProjectBuildConfiguration.php +++ b/src/ncc/Exceptions/InvalidProjectBuildConfiguration.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/InvalidVersionConfigurationException.php b/src/ncc/Exceptions/InvalidVersionConfigurationException.php index 0a73a18..373646a 100644 --- a/src/ncc/Exceptions/InvalidVersionConfigurationException.php +++ b/src/ncc/Exceptions/InvalidVersionConfigurationException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/MissingDependencyException.php b/src/ncc/Exceptions/MissingDependencyException.php index 338f30e..62cdf44 100644 --- a/src/ncc/Exceptions/MissingDependencyException.php +++ b/src/ncc/Exceptions/MissingDependencyException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/NoAvailableUnitsException.php b/src/ncc/Exceptions/NoAvailableUnitsException.php index 778c7ea..eb7f325 100644 --- a/src/ncc/Exceptions/NoAvailableUnitsException.php +++ b/src/ncc/Exceptions/NoAvailableUnitsException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/NotImplementedException.php b/src/ncc/Exceptions/NotImplementedException.php index a0887ce..55de1d1 100644 --- a/src/ncc/Exceptions/NotImplementedException.php +++ b/src/ncc/Exceptions/NotImplementedException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/PackageAlreadyInstalledException.php b/src/ncc/Exceptions/PackageAlreadyInstalledException.php index a437d20..fcbd34c 100644 --- a/src/ncc/Exceptions/PackageAlreadyInstalledException.php +++ b/src/ncc/Exceptions/PackageAlreadyInstalledException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/PackageFetchException.php b/src/ncc/Exceptions/PackageFetchException.php index 40d147c..4dbbbed 100644 --- a/src/ncc/Exceptions/PackageFetchException.php +++ b/src/ncc/Exceptions/PackageFetchException.php @@ -22,10 +22,11 @@ namespace ncc\Exceptions; + use Exception; use ncc\Abstracts\ExceptionCodes; use Throwable; - class PackageFetchException extends \Exception + class PackageFetchException extends Exception { /** * @param string $message diff --git a/src/ncc/Exceptions/PackageLockException.php b/src/ncc/Exceptions/PackageLockException.php index 9a4b1a0..58bbced 100644 --- a/src/ncc/Exceptions/PackageLockException.php +++ b/src/ncc/Exceptions/PackageLockException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/PackageNotFoundException.php b/src/ncc/Exceptions/PackageNotFoundException.php index 98fc89f..070d601 100644 --- a/src/ncc/Exceptions/PackageNotFoundException.php +++ b/src/ncc/Exceptions/PackageNotFoundException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/PackageParsingException.php b/src/ncc/Exceptions/PackageParsingException.php index e208737..7106d1a 100644 --- a/src/ncc/Exceptions/PackageParsingException.php +++ b/src/ncc/Exceptions/PackageParsingException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/PackagePreparationFailedException.php b/src/ncc/Exceptions/PackagePreparationFailedException.php index 67edb24..223795f 100644 --- a/src/ncc/Exceptions/PackagePreparationFailedException.php +++ b/src/ncc/Exceptions/PackagePreparationFailedException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/ResourceChecksumException.php b/src/ncc/Exceptions/ResourceChecksumException.php index d7e14ce..3de79cc 100644 --- a/src/ncc/Exceptions/ResourceChecksumException.php +++ b/src/ncc/Exceptions/ResourceChecksumException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use Throwable; diff --git a/src/ncc/Exceptions/RunnerExecutionException.php b/src/ncc/Exceptions/RunnerExecutionException.php index a6be30d..244a0b5 100644 --- a/src/ncc/Exceptions/RunnerExecutionException.php +++ b/src/ncc/Exceptions/RunnerExecutionException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/UndefinedExecutionPolicyException.php b/src/ncc/Exceptions/UndefinedExecutionPolicyException.php index 92ba1f5..34e8096 100644 --- a/src/ncc/Exceptions/UndefinedExecutionPolicyException.php +++ b/src/ncc/Exceptions/UndefinedExecutionPolicyException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/UnsupportedCompilerExtensionException.php b/src/ncc/Exceptions/UnsupportedCompilerExtensionException.php index e136cd1..d2ffdd4 100644 --- a/src/ncc/Exceptions/UnsupportedCompilerExtensionException.php +++ b/src/ncc/Exceptions/UnsupportedCompilerExtensionException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/UnsupportedComponentTypeException.php b/src/ncc/Exceptions/UnsupportedComponentTypeException.php index 20b2626..5352a41 100644 --- a/src/ncc/Exceptions/UnsupportedComponentTypeException.php +++ b/src/ncc/Exceptions/UnsupportedComponentTypeException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/UnsupportedPackageException.php b/src/ncc/Exceptions/UnsupportedPackageException.php index 6d60852..6e08431 100644 --- a/src/ncc/Exceptions/UnsupportedPackageException.php +++ b/src/ncc/Exceptions/UnsupportedPackageException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/UserAbortedOperationException.php b/src/ncc/Exceptions/UserAbortedOperationException.php index a360e56..fa27d21 100644 --- a/src/ncc/Exceptions/UserAbortedOperationException.php +++ b/src/ncc/Exceptions/UserAbortedOperationException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Exceptions/VersionNotFoundException.php b/src/ncc/Exceptions/VersionNotFoundException.php index f25f29a..c1348ea 100644 --- a/src/ncc/Exceptions/VersionNotFoundException.php +++ b/src/ncc/Exceptions/VersionNotFoundException.php @@ -20,9 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - - namespace ncc\Exceptions; +namespace ncc\Exceptions; use Exception; use ncc\Abstracts\ExceptionCodes; diff --git a/src/ncc/Extensions/ZiProto/Abstracts/Regex.php b/src/ncc/Extensions/ZiProto/Abstracts/Regex.php index cbc3209..1727946 100644 --- a/src/ncc/Extensions/ZiProto/Abstracts/Regex.php +++ b/src/ncc/Extensions/ZiProto/Abstracts/Regex.php @@ -31,7 +31,7 @@ namespace ncc\ZiProto\Abstracts; const UTF8_REGEX = '/\A(?: [\x00-\x7F]++ # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte - | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs + | \xE0[\xA0-\xBF][\x80-\xBF] # excluding over longs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 diff --git a/src/ncc/Extensions/ZiProto/BufferStream.php b/src/ncc/Extensions/ZiProto/BufferStream.php index fb6bf2b..92fde68 100644 --- a/src/ncc/Extensions/ZiProto/BufferStream.php +++ b/src/ncc/Extensions/ZiProto/BufferStream.php @@ -210,8 +210,11 @@ namespace ncc\ZiProto; case 0xc3: return true; // bin + case 0xd9: case 0xc4: return $this->decodeStrData($this->decodeUint8()); + case 0xda: case 0xc5: return $this->decodeStrData($this->decodeUint16()); + case 0xdb: case 0xc6: return $this->decodeStrData($this->decodeUint32()); // float @@ -231,9 +234,6 @@ namespace ncc\ZiProto; case 0xd3: return $this->decodeInt64(); // str - case 0xd9: return $this->decodeStrData($this->decodeUint8()); - case 0xda: return $this->decodeStrData($this->decodeUint16()); - case 0xdb: return $this->decodeStrData($this->decodeUint32()); // array case 0xdc: return $this->decodeArrayData($this->decodeUint16()); @@ -372,7 +372,7 @@ namespace ncc\ZiProto; } /** - * @return bool|string + * @return string */ public function decodeStr() { @@ -408,7 +408,7 @@ namespace ncc\ZiProto; } /** - * @return bool|string + * @return string */ public function decodeBin() { diff --git a/src/ncc/Extensions/ZiProto/DecodingOptions.php b/src/ncc/Extensions/ZiProto/DecodingOptions.php index 43fdf48..347b2a1 100644 --- a/src/ncc/Extensions/ZiProto/DecodingOptions.php +++ b/src/ncc/Extensions/ZiProto/DecodingOptions.php @@ -61,7 +61,7 @@ namespace ncc\ZiProto; { $self = new self(); - $self->bigIntMode = self::getSingleOption('bigint', $bitmask, + $self->bigIntMode = self::getSingleOption($bitmask, Options::BIGINT_AS_STR | Options::BIGINT_AS_GMP | Options::BIGINT_AS_EXCEPTION @@ -87,12 +87,11 @@ namespace ncc\ZiProto; } /** - * @param string $name * @param int $bitmask * @param int $validBitmask * @return int */ - private static function getSingleOption(string $name, int $bitmask, int $validBitmask) : int + private static function getSingleOption(int $bitmask, int $validBitmask) : int { $option = $bitmask & $validBitmask; if ($option === ($option & -$option)) @@ -112,6 +111,6 @@ namespace ncc\ZiProto; $validOptions[] = __CLASS__.'::'.$map[$i]; } - throw InvalidOptionException::outOfRange($name, $validOptions); + throw InvalidOptionException::outOfRange('bigint', $validOptions); } } diff --git a/src/ncc/Extensions/ZiProto/Packet.php b/src/ncc/Extensions/ZiProto/Packet.php index 5e9cde6..3db2473 100644 --- a/src/ncc/Extensions/ZiProto/Packet.php +++ b/src/ncc/Extensions/ZiProto/Packet.php @@ -112,7 +112,7 @@ namespace ncc\ZiProto; * @param $value * @return false|string */ - public function encode($value) + public function encode($value): false|string { if (is_int($value)) { @@ -185,7 +185,7 @@ namespace ncc\ZiProto; /** * @return string */ - public function encodeNil() + public function encodeNil(): string { return "\xc0"; } @@ -194,7 +194,7 @@ namespace ncc\ZiProto; * @param $bool * @return string */ - public function encodeBool($bool) + public function encodeBool($bool): string { return $bool ? "\xc3" : "\xc2"; } @@ -203,7 +203,7 @@ namespace ncc\ZiProto; * @param $int * @return string */ - public function encodeInt($int) + public function encodeInt($int): string { if ($int >= 0) { @@ -257,7 +257,7 @@ namespace ncc\ZiProto; * @param $float * @return string */ - public function encodeFloat($float) + public function encodeFloat($float): string { return $this->isForceFloat32 ? "\xca". pack('G', $float) @@ -268,7 +268,7 @@ namespace ncc\ZiProto; * @param $str * @return string */ - public function encodeStr($str) + public function encodeStr($str): string { $length = strlen($str); @@ -294,7 +294,7 @@ namespace ncc\ZiProto; * @param $str * @return string */ - public function encodeBin($str) + public function encodeBin($str): string { $length = strlen($str); @@ -313,9 +313,9 @@ namespace ncc\ZiProto; /** * @param $array - * @return false|string + * @return string */ - public function encodeArray($array) + public function encodeArray($array): string { $data = $this->encodeArrayHeader(count($array)); @@ -331,7 +331,7 @@ namespace ncc\ZiProto; * @param $size * @return string */ - public function encodeArrayHeader($size) + public function encodeArrayHeader($size): string { if ($size <= 0xf) { @@ -348,9 +348,9 @@ namespace ncc\ZiProto; /** * @param $map - * @return false|string + * @return string */ - public function encodeMap($map) + public function encodeMap($map): string { $data = $this->encodeMapHeader(count($map)); @@ -391,7 +391,7 @@ namespace ncc\ZiProto; * @param $size * @return string */ - public function encodeMapHeader($size) + public function encodeMapHeader($size): string { if ($size <= 0xf) { @@ -411,7 +411,7 @@ namespace ncc\ZiProto; * @param $data * @return string */ - public function encodeExt($type, $data) + public function encodeExt($type, $data): string { $length = strlen($data); diff --git a/src/ncc/Extensions/ZiProto/TypeTransformer/BinaryTransformer.php b/src/ncc/Extensions/ZiProto/TypeTransformer/BinaryTransformer.php index bc1ac56..54d2f34 100644 --- a/src/ncc/Extensions/ZiProto/TypeTransformer/BinaryTransformer.php +++ b/src/ncc/Extensions/ZiProto/TypeTransformer/BinaryTransformer.php @@ -34,7 +34,7 @@ namespace ncc\ncc\ZiProto\TypeTransformer; /** * @param Packet $packer * @param $value - * @return string + * @return string|null */ public function pack(Packet $packer, $value): ?string { diff --git a/src/ncc/Extensions/ZiProto/TypeTransformer/Extension.php b/src/ncc/Extensions/ZiProto/TypeTransformer/Extension.php index 1633e91..dffa49a 100644 --- a/src/ncc/Extensions/ZiProto/TypeTransformer/Extension.php +++ b/src/ncc/Extensions/ZiProto/TypeTransformer/Extension.php @@ -40,5 +40,5 @@ namespace ncc\ncc\ZiProto\TypeTransformer; * @param int $extLength * @return mixed */ - public function decode(BufferStream $stream, int $extLength); + public function decode(BufferStream $stream, int $extLength): mixed; } \ No newline at end of file diff --git a/src/ncc/Interfaces/CompilerInterface.php b/src/ncc/Interfaces/CompilerInterface.php index 37c1683..7ab44de 100644 --- a/src/ncc/Interfaces/CompilerInterface.php +++ b/src/ncc/Interfaces/CompilerInterface.php @@ -27,7 +27,6 @@ namespace ncc\Interfaces; use ncc\Exceptions\BuildException; use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\IOException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Objects\Package; use ncc\Objects\ProjectConfiguration; @@ -57,7 +56,6 @@ namespace ncc\Interfaces; * @throws BuildException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException */ public function build(): ?Package; @@ -88,7 +86,6 @@ namespace ncc\Interfaces; * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException */ public function compileExecutionPolicies(): void; diff --git a/src/ncc/Interfaces/RunnerInterface.php b/src/ncc/Interfaces/RunnerInterface.php index 3b3d7f3..6b09f8d 100644 --- a/src/ncc/Interfaces/RunnerInterface.php +++ b/src/ncc/Interfaces/RunnerInterface.php @@ -25,11 +25,8 @@ namespace ncc\Interfaces; use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\IOException; - use ncc\Exceptions\RunnerExecutionException; - use ncc\Objects\ExecutionPointers\ExecutionPointer; use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\ProjectConfiguration\ExecutionPolicy; - use ncc\ThirdParty\Symfony\Process\Process; interface RunnerInterface { diff --git a/src/ncc/Managers/ExecutionPointerManager.php b/src/ncc/Managers/ExecutionPointerManager.php index ca52b12..9bedc3b 100644 --- a/src/ncc/Managers/ExecutionPointerManager.php +++ b/src/ncc/Managers/ExecutionPointerManager.php @@ -36,13 +36,11 @@ use ncc\Classes\PythonExtension\Python3Runner; use ncc\Classes\PythonExtension\PythonRunner; use ncc\Exceptions\AccessDeniedException; - use ncc\Exceptions\ExecutionUnitNotFoundException; use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\InvalidScopeException; use ncc\Exceptions\IOException; use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\RunnerExecutionException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Objects\ExecutionPointers; use ncc\Objects\Package; use ncc\Objects\Package\ExecutionUnit; @@ -166,9 +164,8 @@ * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException - * @throws UnsupportedRunnerException + * @throws RunnerExecutionException * @noinspection PhpUnused - * @noinspection DuplicatedCode */ public function addUnit(string $package, string $version, ExecutionUnit $unit, bool $temporary=false): void { @@ -209,7 +206,7 @@ Runners::python2 => Python2Runner::getFileExtension(), Runners::python3 => Python3Runner::getFileExtension(), Runners::lua => LuaRunner::getFileExtension(), - default => throw new UnsupportedRunnerException('The runner \'' . $unit->ExecutionPolicy->Runner . '\' is not supported'), + default => throw new RunnerExecutionException('The runner \'' . $unit->ExecutionPolicy->Runner . '\' is not supported'), }; Console::outDebug(sprintf('bin_file=%s', $bin_file)); @@ -258,7 +255,6 @@ * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException - * @noinspection DuplicatedCode */ public function removeUnit(string $package, string $version, string $name): bool { @@ -347,12 +343,10 @@ * @param array $args * @return int * @throws AccessDeniedException - * @throws ExecutionUnitNotFoundException * @throws FileNotFoundException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException - * @throws UnsupportedRunnerException */ public function executeUnit(string $package, string $version, string $name, array $args=[]): int { @@ -368,7 +362,7 @@ $unit = $execution_pointers->getUnit($name); if($unit == null) - throw new ExecutionUnitNotFoundException('The execution unit \'' . $name . '\' was not found for \'' . $package . '=' .$version .'\''); + throw new RunnerExecutionException('The execution unit \'' . $name . '\' was not found for \'' . $package . '=' .$version .'\''); Console::outDebug(sprintf('unit=%s', $unit->ExecutionPolicy->Name)); Console::outDebug(sprintf('runner=%s', $unit->ExecutionPolicy->Runner)); @@ -470,12 +464,10 @@ * @param string $unit_name * @return void * @throws AccessDeniedException - * @throws ExecutionUnitNotFoundException * @throws FileNotFoundException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException - * @throws UnsupportedRunnerException */ public function temporaryExecute(Package $package, string $unit_name): void { @@ -522,12 +514,10 @@ * @param Process|null $process * @return bool * @throws AccessDeniedException - * @throws ExecutionUnitNotFoundException * @throws FileNotFoundException * @throws IOException * @throws NoAvailableUnitsException * @throws RunnerExecutionException - * @throws UnsupportedRunnerException */ public function handleExit(string $package, string $version, ExitHandle $exitHandle, ?Process $process=null): bool { diff --git a/src/ncc/Managers/PackageLockManager.php b/src/ncc/Managers/PackageLockManager.php index ec41f0e..46134d6 100644 --- a/src/ncc/Managers/PackageLockManager.php +++ b/src/ncc/Managers/PackageLockManager.php @@ -20,8 +20,7 @@ * */ - /** @noinspection PhpPropertyOnlyWrittenInspection */ - /** @noinspection PhpMissingFieldTypeInspection */ +/** @noinspection PhpMissingFieldTypeInspection */ namespace ncc\Managers; diff --git a/src/ncc/Managers/PackageManager.php b/src/ncc/Managers/PackageManager.php index e0820e3..fb2cde0 100644 --- a/src/ncc/Managers/PackageManager.php +++ b/src/ncc/Managers/PackageManager.php @@ -51,6 +51,7 @@ use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageNotFoundException; use ncc\Exceptions\PackageParsingException; + use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\SymlinkException; use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\VersionNotFoundException; @@ -109,6 +110,7 @@ * @throws FileNotFoundException * @throws IOException * @throws InstallationException + * @throws InvalidPackageNameException * @throws InvalidScopeException * @throws MissingDependencyException * @throws NotImplementedException @@ -116,11 +118,10 @@ * @throws PackageLockException * @throws PackageNotFoundException * @throws PackageParsingException - * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException - * @throws VersionNotFoundException - * @throws InvalidPackageNameException + * @throws RunnerExecutionException * @throws SymlinkException + * @throws UnsupportedCompilerExtensionException + * @throws VersionNotFoundException */ public function install(string $package_path, ?Entry $entry=null, array $options=[]): string { @@ -604,6 +605,7 @@ * @throws SymlinkException * @throws UnsupportedCompilerExtensionException * @throws VersionNotFoundException + * @throws RunnerExecutionException */ private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null): void { @@ -930,7 +932,7 @@ $paths->getDataPath() . DIRECTORY_SEPARATOR . 'assembly' => ZiProto::encode($package->Assembly->toArray(true)), $paths->getDataPath() . DIRECTORY_SEPARATOR . 'ext' => - ZiProto::encode($package->Header->CompilerExtension->toArray(true)), + ZiProto::encode($package->Header->CompilerExtension->toArray()), $paths->getDataPath() . DIRECTORY_SEPARATOR . 'const' => ZiProto::encode($package->Header->RuntimeConstants), $paths->getDataPath() . DIRECTORY_SEPARATOR . 'dependencies' => diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index cfde399..9e28ba6 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -40,7 +40,6 @@ use ncc\Exceptions\ProjectAlreadyExistsException; use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\UnsupportedCompilerExtensionException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Objects\ProjectConfiguration; use ncc\Objects\ProjectConfiguration\Compiler; use ncc\ThirdParty\Symfony\Uid\Uuid; @@ -192,14 +191,10 @@ // Process options foreach($options as $option) { - switch($option) - { - case InitializeProjectOptions::CREATE_SOURCE_DIRECTORY: - if(!file_exists($this->ProjectConfiguration->Build->SourcePath)) - { - mkdir($this->ProjectConfiguration->Build->SourcePath); - } - break; + if ($option == InitializeProjectOptions::CREATE_SOURCE_DIRECTORY) { + if (!file_exists($this->ProjectConfiguration->Build->SourcePath)) { + mkdir($this->ProjectConfiguration->Build->SourcePath); + } } } } @@ -227,7 +222,7 @@ * @throws FileNotFoundException * @throws IOException */ - public function load() + public function load(): void { if(!file_exists($this->ProjectFilePath) && !is_file($this->ProjectFilePath)) throw new ProjectConfigurationNotFoundException('The project configuration file \'' . $this->ProjectFilePath . '\' was not found'); @@ -241,7 +236,7 @@ * @return void * @throws MalformedJsonException */ - public function save() + public function save(): void { if(!$this->projectLoaded()) return; @@ -294,7 +289,6 @@ * @throws BuildException * @throws PackagePreparationFailedException * @throws UnsupportedCompilerExtensionException - * @throws UnsupportedRunnerException */ public function build(string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string { diff --git a/src/ncc/Managers/RemoteSourcesManager.php b/src/ncc/Managers/RemoteSourcesManager.php index 24e5e62..dc1f884 100644 --- a/src/ncc/Managers/RemoteSourcesManager.php +++ b/src/ncc/Managers/RemoteSourcesManager.php @@ -56,7 +56,6 @@ */ public function __construct() { - /** @noinspection PhpUnhandledExceptionInspection */ $this->DefinedSourcesPath = PathFinder::getRemoteSources(Scopes::System); $this->load(); diff --git a/src/ncc/Managers/SymlinkManager.php b/src/ncc/Managers/SymlinkManager.php index 8dff5e9..ce3e2e1 100644 --- a/src/ncc/Managers/SymlinkManager.php +++ b/src/ncc/Managers/SymlinkManager.php @@ -282,28 +282,6 @@ } } - /** - * Sets the package as unregistered - * - * @param string $package - * @return void - * @throws AccessDeniedException - * @throws SymlinkException - */ - private function setAsUnregistered(string $package): void - { - foreach($this->SymlinkDictionary as $key => $entry) - { - if($entry->Package === $package) - { - $entry->Registered = false; - $this->SymlinkDictionary[$key] = $entry; - $this->save(); - return; - } - } - } - /** * Syncs the symlink dictionary with the filesystem * diff --git a/src/ncc/Objects/Constant.php b/src/ncc/Objects/Constant.php index 4a466cd..a4ec300 100644 --- a/src/ncc/Objects/Constant.php +++ b/src/ncc/Objects/Constant.php @@ -114,7 +114,7 @@ namespace ncc\Objects; */ public function setValue(string $value, bool $readonly=false): void { - if($this->Readonly == true) + if($this->Readonly) { throw new ConstantReadonlyException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly'); } diff --git a/src/ncc/Objects/Package.php b/src/ncc/Objects/Package.php index 5a0d3e6..e5fce9d 100644 --- a/src/ncc/Objects/Package.php +++ b/src/ncc/Objects/Package.php @@ -129,7 +129,7 @@ * @param Dependency $dependency * @return void */ - public function addDependency(Dependency $dependency) + public function addDependency(Dependency $dependency): void { foreach($this->Dependencies as $dep) { @@ -149,7 +149,7 @@ * @param string $name * @return void */ - private function removeDependency(string $name) + private function removeDependency(string $name): void { foreach($this->Dependencies as $key => $dep) { diff --git a/src/ncc/Objects/Package/Header.php b/src/ncc/Objects/Package/Header.php index 3007fca..b53779d 100644 --- a/src/ncc/Objects/Package/Header.php +++ b/src/ncc/Objects/Package/Header.php @@ -84,7 +84,7 @@ public function toArray(bool $bytecode=false): array { return [ - ($bytecode ? Functions::cbc('compiler_extension') : 'compiler_extension') => $this->CompilerExtension->toArray($bytecode), + ($bytecode ? Functions::cbc('compiler_extension') : 'compiler_extension') => $this->CompilerExtension->toArray(), ($bytecode ? Functions::cbc('runtime_constants') : 'runtime_constants') => $this->RuntimeConstants, ($bytecode ? Functions::cbc('compiler_version') : 'compiler_version') => $this->CompilerVersion, ($bytecode ? Functions::cbc('update_source') : 'update_source') => ($this->UpdateSource?->toArray($bytecode) ?? null), diff --git a/src/ncc/Objects/PackageLock/PackageEntry.php b/src/ncc/Objects/PackageLock/PackageEntry.php index e144139..e1f2dc8 100644 --- a/src/ncc/Objects/PackageLock/PackageEntry.php +++ b/src/ncc/Objects/PackageLock/PackageEntry.php @@ -239,7 +239,7 @@ if(!file_exists($path) && Resolver::resolveScope() == Scopes::System) { $filesystem = new Filesystem(); - $filesystem->mkdir($path, 0777); + $filesystem->mkdir($path); } return $path; diff --git a/src/ncc/Objects/PackageLock/VersionEntry.php b/src/ncc/Objects/PackageLock/VersionEntry.php index 01cd1e7..a90a22b 100644 --- a/src/ncc/Objects/PackageLock/VersionEntry.php +++ b/src/ncc/Objects/PackageLock/VersionEntry.php @@ -112,7 +112,7 @@ return [ ($bytecode ? Functions::cbc('version') : 'version') => $this->Version, - ($bytecode ? Functions::cbc('compiler') : 'compiler') => $this->Compiler->toArray($bytecode), + ($bytecode ? Functions::cbc('compiler') : 'compiler') => $this->Compiler->toArray(), ($bytecode ? Functions::cbc('dependencies') : 'dependencies') => $dependencies, ($bytecode ? Functions::cbc('execution_units') : 'execution_units') => $execution_units, ($bytecode ? Functions::cbc('main_execution_policy') : 'main_execution_policy') => $this->MainExecutionPolicy, diff --git a/src/ncc/Objects/ProjectConfiguration/Compiler.php b/src/ncc/Objects/ProjectConfiguration/Compiler.php index d1501b6..64ce759 100644 --- a/src/ncc/Objects/ProjectConfiguration/Compiler.php +++ b/src/ncc/Objects/ProjectConfiguration/Compiler.php @@ -145,10 +145,9 @@ /** * Returns an array representation of the object * - * @param bool $bytecode * @return array */ - public function toArray(bool $bytecode=false): array + public function toArray(): array { $return_results = []; if($this->Extension !== null && strlen($this->Extension) > 0) diff --git a/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy.php b/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy.php index f2b6c5d..efc175c 100644 --- a/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy.php +++ b/src/ncc/Objects/ProjectConfiguration/ExecutionPolicy.php @@ -66,10 +66,9 @@ public $ExitHandlers; /** - * @param bool $throw_exception * @return bool */ - public function validate(bool $throw_exception=True): bool + public function validate(): bool { // TODO: Implement validation method return true; diff --git a/src/ncc/Objects/ProjectConfiguration/Project.php b/src/ncc/Objects/ProjectConfiguration/Project.php index 458cabd..77e15db 100644 --- a/src/ncc/Objects/ProjectConfiguration/Project.php +++ b/src/ncc/Objects/ProjectConfiguration/Project.php @@ -88,7 +88,7 @@ { $ReturnResults = []; - $ReturnResults[($bytecode ? Functions::cbc('compiler') : 'compiler')] = $this->Compiler->toArray($bytecode); + $ReturnResults[($bytecode ? Functions::cbc('compiler') : 'compiler')] = $this->Compiler->toArray(); $ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options; if($this->UpdateSource !== null) diff --git a/src/ncc/Objects/ProjectDetectionResults.php b/src/ncc/Objects/ProjectDetectionResults.php index 5ead723..b5bb92e 100644 --- a/src/ncc/Objects/ProjectDetectionResults.php +++ b/src/ncc/Objects/ProjectDetectionResults.php @@ -59,8 +59,6 @@ namespace ncc\Objects; - use ncc\Abstracts\ProjectType; - class ProjectDetectionResults { /** diff --git a/src/ncc/Runtime.php b/src/ncc/Runtime.php index 6792a4e..b9ab941 100644 --- a/src/ncc/Runtime.php +++ b/src/ncc/Runtime.php @@ -174,7 +174,7 @@ $package = self::getPackageManager()->getPackage($package); if($package == null) - throw new PackageNotFoundException(sprintf('Package %s not found', $package)); + throw new PackageNotFoundException('Package not found (null entry error, possible bug)'); return $package->getDataPath(); } diff --git a/src/ncc/Utilities/Functions.php b/src/ncc/Utilities/Functions.php index fb75342..863520b 100644 --- a/src/ncc/Utilities/Functions.php +++ b/src/ncc/Utilities/Functions.php @@ -47,8 +47,8 @@ namespace ncc\Utilities; use ncc\Exceptions\InvalidScopeException; use ncc\Exceptions\IOException; use ncc\Exceptions\MalformedJsonException; + use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\UnsupportedArchiveException; - use ncc\Exceptions\UnsupportedRunnerException; use ncc\Managers\ConfigurationManager; use ncc\Managers\CredentialManager; use ncc\Managers\PackageLockManager; @@ -298,10 +298,10 @@ namespace ncc\Utilities; * @param string $path * @param ExecutionPolicy $policy * @return ExecutionUnit - * @throws UnsupportedRunnerException * @throws AccessDeniedException * @throws FileNotFoundException * @throws IOException + * @throws RunnerExecutionException */ public static function compileRunner(string $path, ExecutionPolicy $policy): ExecutionUnit { @@ -313,7 +313,7 @@ namespace ncc\Utilities; Runners::python2 => Python2Runner::processUnit($path, $policy), Runners::python3 => Python3Runner::processUnit($path, $policy), Runners::lua => LuaRunner::processUnit($path, $policy), - default => throw new UnsupportedRunnerException('The runner \'' . $policy->Runner . '\' is not supported'), + default => throw new RunnerExecutionException('The runner \'' . $policy->Runner . '\' is not supported'), }; } @@ -676,21 +676,13 @@ namespace ncc\Utilities; if (!in_array($mimeType, $supportedTypes)) throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"); - switch($mimeType) - { - case 'application/zip': - $command = [$unzip_executable, $path, '-d', $out_path]; - break; - case 'application/x-tar': - $command = [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path]; - break; - case 'application/x-gzip': - $command = [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path]; - break; - case 'application/x-bzip2': - $command = [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path]; - break; - } + $command = match ($mimeType) { + 'application/zip' => [$unzip_executable, $path, '-d', $out_path], + 'application/x-tar' => [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path], + 'application/x-gzip' => [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path], + 'application/x-bzip2' => [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path], + default => throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"), + }; Console::out("Extracting archive $path"); $process = new Process($command); @@ -746,7 +738,6 @@ namespace ncc\Utilities; $minor = (string)null; $patch = (string)null; - $buildmetadata = (string)null; if(count($parts) >= 1) $major = $parts[0]; if(count($parts) >= 2) @@ -945,7 +936,7 @@ namespace ncc\Utilities; * @param string $input * @return float|int|mixed|string */ - public static function stringTypeCast(string $input) + public static function stringTypeCast(string $input): mixed { if (is_numeric($input)) { @@ -969,7 +960,7 @@ namespace ncc\Utilities; * @return void * @throws InvalidScopeException */ - public static function finalizePermissions() + public static function finalizePermissions(): void { if(Resolver::resolveScope() !== Scopes::System) return; diff --git a/src/ncc/Utilities/Resolver.php b/src/ncc/Utilities/Resolver.php index d30bf64..c58edab 100644 --- a/src/ncc/Utilities/Resolver.php +++ b/src/ncc/Utilities/Resolver.php @@ -292,7 +292,6 @@ * Detects the project type from the specified path * * @param string $path - * @param array $exlucde * @return ProjectDetectionResults */ public static function detectProjectType(string $path): ProjectDetectionResults diff --git a/src/ncc/Utilities/Security.php b/src/ncc/Utilities/Security.php index 07856f6..f2d3de2 100644 --- a/src/ncc/Utilities/Security.php +++ b/src/ncc/Utilities/Security.php @@ -48,8 +48,7 @@ namespace ncc\Utilities; if ($beautify) $input = self::beautifyFilename($input); // maximize filename length to 255 bytes http://serverfault.com/a/9548/44086 $ext = pathinfo($input, PATHINFO_EXTENSION); - $input = mb_strcut(pathinfo($input, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($input)) . ($ext ? '.' . $ext : ''); - return $input; + return mb_strcut(pathinfo($input, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($input)) . ($ext ? '.' . $ext : ''); } /** @@ -77,8 +76,6 @@ namespace ncc\Utilities; // lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 $input = mb_strtolower($input, mb_detect_encoding($input)); // ".file-name.-" becomes "file-name" - $input = trim($input, '.-'); - - return $input; + return trim($input, '.-'); } } \ No newline at end of file diff --git a/src/ncc/ncc b/src/ncc/ncc index a5d251f..fd7b4af 100644 --- a/src/ncc/ncc +++ b/src/ncc/ncc @@ -19,6 +19,8 @@ * DEALINGS IN THE SOFTWARE. * */ - - require('autoload.php'); - \ncc\CLI\Main::start($argv); \ No newline at end of file + +use ncc\CLI\Main; + +require('autoload.php'); + Main::start($argv); \ No newline at end of file diff --git a/src/ncc/ncc.php b/src/ncc/ncc.php index 186bc61..72e609f 100644 --- a/src/ncc/ncc.php +++ b/src/ncc/ncc.php @@ -38,7 +38,7 @@ namespace ncc; { /** - * The cache'd version of the version information object. + * The cached version of the version information object. * * @var NccVersionInformation|null */ @@ -98,7 +98,9 @@ namespace ncc; * Initializes the NCC environment * * @return bool - * @throws Exceptions\FileNotFoundException + * @throws AccessDeniedException + * @throws FileNotFoundException + * @throws IOException * @throws RuntimeException */ public static function initialize(): bool @@ -146,7 +148,7 @@ namespace ncc; */ public static function getConstants(): array { - if(defined('NCC_INIT') == false) + if(!defined('NCC_INIT')) { throw new RuntimeException('NCC Must be initialized before executing ' . get_called_class() . '::getConstants()'); }