1.0.0 Alpha Release #59

Merged
netkas merged 213 commits from v1.0.0_alpha into master 2023-01-29 23:27:58 +00:00
81 changed files with 186 additions and 396 deletions
Showing only changes of commit de83f53a2d - Show all commits

View file

@ -0,0 +1,37 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Abstracts;
class BuiltinRemoteSourceType
{
/**
* The remote source indicates the package is to be
* fetched using the composer utility.
*/
const Composer = 'composer';
const All = [
self::Composer
];
}

View file

@ -34,7 +34,9 @@
use ncc\CLI\Management\PackageManagerMenu; use ncc\CLI\Management\PackageManagerMenu;
use ncc\CLI\Management\ProjectMenu; use ncc\CLI\Management\ProjectMenu;
use ncc\CLI\Management\SourcesMenu; use ncc\CLI\Management\SourcesMenu;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\RuntimeException; use ncc\Exceptions\RuntimeException;
use ncc\ncc; use ncc\ncc;
use ncc\Utilities\Console; use ncc\Utilities\Console;
@ -60,6 +62,8 @@
* @param $argv * @param $argv
* @return void * @return void
* @throws RuntimeException * @throws RuntimeException
* @throws AccessDeniedException
* @throws IOException
*/ */
public static function start($argv): void public static function start($argv): void
{ {
@ -112,7 +116,6 @@
if(Resolver::checkLogLevel(self::$log_level, LogLevel::Debug)) if(Resolver::checkLogLevel(self::$log_level, LogLevel::Debug))
{ {
Console::outDebug('Debug logging enabled'); Console::outDebug('Debug logging enabled');
/** @noinspection PhpUnhandledExceptionInspection */
Console::outDebug(sprintf('const: %s', json_encode(ncc::getConstants(), JSON_UNESCAPED_SLASHES))); Console::outDebug(sprintf('const: %s', json_encode(ncc::getConstants(), JSON_UNESCAPED_SLASHES)));
Console::outDebug(sprintf('args: %s', json_encode(self::$args, JSON_UNESCAPED_SLASHES))); Console::outDebug(sprintf('args: %s', json_encode(self::$args, JSON_UNESCAPED_SLASHES)));
} }

View file

@ -555,7 +555,6 @@ namespace ncc\CLI\Management;
$version_entry = null; $version_entry = null;
if($version_entry !== null && $package_entry !== null) if($version_entry !== null && $package_entry !== null)
/** @noinspection PhpUnhandledExceptionInspection */
/** @noinspection PhpRedundantOptionalArgumentInspection */ /** @noinspection PhpRedundantOptionalArgumentInspection */
$version_entry = $package_entry->getVersion($version_entry, false); $version_entry = $package_entry->getVersion($version_entry, false);

View file

@ -26,13 +26,20 @@ namespace ncc\CLI\Management;
use ncc\Abstracts\CompilerExtensionDefaultVersions; use ncc\Abstracts\CompilerExtensionDefaultVersions;
use ncc\Abstracts\CompilerExtensions; use ncc\Abstracts\CompilerExtensions;
use ncc\Abstracts\CompilerExtensionSupportedVersions; use ncc\Abstracts\CompilerExtensionSupportedVersions;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\DirectoryNotFoundException;
use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\InvalidPackageNameException; use ncc\Exceptions\InvalidPackageNameException;
use ncc\Exceptions\InvalidProjectNameException; use ncc\Exceptions\InvalidProjectNameException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\ProjectAlreadyExistsException; use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
use ncc\Objects\CliHelpSection; use ncc\Objects\CliHelpSection;
use ncc\Objects\ProjectConfiguration\Compiler; use ncc\Objects\ProjectConfiguration\Compiler;
use ncc\Utilities\Console; use ncc\Utilities\Console;
use ncc\Utilities\Functions;
class ProjectMenu class ProjectMenu
{ {
@ -41,6 +48,12 @@ namespace ncc\CLI\Management;
* *
* @param $args * @param $args
* @return void * @return void
* @throws AccessDeniedException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectConfigurationNotFoundException
*/ */
public static function start($args): void public static function start($args): void
{ {
@ -50,13 +63,17 @@ namespace ncc\CLI\Management;
} }
self::displayOptions(); self::displayOptions();
exit(0);
} }
/** /**
* @param $args * @param $args
* @return void * @return void
* @throws AccessDeniedException
* @throws DirectoryNotFoundException
* @throws FileNotFoundException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectConfigurationNotFoundException
*/ */
public static function createProject($args): void public static function createProject($args): void
{ {
@ -93,7 +110,7 @@ namespace ncc\CLI\Management;
} }
// Remove basename from real_src // 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 // Fetch the rest of the information needed for the project
//$compiler_extension = Console::getOptionInput($args, 'ce', 'Compiler Extension (php, java): '); //$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'), 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('Usage: ncc project {command} [options]');
Console::out('Options:' . PHP_EOL); Console::out('Options:' . PHP_EOL);

View file

@ -22,16 +22,11 @@
namespace ncc\Classes\BashExtension; namespace ncc\Classes\BashExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class BashRunner implements RunnerInterface class BashRunner implements RunnerInterface
{ {

View file

@ -48,7 +48,6 @@ namespace ncc\Classes\ComposerExtension;
use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\RuntimeException; use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Exceptions\UserAbortedOperationException; use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\ServiceSourceInterface; use ncc\Interfaces\ServiceSourceInterface;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
@ -99,7 +98,6 @@ namespace ncc\Classes\ComposerExtension;
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws RuntimeException * @throws RuntimeException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
*/ */
public static function fetch(RemotePackageInput $packageInput): string public static function fetch(RemotePackageInput $packageInput): string
@ -138,7 +136,6 @@ namespace ncc\Classes\ComposerExtension;
* @throws PackagePreparationFailedException * @throws PackagePreparationFailedException
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
* @throws UserAbortedOperationException * @throws UserAbortedOperationException
*/ */
public static function fromLocal(string $path): string public static function fromLocal(string $path): string
@ -196,7 +193,6 @@ namespace ncc\Classes\ComposerExtension;
* @throws PackagePreparationFailedException * @throws PackagePreparationFailedException
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
*/ */
private static function compilePackages(string $composer_lock_path): array private static function compilePackages(string $composer_lock_path): array
{ {

View file

@ -1,91 +0,0 @@
<?php
/*
* Copyright (c) Nosial 2022-2023, all rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including without
* limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
* Software, and to permit persons to whom the Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
namespace ncc\Classes;
use ncc\Objects\PhpConfiguration;
class EnvironmentConfiguration
{
/**
* Returns an array of all the current configuration values set in this environment
*
* @return PhpConfiguration[]
*/
public static function getCurrentConfiguration(): array
{
$results = [];
foreach(ini_get_all() as $name => $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);
}
}
}

View file

@ -66,7 +66,7 @@ namespace ncc\Classes;
* @param string $branch * @param string $branch
* @throws GitCheckoutException * @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); Console::outVerbose('Checking out branch' . $branch);
$process = new Process(["git", "checkout", $branch], $path); $process = new Process(["git", "checkout", $branch], $path);

View file

@ -204,8 +204,7 @@ namespace ncc\Classes\GithubExtension;
if ($response->StatusCode != 200) if ($response->StatusCode != 200)
throw new GithubServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode)); 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 Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
return $response_decoded;
} }
/** /**

View file

@ -191,14 +191,11 @@ namespace ncc\Classes;
/** /**
* Displays the download progress in the console * Displays the download progress in the console
* *
* @param $resource
* @param $downloadSize * @param $downloadSize
* @param $downloaded * @param $downloaded
* @param $uploadSize
* @param $uploaded
* @return void * @return void
*/ */
public static function displayProgress($resource, $downloadSize, $downloaded, $uploadSize, $uploaded): void public static function displayProgress($downloadSize, $downloaded): void
{ {
if(Main::getLogLevel() !== null) 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. * Takes the return headers of a cURL request and parses them into an array.
* *
* @param string $headers * @param string $input
* @return array * @return array
*/ */
private static function parseHeaders(string $input): array private static function parseHeaders(string $input): array

View file

@ -22,15 +22,10 @@
namespace ncc\Classes\LuaExtension; namespace ncc\Classes\LuaExtension;
use ncc\Abstracts\Runners;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class LuaRunner implements RunnerInterface class LuaRunner implements RunnerInterface
{ {

View file

@ -39,9 +39,9 @@ namespace ncc\Classes\NccExtension;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackagePreparationFailedException; use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedProjectTypeException; use ncc\Exceptions\UnsupportedProjectTypeException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Interfaces\CompilerInterface; use ncc\Interfaces\CompilerInterface;
use ncc\Managers\ProjectManager; use ncc\Managers\ProjectManager;
use ncc\ncc; use ncc\ncc;
@ -70,7 +70,6 @@ namespace ncc\Classes\NccExtension;
* @throws PackagePreparationFailedException * @throws PackagePreparationFailedException
* @throws ProjectConfigurationNotFoundException * @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
*/ */
public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string
{ {
@ -162,7 +161,7 @@ namespace ncc\Classes\NccExtension;
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException * @throws RunnerExecutionException
*/ */
public static function compileExecutionPolicies(string $path, ProjectConfiguration $configuration): array public static function compileExecutionPolicies(string $path, ProjectConfiguration $configuration): array
{ {

View file

@ -22,19 +22,14 @@
namespace ncc\Classes\NccExtension; namespace ncc\Classes\NccExtension;
use ncc\Abstracts\Runners;
use ncc\Abstracts\Scopes; use ncc\Abstracts\Scopes;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\ExecutionUnitNotFoundException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\NoAvailableUnitsException;
use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Managers\ExecutionPointerManager; use ncc\Managers\ExecutionPointerManager;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Utilities\PathFinder;
use ncc\Utilities\Resolver; use ncc\Utilities\Resolver;
class Runner class Runner
@ -47,21 +42,19 @@ namespace ncc\Classes\NccExtension;
* @param ExecutionUnit $unit * @param ExecutionUnit $unit
* @return void * @return void
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws UnsupportedRunnerException
* @throws ExecutionUnitNotFoundException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws NoAvailableUnitsException * @throws NoAvailableUnitsException
* @throws RunnerExecutionException * @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) 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 = new ExecutionPointerManager();
$ExecutionPointerManager->addUnit($package, $version, $unit, true); $ExecutionPointerManager->addUnit($package, $version, $unit, true);
$ExecutionPointerManager->executeUnit($package, $version, $unit->ExecutionPolicy->Name); $ExecutionPointerManager->executeUnit($package, $version, $unit->ExecutionPolicy->Name);
$ExecutionPointerManager->cleanTemporaryUnits();; $ExecutionPointerManager->cleanTemporaryUnits();
} }
} }

View file

@ -22,16 +22,11 @@
namespace ncc\Classes\PerlExtension; namespace ncc\Classes\PerlExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class PerlRunner implements RunnerInterface class PerlRunner implements RunnerInterface
{ {

View file

@ -39,7 +39,7 @@
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackagePreparationFailedException; use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\UnsupportedRunnerException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
use ncc\Interfaces\CompilerInterface; use ncc\Interfaces\CompilerInterface;
use ncc\Managers\PackageLockManager; use ncc\Managers\PackageLockManager;
@ -304,7 +304,6 @@
* @throws BuildException * @throws BuildException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException
*/ */
public function build(): ?Package public function build(): ?Package
{ {
@ -443,7 +442,7 @@
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException * @throws RunnerExecutionException
*/ */
public function compileExecutionPolicies(): void public function compileExecutionPolicies(): void
{ {

View file

@ -288,15 +288,13 @@
* *
* @param string $src * @param string $src
* @param string $output * @param string $output
* @param bool $ignore_units
* @return string * @return string
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws CollectorException * @throws CollectorException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @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 // Construct configuration
$configuration = new Config([$src]); $configuration = new Config([$src]);
@ -317,10 +315,6 @@
$result = self::runCollector($factory, $configuration); $result = self::runCollector($factory, $configuration);
// Exception raises when there are no files in the project that can be processed by the autoloader // 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()); $template = IO::fread($configuration->getTemplate());

View file

@ -22,19 +22,13 @@
namespace ncc\Classes\PhpExtension; namespace ncc\Classes\PhpExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class PhpRunner implements RunnerInterface class PhpRunner implements RunnerInterface
{ {

View file

@ -22,16 +22,11 @@
namespace ncc\Classes\PythonExtension; namespace ncc\Classes\PythonExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class Python2Runner implements RunnerInterface class Python2Runner implements RunnerInterface
{ {

View file

@ -22,16 +22,11 @@
namespace ncc\Classes\PythonExtension; namespace ncc\Classes\PythonExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class Python3Runner implements RunnerInterface class Python3Runner implements RunnerInterface
{ {

View file

@ -22,16 +22,11 @@
namespace ncc\Classes\PythonExtension; namespace ncc\Classes\PythonExtension;
use ncc\Abstracts\Runners;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Interfaces\RunnerInterface; use ncc\Interfaces\RunnerInterface;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
use ncc\Utilities\Base64;
use ncc\Utilities\IO; use ncc\Utilities\IO;
use ncc\Utilities\PathFinder;
class PythonRunner implements RunnerInterface class PythonRunner implements RunnerInterface
{ {

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,14 +20,13 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;
use Throwable; use Throwable;
class ComposerDisabledException extends \Exception class ComposerDisabledException extends Exception
{ {
/** /**
* @param string $message * @param string $message

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,10 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -22,10 +22,11 @@
namespace ncc\Exceptions; namespace ncc\Exceptions;
use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;
use Throwable; use Throwable;
class GitCheckoutException extends \Exception class GitCheckoutException extends Exception
{ {
/** /**
* @param string $message * @param string $message

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -22,10 +22,11 @@
namespace ncc\Exceptions; namespace ncc\Exceptions;
use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;
use Throwable; use Throwable;
class PackageFetchException extends \Exception class PackageFetchException extends Exception
{ {
/** /**
* @param string $message * @param string $message

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use Throwable; use Throwable;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -20,9 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception; use Exception;
use ncc\Abstracts\ExceptionCodes; use ncc\Abstracts\ExceptionCodes;

View file

@ -31,7 +31,7 @@ namespace ncc\ZiProto\Abstracts;
const UTF8_REGEX = '/\A(?: const UTF8_REGEX = '/\A(?:
[\x00-\x7F]++ # ASCII [\x00-\x7F]++ # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | [\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 | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3

View file

@ -210,8 +210,11 @@ namespace ncc\ZiProto;
case 0xc3: return true; case 0xc3: return true;
// bin // bin
case 0xd9:
case 0xc4: return $this->decodeStrData($this->decodeUint8()); case 0xc4: return $this->decodeStrData($this->decodeUint8());
case 0xda:
case 0xc5: return $this->decodeStrData($this->decodeUint16()); case 0xc5: return $this->decodeStrData($this->decodeUint16());
case 0xdb:
case 0xc6: return $this->decodeStrData($this->decodeUint32()); case 0xc6: return $this->decodeStrData($this->decodeUint32());
// float // float
@ -231,9 +234,6 @@ namespace ncc\ZiProto;
case 0xd3: return $this->decodeInt64(); case 0xd3: return $this->decodeInt64();
// str // str
case 0xd9: return $this->decodeStrData($this->decodeUint8());
case 0xda: return $this->decodeStrData($this->decodeUint16());
case 0xdb: return $this->decodeStrData($this->decodeUint32());
// array // array
case 0xdc: return $this->decodeArrayData($this->decodeUint16()); case 0xdc: return $this->decodeArrayData($this->decodeUint16());
@ -372,7 +372,7 @@ namespace ncc\ZiProto;
} }
/** /**
* @return bool|string * @return string
*/ */
public function decodeStr() public function decodeStr()
{ {
@ -408,7 +408,7 @@ namespace ncc\ZiProto;
} }
/** /**
* @return bool|string * @return string
*/ */
public function decodeBin() public function decodeBin()
{ {

View file

@ -61,7 +61,7 @@ namespace ncc\ZiProto;
{ {
$self = new self(); $self = new self();
$self->bigIntMode = self::getSingleOption('bigint', $bitmask, $self->bigIntMode = self::getSingleOption($bitmask,
Options::BIGINT_AS_STR | Options::BIGINT_AS_STR |
Options::BIGINT_AS_GMP | Options::BIGINT_AS_GMP |
Options::BIGINT_AS_EXCEPTION Options::BIGINT_AS_EXCEPTION
@ -87,12 +87,11 @@ namespace ncc\ZiProto;
} }
/** /**
* @param string $name
* @param int $bitmask * @param int $bitmask
* @param int $validBitmask * @param int $validBitmask
* @return int * @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; $option = $bitmask & $validBitmask;
if ($option === ($option & -$option)) if ($option === ($option & -$option))
@ -112,6 +111,6 @@ namespace ncc\ZiProto;
$validOptions[] = __CLASS__.'::'.$map[$i]; $validOptions[] = __CLASS__.'::'.$map[$i];
} }
throw InvalidOptionException::outOfRange($name, $validOptions); throw InvalidOptionException::outOfRange('bigint', $validOptions);
} }
} }

View file

@ -112,7 +112,7 @@ namespace ncc\ZiProto;
* @param $value * @param $value
* @return false|string * @return false|string
*/ */
public function encode($value) public function encode($value): false|string
{ {
if (is_int($value)) if (is_int($value))
{ {
@ -185,7 +185,7 @@ namespace ncc\ZiProto;
/** /**
* @return string * @return string
*/ */
public function encodeNil() public function encodeNil(): string
{ {
return "\xc0"; return "\xc0";
} }
@ -194,7 +194,7 @@ namespace ncc\ZiProto;
* @param $bool * @param $bool
* @return string * @return string
*/ */
public function encodeBool($bool) public function encodeBool($bool): string
{ {
return $bool ? "\xc3" : "\xc2"; return $bool ? "\xc3" : "\xc2";
} }
@ -203,7 +203,7 @@ namespace ncc\ZiProto;
* @param $int * @param $int
* @return string * @return string
*/ */
public function encodeInt($int) public function encodeInt($int): string
{ {
if ($int >= 0) if ($int >= 0)
{ {
@ -257,7 +257,7 @@ namespace ncc\ZiProto;
* @param $float * @param $float
* @return string * @return string
*/ */
public function encodeFloat($float) public function encodeFloat($float): string
{ {
return $this->isForceFloat32 return $this->isForceFloat32
? "\xca". pack('G', $float) ? "\xca". pack('G', $float)
@ -268,7 +268,7 @@ namespace ncc\ZiProto;
* @param $str * @param $str
* @return string * @return string
*/ */
public function encodeStr($str) public function encodeStr($str): string
{ {
$length = strlen($str); $length = strlen($str);
@ -294,7 +294,7 @@ namespace ncc\ZiProto;
* @param $str * @param $str
* @return string * @return string
*/ */
public function encodeBin($str) public function encodeBin($str): string
{ {
$length = strlen($str); $length = strlen($str);
@ -313,9 +313,9 @@ namespace ncc\ZiProto;
/** /**
* @param $array * @param $array
* @return false|string * @return string
*/ */
public function encodeArray($array) public function encodeArray($array): string
{ {
$data = $this->encodeArrayHeader(count($array)); $data = $this->encodeArrayHeader(count($array));
@ -331,7 +331,7 @@ namespace ncc\ZiProto;
* @param $size * @param $size
* @return string * @return string
*/ */
public function encodeArrayHeader($size) public function encodeArrayHeader($size): string
{ {
if ($size <= 0xf) if ($size <= 0xf)
{ {
@ -348,9 +348,9 @@ namespace ncc\ZiProto;
/** /**
* @param $map * @param $map
* @return false|string * @return string
*/ */
public function encodeMap($map) public function encodeMap($map): string
{ {
$data = $this->encodeMapHeader(count($map)); $data = $this->encodeMapHeader(count($map));
@ -391,7 +391,7 @@ namespace ncc\ZiProto;
* @param $size * @param $size
* @return string * @return string
*/ */
public function encodeMapHeader($size) public function encodeMapHeader($size): string
{ {
if ($size <= 0xf) if ($size <= 0xf)
{ {
@ -411,7 +411,7 @@ namespace ncc\ZiProto;
* @param $data * @param $data
* @return string * @return string
*/ */
public function encodeExt($type, $data) public function encodeExt($type, $data): string
{ {
$length = strlen($data); $length = strlen($data);

View file

@ -34,7 +34,7 @@ namespace ncc\ncc\ZiProto\TypeTransformer;
/** /**
* @param Packet $packer * @param Packet $packer
* @param $value * @param $value
* @return string * @return string|null
*/ */
public function pack(Packet $packer, $value): ?string public function pack(Packet $packer, $value): ?string
{ {

View file

@ -40,5 +40,5 @@ namespace ncc\ncc\ZiProto\TypeTransformer;
* @param int $extLength * @param int $extLength
* @return mixed * @return mixed
*/ */
public function decode(BufferStream $stream, int $extLength); public function decode(BufferStream $stream, int $extLength): mixed;
} }

View file

@ -27,7 +27,6 @@ namespace ncc\Interfaces;
use ncc\Exceptions\BuildException; use ncc\Exceptions\BuildException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Objects\Package; use ncc\Objects\Package;
use ncc\Objects\ProjectConfiguration; use ncc\Objects\ProjectConfiguration;
@ -57,7 +56,6 @@ namespace ncc\Interfaces;
* @throws BuildException * @throws BuildException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException
*/ */
public function build(): ?Package; public function build(): ?Package;
@ -88,7 +86,6 @@ namespace ncc\Interfaces;
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException
*/ */
public function compileExecutionPolicies(): void; public function compileExecutionPolicies(): void;

View file

@ -25,11 +25,8 @@ namespace ncc\Interfaces;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Objects\ExecutionPointers\ExecutionPointer;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
use ncc\Objects\ProjectConfiguration\ExecutionPolicy; use ncc\Objects\ProjectConfiguration\ExecutionPolicy;
use ncc\ThirdParty\Symfony\Process\Process;
interface RunnerInterface interface RunnerInterface
{ {

View file

@ -36,13 +36,11 @@
use ncc\Classes\PythonExtension\Python3Runner; use ncc\Classes\PythonExtension\Python3Runner;
use ncc\Classes\PythonExtension\PythonRunner; use ncc\Classes\PythonExtension\PythonRunner;
use ncc\Exceptions\AccessDeniedException; use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\ExecutionUnitNotFoundException;
use ncc\Exceptions\FileNotFoundException; use ncc\Exceptions\FileNotFoundException;
use ncc\Exceptions\InvalidScopeException; use ncc\Exceptions\InvalidScopeException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\NoAvailableUnitsException; use ncc\Exceptions\NoAvailableUnitsException;
use ncc\Exceptions\RunnerExecutionException; use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Objects\ExecutionPointers; use ncc\Objects\ExecutionPointers;
use ncc\Objects\Package; use ncc\Objects\Package;
use ncc\Objects\Package\ExecutionUnit; use ncc\Objects\Package\ExecutionUnit;
@ -166,9 +164,8 @@
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws UnsupportedRunnerException * @throws RunnerExecutionException
* @noinspection PhpUnused * @noinspection PhpUnused
* @noinspection DuplicatedCode
*/ */
public function addUnit(string $package, string $version, ExecutionUnit $unit, bool $temporary=false): void public function addUnit(string $package, string $version, ExecutionUnit $unit, bool $temporary=false): void
{ {
@ -209,7 +206,7 @@
Runners::python2 => Python2Runner::getFileExtension(), Runners::python2 => Python2Runner::getFileExtension(),
Runners::python3 => Python3Runner::getFileExtension(), Runners::python3 => Python3Runner::getFileExtension(),
Runners::lua => LuaRunner::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)); Console::outDebug(sprintf('bin_file=%s', $bin_file));
@ -258,7 +255,6 @@
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @noinspection DuplicatedCode
*/ */
public function removeUnit(string $package, string $version, string $name): bool public function removeUnit(string $package, string $version, string $name): bool
{ {
@ -347,12 +343,10 @@
* @param array $args * @param array $args
* @return int * @return int
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws ExecutionUnitNotFoundException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws NoAvailableUnitsException * @throws NoAvailableUnitsException
* @throws RunnerExecutionException * @throws RunnerExecutionException
* @throws UnsupportedRunnerException
*/ */
public function executeUnit(string $package, string $version, string $name, array $args=[]): int public function executeUnit(string $package, string $version, string $name, array $args=[]): int
{ {
@ -368,7 +362,7 @@
$unit = $execution_pointers->getUnit($name); $unit = $execution_pointers->getUnit($name);
if($unit == null) 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('unit=%s', $unit->ExecutionPolicy->Name));
Console::outDebug(sprintf('runner=%s', $unit->ExecutionPolicy->Runner)); Console::outDebug(sprintf('runner=%s', $unit->ExecutionPolicy->Runner));
@ -470,12 +464,10 @@
* @param string $unit_name * @param string $unit_name
* @return void * @return void
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws ExecutionUnitNotFoundException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws NoAvailableUnitsException * @throws NoAvailableUnitsException
* @throws RunnerExecutionException * @throws RunnerExecutionException
* @throws UnsupportedRunnerException
*/ */
public function temporaryExecute(Package $package, string $unit_name): void public function temporaryExecute(Package $package, string $unit_name): void
{ {
@ -522,12 +514,10 @@
* @param Process|null $process * @param Process|null $process
* @return bool * @return bool
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws ExecutionUnitNotFoundException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws NoAvailableUnitsException * @throws NoAvailableUnitsException
* @throws RunnerExecutionException * @throws RunnerExecutionException
* @throws UnsupportedRunnerException
*/ */
public function handleExit(string $package, string $version, ExitHandle $exitHandle, ?Process $process=null): bool public function handleExit(string $package, string $version, ExitHandle $exitHandle, ?Process $process=null): bool
{ {

View file

@ -20,8 +20,7 @@
* *
*/ */
/** @noinspection PhpPropertyOnlyWrittenInspection */ /** @noinspection PhpMissingFieldTypeInspection */
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Managers; namespace ncc\Managers;

View file

@ -51,6 +51,7 @@
use ncc\Exceptions\PackageLockException; use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException; use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackageParsingException; use ncc\Exceptions\PackageParsingException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\SymlinkException; use ncc\Exceptions\SymlinkException;
use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\VersionNotFoundException; use ncc\Exceptions\VersionNotFoundException;
@ -109,6 +110,7 @@
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws InstallationException * @throws InstallationException
* @throws InvalidPackageNameException
* @throws InvalidScopeException * @throws InvalidScopeException
* @throws MissingDependencyException * @throws MissingDependencyException
* @throws NotImplementedException * @throws NotImplementedException
@ -116,11 +118,10 @@
* @throws PackageLockException * @throws PackageLockException
* @throws PackageNotFoundException * @throws PackageNotFoundException
* @throws PackageParsingException * @throws PackageParsingException
* @throws UnsupportedCompilerExtensionException * @throws RunnerExecutionException
* @throws UnsupportedRunnerException
* @throws VersionNotFoundException
* @throws InvalidPackageNameException
* @throws SymlinkException * @throws SymlinkException
* @throws UnsupportedCompilerExtensionException
* @throws VersionNotFoundException
*/ */
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
{ {
@ -604,6 +605,7 @@
* @throws SymlinkException * @throws SymlinkException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws VersionNotFoundException * @throws VersionNotFoundException
* @throws RunnerExecutionException
*/ */
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null): void private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null): void
{ {
@ -930,7 +932,7 @@
$paths->getDataPath() . DIRECTORY_SEPARATOR . 'assembly' => $paths->getDataPath() . DIRECTORY_SEPARATOR . 'assembly' =>
ZiProto::encode($package->Assembly->toArray(true)), ZiProto::encode($package->Assembly->toArray(true)),
$paths->getDataPath() . DIRECTORY_SEPARATOR . 'ext' => $paths->getDataPath() . DIRECTORY_SEPARATOR . 'ext' =>
ZiProto::encode($package->Header->CompilerExtension->toArray(true)), ZiProto::encode($package->Header->CompilerExtension->toArray()),
$paths->getDataPath() . DIRECTORY_SEPARATOR . 'const' => $paths->getDataPath() . DIRECTORY_SEPARATOR . 'const' =>
ZiProto::encode($package->Header->RuntimeConstants), ZiProto::encode($package->Header->RuntimeConstants),
$paths->getDataPath() . DIRECTORY_SEPARATOR . 'dependencies' => $paths->getDataPath() . DIRECTORY_SEPARATOR . 'dependencies' =>

View file

@ -40,7 +40,6 @@
use ncc\Exceptions\ProjectAlreadyExistsException; use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Exceptions\ProjectConfigurationNotFoundException; use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\UnsupportedCompilerExtensionException; use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Objects\ProjectConfiguration; use ncc\Objects\ProjectConfiguration;
use ncc\Objects\ProjectConfiguration\Compiler; use ncc\Objects\ProjectConfiguration\Compiler;
use ncc\ThirdParty\Symfony\Uid\Uuid; use ncc\ThirdParty\Symfony\Uid\Uuid;
@ -192,14 +191,10 @@
// Process options // Process options
foreach($options as $option) foreach($options as $option)
{ {
switch($option) if ($option == InitializeProjectOptions::CREATE_SOURCE_DIRECTORY) {
{ if (!file_exists($this->ProjectConfiguration->Build->SourcePath)) {
case InitializeProjectOptions::CREATE_SOURCE_DIRECTORY: mkdir($this->ProjectConfiguration->Build->SourcePath);
if(!file_exists($this->ProjectConfiguration->Build->SourcePath)) }
{
mkdir($this->ProjectConfiguration->Build->SourcePath);
}
break;
} }
} }
} }
@ -227,7 +222,7 @@
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
*/ */
public function load() public function load(): void
{ {
if(!file_exists($this->ProjectFilePath) && !is_file($this->ProjectFilePath)) if(!file_exists($this->ProjectFilePath) && !is_file($this->ProjectFilePath))
throw new ProjectConfigurationNotFoundException('The project configuration file \'' . $this->ProjectFilePath . '\' was not found'); throw new ProjectConfigurationNotFoundException('The project configuration file \'' . $this->ProjectFilePath . '\' was not found');
@ -241,7 +236,7 @@
* @return void * @return void
* @throws MalformedJsonException * @throws MalformedJsonException
*/ */
public function save() public function save(): void
{ {
if(!$this->projectLoaded()) if(!$this->projectLoaded())
return; return;
@ -294,7 +289,6 @@
* @throws BuildException * @throws BuildException
* @throws PackagePreparationFailedException * @throws PackagePreparationFailedException
* @throws UnsupportedCompilerExtensionException * @throws UnsupportedCompilerExtensionException
* @throws UnsupportedRunnerException
*/ */
public function build(string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string public function build(string $build_configuration=BuildConfigurationValues::DefaultConfiguration): string
{ {

View file

@ -56,7 +56,6 @@
*/ */
public function __construct() public function __construct()
{ {
/** @noinspection PhpUnhandledExceptionInspection */
$this->DefinedSourcesPath = PathFinder::getRemoteSources(Scopes::System); $this->DefinedSourcesPath = PathFinder::getRemoteSources(Scopes::System);
$this->load(); $this->load();

View file

@ -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 * Syncs the symlink dictionary with the filesystem
* *

View file

@ -114,7 +114,7 @@ namespace ncc\Objects;
*/ */
public function setValue(string $value, bool $readonly=false): void 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'); throw new ConstantReadonlyException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly');
} }

View file

@ -129,7 +129,7 @@
* @param Dependency $dependency * @param Dependency $dependency
* @return void * @return void
*/ */
public function addDependency(Dependency $dependency) public function addDependency(Dependency $dependency): void
{ {
foreach($this->Dependencies as $dep) foreach($this->Dependencies as $dep)
{ {
@ -149,7 +149,7 @@
* @param string $name * @param string $name
* @return void * @return void
*/ */
private function removeDependency(string $name) private function removeDependency(string $name): void
{ {
foreach($this->Dependencies as $key => $dep) foreach($this->Dependencies as $key => $dep)
{ {

View file

@ -84,7 +84,7 @@
public function toArray(bool $bytecode=false): array public function toArray(bool $bytecode=false): array
{ {
return [ 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('runtime_constants') : 'runtime_constants') => $this->RuntimeConstants,
($bytecode ? Functions::cbc('compiler_version') : 'compiler_version') => $this->CompilerVersion, ($bytecode ? Functions::cbc('compiler_version') : 'compiler_version') => $this->CompilerVersion,
($bytecode ? Functions::cbc('update_source') : 'update_source') => ($this->UpdateSource?->toArray($bytecode) ?? null), ($bytecode ? Functions::cbc('update_source') : 'update_source') => ($this->UpdateSource?->toArray($bytecode) ?? null),

View file

@ -239,7 +239,7 @@
if(!file_exists($path) && Resolver::resolveScope() == Scopes::System) if(!file_exists($path) && Resolver::resolveScope() == Scopes::System)
{ {
$filesystem = new Filesystem(); $filesystem = new Filesystem();
$filesystem->mkdir($path, 0777); $filesystem->mkdir($path);
} }
return $path; return $path;

View file

@ -112,7 +112,7 @@
return [ return [
($bytecode ? Functions::cbc('version') : 'version') => $this->Version, ($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('dependencies') : 'dependencies') => $dependencies,
($bytecode ? Functions::cbc('execution_units') : 'execution_units') => $execution_units, ($bytecode ? Functions::cbc('execution_units') : 'execution_units') => $execution_units,
($bytecode ? Functions::cbc('main_execution_policy') : 'main_execution_policy') => $this->MainExecutionPolicy, ($bytecode ? Functions::cbc('main_execution_policy') : 'main_execution_policy') => $this->MainExecutionPolicy,

View file

@ -145,10 +145,9 @@
/** /**
* Returns an array representation of the object * Returns an array representation of the object
* *
* @param bool $bytecode
* @return array * @return array
*/ */
public function toArray(bool $bytecode=false): array public function toArray(): array
{ {
$return_results = []; $return_results = [];
if($this->Extension !== null && strlen($this->Extension) > 0) if($this->Extension !== null && strlen($this->Extension) > 0)

View file

@ -66,10 +66,9 @@
public $ExitHandlers; public $ExitHandlers;
/** /**
* @param bool $throw_exception
* @return bool * @return bool
*/ */
public function validate(bool $throw_exception=True): bool public function validate(): bool
{ {
// TODO: Implement validation method // TODO: Implement validation method
return true; return true;

View file

@ -88,7 +88,7 @@
{ {
$ReturnResults = []; $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; $ReturnResults[($bytecode ? Functions::cbc('options') : 'options')] = $this->Options;
if($this->UpdateSource !== null) if($this->UpdateSource !== null)

View file

@ -59,8 +59,6 @@
namespace ncc\Objects; namespace ncc\Objects;
use ncc\Abstracts\ProjectType;
class ProjectDetectionResults class ProjectDetectionResults
{ {
/** /**

View file

@ -174,7 +174,7 @@
$package = self::getPackageManager()->getPackage($package); $package = self::getPackageManager()->getPackage($package);
if($package == null) 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(); return $package->getDataPath();
} }

View file

@ -47,8 +47,8 @@ namespace ncc\Utilities;
use ncc\Exceptions\InvalidScopeException; use ncc\Exceptions\InvalidScopeException;
use ncc\Exceptions\IOException; use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException; use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedArchiveException; use ncc\Exceptions\UnsupportedArchiveException;
use ncc\Exceptions\UnsupportedRunnerException;
use ncc\Managers\ConfigurationManager; use ncc\Managers\ConfigurationManager;
use ncc\Managers\CredentialManager; use ncc\Managers\CredentialManager;
use ncc\Managers\PackageLockManager; use ncc\Managers\PackageLockManager;
@ -298,10 +298,10 @@ namespace ncc\Utilities;
* @param string $path * @param string $path
* @param ExecutionPolicy $policy * @param ExecutionPolicy $policy
* @return ExecutionUnit * @return ExecutionUnit
* @throws UnsupportedRunnerException
* @throws AccessDeniedException * @throws AccessDeniedException
* @throws FileNotFoundException * @throws FileNotFoundException
* @throws IOException * @throws IOException
* @throws RunnerExecutionException
*/ */
public static function compileRunner(string $path, ExecutionPolicy $policy): ExecutionUnit public static function compileRunner(string $path, ExecutionPolicy $policy): ExecutionUnit
{ {
@ -313,7 +313,7 @@ namespace ncc\Utilities;
Runners::python2 => Python2Runner::processUnit($path, $policy), Runners::python2 => Python2Runner::processUnit($path, $policy),
Runners::python3 => Python3Runner::processUnit($path, $policy), Runners::python3 => Python3Runner::processUnit($path, $policy),
Runners::lua => LuaRunner::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)) if (!in_array($mimeType, $supportedTypes))
throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"); throw new UnsupportedArchiveException("Unsupported archive type: $mimeType");
switch($mimeType) $command = match ($mimeType) {
{ 'application/zip' => [$unzip_executable, $path, '-d', $out_path],
case 'application/zip': 'application/x-tar' => [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path],
$command = [$unzip_executable, $path, '-d', $out_path]; 'application/x-gzip' => [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path],
break; 'application/x-bzip2' => [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path],
case 'application/x-tar': default => throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"),
$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;
}
Console::out("Extracting archive $path"); Console::out("Extracting archive $path");
$process = new Process($command); $process = new Process($command);
@ -746,7 +738,6 @@ namespace ncc\Utilities;
$minor = (string)null; $minor = (string)null;
$patch = (string)null; $patch = (string)null;
$buildmetadata = (string)null;
if(count($parts) >= 1) if(count($parts) >= 1)
$major = $parts[0]; $major = $parts[0];
if(count($parts) >= 2) if(count($parts) >= 2)
@ -945,7 +936,7 @@ namespace ncc\Utilities;
* @param string $input * @param string $input
* @return float|int|mixed|string * @return float|int|mixed|string
*/ */
public static function stringTypeCast(string $input) public static function stringTypeCast(string $input): mixed
{ {
if (is_numeric($input)) if (is_numeric($input))
{ {
@ -969,7 +960,7 @@ namespace ncc\Utilities;
* @return void * @return void
* @throws InvalidScopeException * @throws InvalidScopeException
*/ */
public static function finalizePermissions() public static function finalizePermissions(): void
{ {
if(Resolver::resolveScope() !== Scopes::System) if(Resolver::resolveScope() !== Scopes::System)
return; return;

View file

@ -292,7 +292,6 @@
* Detects the project type from the specified path * Detects the project type from the specified path
* *
* @param string $path * @param string $path
* @param array $exlucde
* @return ProjectDetectionResults * @return ProjectDetectionResults
*/ */
public static function detectProjectType(string $path): ProjectDetectionResults public static function detectProjectType(string $path): ProjectDetectionResults

View file

@ -48,8 +48,7 @@ namespace ncc\Utilities;
if ($beautify) $input = self::beautifyFilename($input); if ($beautify) $input = self::beautifyFilename($input);
// maximize filename length to 255 bytes http://serverfault.com/a/9548/44086 // maximize filename length to 255 bytes http://serverfault.com/a/9548/44086
$ext = pathinfo($input, PATHINFO_EXTENSION); $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 mb_strcut(pathinfo($input, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($input)) . ($ext ? '.' . $ext : '');
return $input;
} }
/** /**
@ -77,8 +76,6 @@ namespace ncc\Utilities;
// lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 // lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625
$input = mb_strtolower($input, mb_detect_encoding($input)); $input = mb_strtolower($input, mb_detect_encoding($input));
// ".file-name.-" becomes "file-name" // ".file-name.-" becomes "file-name"
$input = trim($input, '.-'); return trim($input, '.-');
return $input;
} }
} }

View file

@ -19,6 +19,8 @@
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
* *
*/ */
require('autoload.php'); use ncc\CLI\Main;
\ncc\CLI\Main::start($argv);
require('autoload.php');
Main::start($argv);

View file

@ -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 * @var NccVersionInformation|null
*/ */
@ -98,7 +98,9 @@ namespace ncc;
* Initializes the NCC environment * Initializes the NCC environment
* *
* @return bool * @return bool
* @throws Exceptions\FileNotFoundException * @throws AccessDeniedException
* @throws FileNotFoundException
* @throws IOException
* @throws RuntimeException * @throws RuntimeException
*/ */
public static function initialize(): bool public static function initialize(): bool
@ -146,7 +148,7 @@ namespace ncc;
*/ */
public static function getConstants(): array 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()'); throw new RuntimeException('NCC Must be initialized before executing ' . get_called_class() . '::getConstants()');
} }