- Removed unused exception PackageNotFoundException in \ncc\Exceptions in favor of PackageException

- Removed unused exception `ConstantReadonlyException` in `\ncc\Exceptions` in favor of `IntegrityException` & `\InvalidArgumentException`
 - Removed unused exception `InvalidConstantName` in `\ncc\Exceptions` in favor for `IntegrityException`
 - Removed unused exception `ComponentDecodeException` in `\ncc\Exceptions` in favor for `IntegrityException`
 - Removed unused exception `ResourceChecksumException` in `\ncc\Exceptions` in favor for `IntegrityException`
 - Removed unused exception `AutoloadGeneratorException` in `\ncc\Exceptions` in favor for `IOException`
 - Removed unused exception `SymlinkException` in `\ncc\Exceptions` in favor for `IOException`
 - Removed unused exception `PackageLockException` in `\ncc\Exceptions` in favor for `IOException`
This commit is contained in:
Netkas 2023-08-21 23:14:13 -04:00
parent cdbc87e4bc
commit 69d7b86534
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
30 changed files with 299 additions and 717 deletions

View file

@ -112,6 +112,7 @@ features.
- Updated `\ncc\Classes > GitClient > cloneRepository()` to throw `GitException` instead of `GitCloneException`
- Updated `\ncc\Classes > GitClient > checkout()` to throw `GitException` instead of `GitCheckoutException`
- Corrected code-smell and code style issues in `\ncc\Objects > PackageLock`
- Corrected code-smell and code style issues in `\ncc\Classes\PhpExtension > PhpRuntime`
### Removed
- Removed `FileNotFoundException` and `DirectoryNotFoundException` from `\ncc\Exceptions`
@ -158,6 +159,14 @@ features.
- Removed unused exception `MissingDependencyException` in `\ncc\Exceptions` (not used)
- Removed unused exception `PackageAlreadyInstalledException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `PackageFetchException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `PackageNotFoundException` in `\ncc\Exceptions` in favor of `PackageException`
- Removed unused exception `ConstantReadonlyException` in `\ncc\Exceptions` in favor of `IntegrityException` & `\InvalidArgumentException`
- Removed unused exception `InvalidConstantName` in `\ncc\Exceptions` in favor for `IntegrityException`
- Removed unused exception `ComponentDecodeException` in `\ncc\Exceptions` in favor for `IntegrityException`
- Removed unused exception `ResourceChecksumException` in `\ncc\Exceptions` in favor for `IntegrityException`
- Removed unused exception `AutoloadGeneratorException` in `\ncc\Exceptions` in favor for `IOException`
- Removed unused exception `SymlinkException` in `\ncc\Exceptions` in favor for `IOException`
- Removed unused exception `PackageLockException` in `\ncc\Exceptions` in favor for `IOException`

View file

@ -24,24 +24,22 @@ AuthenticationException
ResourceNotFoundException
PROJECT_ALREADY_EXISTS
NO_UNITS_FOUND
PACKAGE_NOT_FOUND
VERSION_NOT_FOUND
NO_AVAILABLE_UNITS
PackageLockException
PACKAGE_LOCK_EXCEPTION
PackageException
* PACKAGE_PREPARATION_FAILED
* PACKAGE_PARSING_EXCEPTION
PACKAGE_ALREADY_INSTALLED
PACKAGE_FETCH_EXCEPTION
* PACKAGE_ALREADY_INSTALLED
* PACKAGE_FETCH_EXCEPTION
- MISSING_DEPENDENCY
* PACKAGE_NOT_FOUND
IOException
IO_EXCEPTION
SYMLINK_EXCEPTION
* IO_EXCEPTION
* AUTOLOADER_GENERATOR_EXCEPTION
* SYMLINK_EXCEPTION
* PACKAGE_LOCK_EXCEPTION
NetworkException
* HTTP_EXCEPTION
@ -80,10 +78,10 @@ RuntimeException
USER_ABORTED_OPERATION
IntegrityException
CONSTANT_READ_ONLY
INVALID_CONSTANT_NAME
COMPONENT_DECODE_EXCEPTION
RESOURCE_CHECKSUM_EXCEPTION
* CONSTANT_READ_ONLY
* INVALID_CONSTANT_NAME
* COMPONENT_DECODE_EXCEPTION
* RESOURCE_CHECKSUM_EXCEPTION
AutoLoadException
AUTOLOAD_GENERATOR
- AUTOLOAD_GENERATOR

View file

@ -27,9 +27,7 @@
use ncc\Enums\ConsoleColors;
use ncc\Enums\Options\InstallPackageOptions;
use ncc\Enums\Scopes;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Managers\CredentialManager;
use ncc\Managers\PackageManager;
use ncc\Objects\CliHelpSection;
@ -376,7 +374,7 @@
{
$credential->unlock(Console::passwordInput(sprintf('Enter Password for %s: ', $credential->getName())));
}
catch (RuntimeException $e)
catch (Exception $e)
{
Console::outException(sprintf('Failed to unlock credential %s', $credential->getName()), $e, 1);
return;
@ -507,7 +505,7 @@
{
$dependency_package = $package_manager->getPackage($dependency->name);
}
catch (PackageLockException $e)
catch (IOException $e)
{
unset($e);
$dependency_package = null;
@ -519,7 +517,7 @@
{
$dependency_version = $dependency_package->getVersion($dependency->version);
}
catch (VersionNotFoundException $e)
catch (IOException $e)
{
unset($e);
$dependency_version = null;
@ -596,7 +594,7 @@
*
* @param $args
* @return void
* @throws VersionNotFoundException
* @throws IOException
*/
private static function uninstallPackage($args): void
{
@ -622,7 +620,7 @@
{
$package_entry = $package_manager->getPackage($selected_package);
}
catch (PackageLockException $e)
catch (IOException $e)
{
Console::outException('PackageLock error', $e, 1);
return;
@ -688,7 +686,7 @@
*
* @param $args
* @return void
* @throws PackageLockException
* @throws IOException
*/
private static function uninstallAllPackages($args): void
{

View file

@ -30,7 +30,6 @@
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Managers\ProjectManager;
use ncc\Objects\CliHelpSection;
use ncc\Objects\ProjectConfiguration\Compiler;
@ -217,11 +216,6 @@
Console::outException(sprintf('The project configuration is invalid: %s', $e->getMessage()), $e, 1);
return;
}
catch (ProjectAlreadyExistsException $e)
{
Console::outException('A project has already been initialized in \'' . $current_directory . '\'', $e, 1);
return;
}
catch(Exception $e)
{
Console::outException('There was an unexpected error while trying to initialize the project', $e, 1);

View file

@ -40,7 +40,6 @@
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\ServiceSourceInterface;
@ -82,7 +81,6 @@
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PathNotFoundException
* @throws RuntimeException
* @throws UserAbortedOperationException
@ -118,7 +116,6 @@
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PathNotFoundException
* @throws UserAbortedOperationException
*/
@ -188,7 +185,6 @@
* @throws MalformedJsonException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageNotFoundException
* @throws PathNotFoundException
*/
private static function compilePackages(string $composer_lock_path): array
@ -228,7 +224,7 @@
$composer_package = $composer_lock->getPackage($package->Name);
if ($composer_package === null)
{
throw new PackageNotFoundException(sprintf('Package "%s" not found in composer lock file', $package->Name));
throw new PackageException(sprintf('Package "%s" not found in composer lock file', $package->Name));
}
// Convert it to an NCC project configuration

View file

@ -36,7 +36,6 @@
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\VersionNotFoundException;
@ -274,7 +273,7 @@
$package = $package_lock_manager->getPackageLock()?->getPackage($dependency->Name);
if($package === null)
{
throw new PackageLockException('Cannot find package lock for dependency ' . $dependency->Name);
throw new IOException('Cannot find package lock for dependency ' . $dependency->Name);
}
$version = $package->getVersion($dependency->Version);
@ -294,11 +293,7 @@
$dependency->Source = 'libs' . DIRECTORY_SEPARATOR . sprintf('%s=%s.lib', $dependency->Name, $dependency->Version);
}
catch (VersionNotFoundException $e)
{
throw new PackageException('Static linking not possible, cannot find version ' . $dependency->Version . ' for dependency ' . $dependency->Name, $e);
}
catch (PackageLockException $e)
catch (IOException $e)
{
throw new PackageException('Static linking not possible, cannot find package lock for dependency ' . $dependency->Name, $e);
}

View file

@ -29,16 +29,15 @@
use Exception;
use ncc\Enums\ComponentDataType;
use ncc\Enums\ComponentFileExtensions;
use ncc\Exceptions\ComponentChecksumException;
use ncc\Exceptions\ComponentDecodeException;
use ncc\Exceptions\IntegrityException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\ResourceChecksumException;
use ncc\Interfaces\InstallerInterface;
use ncc\Objects\InstallationPaths;
use ncc\Objects\Package;
use ncc\Objects\Package\Component;
use ncc\Objects\Package\Resource;
use ncc\ThirdParty\nikic\PhpParser\Comment;
use ncc\ThirdParty\nikic\PhpParser\Node;
use ncc\ThirdParty\nikic\PhpParser\PrettyPrinter\Standard;
@ -75,8 +74,7 @@
*
* @param Component $component
* @return string|null
* @throws ComponentChecksumException
* @throws ComponentDecodeException
* @throws IntegrityException
* @throws NotSupportedException
*/
public function processComponent(Package\Component $component): ?string
@ -88,7 +86,7 @@
if(!$component->validate_checksum())
{
throw new ComponentChecksumException('Checksum validation failed for component ' . $component->name . ', the package may be corrupted.');
throw new IntegrityException(sprintf('Checksum validation failed for component: %s', $component->name));
}
switch($component->data_types)
@ -100,7 +98,7 @@
}
catch (Exception $e)
{
throw new ComponentDecodeException('Cannot decode component: ' . $component->name . ', ' . $e->getMessage(), $e);
throw new IntegrityException(sprintf('Cannot decode component: %s, %s', $component->name, $e->getMessage()));
}
return (new Standard())->prettyPrintFile($stmts);
@ -137,15 +135,15 @@
/**
* Processes the given resource and returns the string representation of the resource
*
* @param Package\Resource $resource
* @param Resource $resource
* @return string|null
* @throws ResourceChecksumException
* @throws IntegrityException
*/
public function processResource(Package\Resource $resource): ?string
{
if(!$resource->validateChecksum())
{
throw new ResourceChecksumException('Checksum validation failed for resource ' . $resource->Name . ', the package may be corrupted.');
throw new IntegrityException('Checksum validation failed for resource ' . $resource->Name . ', the package may be corrupted.');
}
return Base64::decode($resource->Data);

View file

@ -1,33 +1,32 @@
<?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.
*
*/
/*
* 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\PhpExtension;
namespace ncc\Classes\PhpExtension;
use Exception;
use ncc\Enums\Options\RuntimeImportOptions;
use ncc\Classes\NccExtension\ConstantCompiler;
use ncc\Exceptions\ConstantReadonlyException;
use ncc\Exceptions\ImportException;
use ncc\Exceptions\InvalidConstantNameException;
use ncc\Exceptions\IntegrityException;
use ncc\Interfaces\RuntimeInterface;
use ncc\Objects\PackageLock\VersionEntry;
use ncc\Objects\ProjectConfiguration\Assembly;
@ -54,7 +53,9 @@ namespace ncc\Classes\PhpExtension;
$assembly_path = $versionEntry->getInstallPaths()->getDataPath() . DIRECTORY_SEPARATOR . 'assembly';
if(!file_exists($assembly_path))
{
throw new ImportException('Cannot locate assembly file \'' . $assembly_path . '\'');
}
try
{
@ -85,29 +86,27 @@ namespace ncc\Classes\PhpExtension;
{
Constants::register($assembly->package, $name, $value, true);
}
catch (ConstantReadonlyException $e)
catch (IntegrityException $e)
{
trigger_error('Constant \'' . $name . '\' is readonly (' . $assembly->package . ')', E_USER_WARNING);
}
catch (InvalidConstantNameException $e)
{
throw new ImportException('Invalid constant name \'' . $name . '\' (' . $assembly->package . ')', $e);
trigger_error('Cannot set constant \'' . $name . '\', ' . $e->getMessage(), E_USER_WARNING);
}
}
}
if(file_exists($autoload_path) && !in_array(RuntimeImportOptions::IMPORT_AUTOLOADER, $options))
if(file_exists($autoload_path) && !in_array(RuntimeImportOptions::IMPORT_AUTOLOADER, $options, true))
{
require_once($autoload_path);
}
if(file_exists($static_files) && !in_array(RuntimeImportOptions::IMPORT_STATIC_FILES, $options))
if(file_exists($static_files) && !in_array(RuntimeImportOptions::IMPORT_STATIC_FILES, $options, true))
{
try
{
$static_files = ZiProto::decode(IO::fread($static_files));
foreach($static_files as $file)
{
require_once($file);
}
}
catch(Exception $e)
{
@ -116,9 +115,6 @@ namespace ncc\Classes\PhpExtension;
}
if(!file_exists($autoload_path) && !file_exists($static_files))
return false;
return true;
return !(!file_exists($autoload_path) && !file_exists($static_files));
}
}

View file

@ -43,46 +43,21 @@
*/
public const CONSTANT_READ_ONLY = -1709;
/**
* @see ProjectAlreadyExistsException
*/
public const PROJECT_ALREADY_EXISTS = -1713;
/**
* @see AutoloadGeneratorException
*/
public const AUTOLOAD_GENERATOR = -1714;
/**
* @see NoUnitsFoundException
*/
public const NO_UNITS_FOUND = -1715;
/**
* @see InvalidConstantNameException
*/
public const INVALID_CONSTANT_NAME = -1719;
/**
* @see BuildException
*/
public const BUILD_EXCEPTION = -1727;
/**
* @see PackageLockException
*/
public const PACKAGE_LOCK_EXCEPTION = -1729;
/**
* @see InstallationException
*/
public const INSTALLATION_EXCEPTION = -1730;
/**
* @see ComponentDecodeException
*/
public const COMPONENT_DECODE_EXCEPTION = -1732;
/**
* @see IOException
*/
@ -103,11 +78,6 @@
*/
public const NO_AVAILABLE_UNITS = -1742;
/**
* @see PackageNotFoundException
*/
public const PACKAGE_NOT_FOUND = -1745;
/**
* @see ComposerException
*/
@ -138,11 +108,6 @@
*/
public const ARCHIVE_EXCEPTION = -1764;
/**
* @see SymlinkException
*/
public const SYMLINK_EXCEPTION = -1768;
/**
* @see PathNotFoundException
*/
@ -168,6 +133,11 @@
*/
public const NETWORK_EXCEPTION = -1774;
/**
* @see IntegrityException
*/
public const INTEGRITY_EXCEPTION = -1775;
/**
* All the exception codes from NCC
*/
@ -175,29 +145,23 @@
self::MALFORMED_JSON,
self::RUNTIME,
self::CONSTANT_READ_ONLY,
self::PROJECT_ALREADY_EXISTS,
self::AUTOLOAD_GENERATOR,
self::NO_UNITS_FOUND,
self::INVALID_CONSTANT_NAME,
self::BUILD_EXCEPTION,
self::PACKAGE_LOCK_EXCEPTION,
self::INSTALLATION_EXCEPTION,
self::COMPONENT_DECODE_EXCEPTION,
self::IO_EXCEPTION,
self::VERSION_NOT_FOUND,
self::RUNNER_EXECUTION_EXCEPTION,
self::NO_AVAILABLE_UNITS,
self::PACKAGE_NOT_FOUND,
self::COMPOSER_EXCEPTION,
self::USER_ABORTED_OPERATION,
self::AUTHENTICATION_EXCEPTION,
self::NOT_SUPPORTED_EXCEPTION,
self::ARCHIVE_EXCEPTION,
self::SYMLINK_EXCEPTION,
self::PATH_NOT_FOUND,
self::GIT_EXCEPTION,
self::CONFIGURATION_EXCEPTION,
self::PACKAGE_EXCEPTION,
self::NETWORK_EXCEPTION
self::NETWORK_EXCEPTION,
self::INTEGRITY_EXCEPTION
];
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class AutoloadGeneratorException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::AUTOLOAD_GENERATOR, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class ComponentDecodeException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::COMPONENT_DECODE_EXCEPTION, $previous);
}
}

View file

@ -1,38 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
class ComposerNotAvailableException extends Exception
{
/**
* @param string $message
* @param $previous
*/
public function __construct(string $message = "", $previous = null)
{
parent::__construct($message, ExceptionCodes::COMPOSER_NOT_AVAILABLE, $previous);
}
}

View file

@ -1,40 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class ConstantReadonlyException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::ConstantReadonlyException, $previous);
}
}

View file

@ -0,0 +1,34 @@
<?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\Exceptions;
use ncc\Enums\ExceptionCodes;
use Throwable;
class IntegrityException extends \Exception
{
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::INTEGRITY_EXCEPTION, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class InvalidConstantNameException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::INVALID_CONSTANT_NAME, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageLockException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_LOCK_EXCEPTION, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class PackageNotFoundException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PACKAGE_NOT_FOUND, $previous);
}
}

View file

@ -1,40 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class ProjectAlreadyExistsException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::PROJECT_ALREADY_EXISTS, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use Throwable;
class ResourceChecksumException extends Exception
{
/**
* @param string $message
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
}
}

View file

@ -1,39 +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\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;
use Throwable;
class SymlinkException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::SYMLINK_EXCEPTION, $previous);
}
}

View file

@ -24,7 +24,6 @@ namespace ncc\Interfaces;
use Exception;
use ncc\Exceptions\ComponentChecksumException;
use ncc\Exceptions\ComponentDecodeException;
use ncc\Objects\InstallationPaths;
use ncc\Objects\Package;
use ncc\Objects\Package\Component;
@ -44,7 +43,6 @@ namespace ncc\Interfaces;
* @param Component $component
* @return string|null
* @throws ComponentChecksumException
* @throws ComponentDecodeException
*/
public function processComponent(Package\Component $component): ?string;

View file

@ -1,30 +1,28 @@
<?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.
*
*/
/*
* 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\Interfaces;
namespace ncc\Interfaces;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Objects\PackageLock\VersionEntry;
interface RuntimeInterface
@ -33,9 +31,7 @@ namespace ncc\Interfaces;
* @param VersionEntry $versionEntry
* @param array $options
* @return mixed
* @throws PackageNotFoundException
* @throws VersionNotFoundException
* @throws PackageLockException
* @throws IOException
*/
public static function import(VersionEntry $versionEntry, array $options=[]): bool;
}

View file

@ -1,26 +1,26 @@
<?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.
*
*/
/*
* 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.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
/** @noinspection PhpMissingFieldTypeInspection */
namespace ncc\Managers;
@ -28,7 +28,6 @@
use ncc\Enums\Scopes;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageLockException;
use ncc\Objects\PackageLock;
use ncc\Utilities\Console;
use ncc\Utilities\IO;
@ -61,7 +60,7 @@
{
$this->load();
}
catch (PackageLockException $e)
catch (IOException $e)
{
unset($e);
}
@ -71,7 +70,7 @@
* Loads the PackageLock from the disk
*
* @return void
* @throws PackageLockException
* @throws IOException
*/
public function load(): void
{
@ -89,7 +88,7 @@
{
Console::outDebug('package lock exists, loading from disk');
$data = IO::fread($this->PackageLockPath);
if(strlen($data) > 0)
if($data !== '')
{
$this->PackageLock = PackageLock::fromArray(ZiProto::decode($data));
}
@ -100,7 +99,7 @@
}
catch(Exception $e)
{
throw new PackageLockException('The PackageLock file cannot be parsed', $e);
throw new IOException('The PackageLock file cannot be parsed', $e);
}
}
else
@ -118,14 +117,14 @@
*
* @return void
* @throws AuthenticationException
* @throws PackageLockException
* @throws IOException
*/
public function save(): void
{
Console::outDebug(sprintf('saving package lock to \'%s\'', $this->PackageLockPath));
// Don't save something that isn't loaded lol
if($this->PackageLock == null)
if($this->PackageLock === null)
{
Console::outDebug('warning: PackageLock is null, not saving to disk');
return;
@ -144,7 +143,7 @@
}
catch(IOException $e)
{
throw new PackageLockException('Cannot save the package lock file to disk', $e);
throw new IOException('Cannot save the package lock file to disk', $e);
}
try
@ -155,7 +154,7 @@
}
catch(Exception $e)
{
throw new PackageLockException('Failed to synchronize symlinks', $e);
throw new IOException('Failed to synchronize symlinks', $e);
}
}
@ -163,7 +162,8 @@
* Constructs the package lock file if it doesn't exist
*
* @return void
* @throws PackageLockException
* @throws AuthenticationException
* @throws IOException
*/
public function constructLockFile(): void
{
@ -171,7 +171,7 @@
{
$this->load();
}
catch (PackageLockException $e)
catch (IOException $e)
{
unset($e);
$this->PackageLock = new PackageLock();
@ -182,12 +182,15 @@
/**
* @return PackageLock|null
* @throws PackageLockException
* @throws IOException
*/
public function getPackageLock(): ?PackageLock
{
if($this->PackageLock == null)
if($this->PackageLock === null)
{
$this->load();
}
return $this->PackageLock;
}
}

View file

@ -43,11 +43,8 @@
use ncc\Exceptions\IOException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\SymlinkException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Objects\DefinedRemoteSource;
use ncc\Objects\InstallationPaths;
@ -84,7 +81,7 @@
private $package_lock_manager;
/**
* @throws PackageLockException
* @throws IOException
*/
public function __construct()
{
@ -104,13 +101,10 @@
* @throws IOException
* @throws InstallationException
* @throws NotSupportedException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws PackageException
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
* @throws VersionNotFoundException
* @throws PackageException
*/
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
{
@ -648,11 +642,8 @@
* @throws InstallationException
* @throws NotSupportedException
* @throws PackageException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
* @throws VersionNotFoundException
*/
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
@ -703,7 +694,7 @@
break;
case DependencySourceType::STATIC:
throw new PackageNotFoundException('Static linking not possible, package ' . $dependency->name . ' is not installed');
throw new PackageException('Static linking not possible, package ' . $dependency->name . ' is not installed');
case DependencySourceType::REMOTE:
Console::outDebug('installing from remote source ' . $dependency->source);
@ -717,7 +708,7 @@
}
elseif(!$dependency_met)
{
throw new PackageNotFoundException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
throw new PackageException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
}
}
@ -726,7 +717,7 @@
*
* @param string $package
* @return PackageEntry|null
* @throws PackageLockException
* @throws IOException
*/
public function getPackage(string $package): ?PackageEntry
{
@ -740,8 +731,7 @@
* @param string $package
* @param string $version
* @return VersionEntry|null
* @throws VersionNotFoundException
* @throws PackageLockException
* @throws IOException
*/
public function getPackageVersion(string $package, string $version): ?VersionEntry
{
@ -754,9 +744,7 @@
*
* @param string $package
* @return VersionEntry|null
* @throws VersionNotFoundException
* @throws PackageLockException
* @noinspection PhpUnused
* @throws IOException
*/
public function getLatestVersion(string $package): ?VersionEntry
{
@ -768,8 +756,7 @@
* Returns an array of all packages and their installed versions
*
* @return array
* @throws PackageLockException
* @throws PackageLockException
* @throws IOException
*/
public function getInstalledPackages(): array
{
@ -797,7 +784,7 @@
$package = $this->getPackage($exploded[0]);
if($package === null)
{
throw new PackageNotFoundException('Package ' . $exploded[0] . ' not found');
throw new PackageException('Package ' . $exploded[0] . ' not found');
}
$version = $package->getVersion($exploded[1]);
@ -836,7 +823,7 @@
}
}
}
catch (PackageLockException $e)
catch (IOException $e)
{
unset($e);
}
@ -884,10 +871,7 @@
* @return void
* @throws AuthenticationException
* @throws IOException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws SymlinkException
* @throws VersionNotFoundException
* @throws PackageException
*/
public function uninstallPackageVersion(string $package, string $version): void
{
@ -899,7 +883,7 @@
$version_entry = $this->getPackageVersion($package, $version);
if($version_entry === null)
{
throw new PackageNotFoundException(sprintf('The package %s=%s was not found', $package, $version));
throw new PackageException(sprintf('The package %s=%s was not found', $package, $version));
}
Console::out(sprintf('Uninstalling %s=%s', $package, $version));
@ -963,9 +947,8 @@
* @param string $package
* @return void
* @throws AuthenticationException
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws VersionNotFoundException
* @throws IOException
* @throws PackageException
*/
public function uninstallPackage(string $package): void
{
@ -977,7 +960,7 @@
$package_entry = $this->getPackage($package);
if($package_entry === null)
{
throw new PackageNotFoundException(sprintf('The package %s was not found', $package));
throw new PackageException(sprintf('The package %s was not found', $package));
}
foreach($package_entry->getVersions() as $version)

View file

@ -34,7 +34,6 @@
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Objects\ProjectConfiguration;
use ncc\Objects\ProjectConfiguration\Compiler;
use ncc\ThirdParty\Symfony\Uid\Uuid;
@ -105,8 +104,8 @@
* @param string|null $src
* @param array $options
* @throws ConfigurationException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectAlreadyExistsException
*/
public function initializeProject(Compiler $compiler, string $name, string $package, ?string $src=null, array $options=[]): void
{
@ -123,7 +122,7 @@
if(file_exists($this->project_path . DIRECTORY_SEPARATOR . 'project.json'))
{
throw new ProjectAlreadyExistsException('A project has already been initialized in \'' . $this->project_path . DIRECTORY_SEPARATOR . 'project.json' . '\'');
throw new IOException('A project has already been initialized in \'' . $this->project_path . DIRECTORY_SEPARATOR . 'project.json' . '\'');
}
$this->project_configuration = new ProjectConfiguration();

View file

@ -27,7 +27,7 @@
use Exception;
use ncc\Enums\Scopes;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\SymlinkException;
use ncc\Exceptions\IOException;
use ncc\Objects\SymlinkDictionary\SymlinkEntry;
use ncc\ThirdParty\Symfony\Filesystem\Filesystem;
use ncc\Utilities\Console;
@ -85,7 +85,6 @@
*
* @return void
* @throws AuthenticationException
* @throws SymlinkException
*/
public function load(): void
{
@ -130,7 +129,7 @@
* @param bool $throw_exception
* @return void
* @throws AuthenticationException
* @throws SymlinkException
* @throws IOException
*/
private function save(bool $throw_exception=true): void
{
@ -154,7 +153,9 @@
catch(Exception $e)
{
if($throw_exception)
throw new SymlinkException(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath), $e);
{
throw new IOException(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath), $e);
}
Console::outWarning(sprintf('failed to save symlink dictionary to %s', $this->SymlinkDictionaryPath));
}
@ -204,7 +205,7 @@
* @param string $unit
* @return void
* @throws AuthenticationException
* @throws SymlinkException
* @throws IOException
*/
public function add(string $package, string $unit='main'): void
{
@ -232,7 +233,7 @@
* @param string $package
* @return void
* @throws AuthenticationException
* @throws SymlinkException
* @throws IOException
*/
public function remove(string $package): void
{
@ -258,7 +259,9 @@
$symlink = self::$BinPath . DIRECTORY_SEPARATOR . $symlink_name;
if($filesystem->exists($symlink))
{
$filesystem->remove($symlink);
}
}
unset($this->SymlinkDictionary[$key]);
@ -267,7 +270,7 @@
}
}
throw new SymlinkException(sprintf('failed to remove package %s from the symlink dictionary', $package));
throw new IOException(sprintf('failed to remove package %s from the symlink dictionary', $package));
}
/**
@ -276,7 +279,6 @@
* @param string $package
* @return void
* @throws AuthenticationException
* @throws SymlinkException
*/
private function setAsRegistered(string $package): void
{
@ -297,7 +299,6 @@
*
* @return void
* @throws AuthenticationException
* @throws SymlinkException
*/
public function sync(): void
{
@ -328,7 +329,7 @@
{
$package_entry = $package_lock_manager->getPackageLock()->getPackage($entry->Package);
if($package_entry == null)
if($package_entry === null)
{
Console::outWarning(sprintf('Package %s is not installed, skipping', $entry->Package));
continue;

View file

@ -1,28 +1,31 @@
<?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\Objects;
/** @noinspection PhpMissingFieldTypeInspection */
use ncc\Exceptions\ConstantReadonlyException;
/*
* 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\Objects;
use ncc\Exceptions\IntegrityException;
use ncc\Utilities\Resolver;
class Constant
@ -32,35 +35,35 @@ namespace ncc\Objects;
*
* @var string
*/
private $Hash;
private $hash;
/**
* The package that manages this constant
*
* @var string
*/
private $Scope;
private $scope;
/**
* The name of the constant
*
* @var string
*/
private $Name;
private $name;
/**
* The value of the constant
*
* @var string
*/
private $Value;
private $value;
/**
* Indicates if the constant is readonly or not
*
* @var bool
*/
private $Readonly;
private $readonly;
/**
* Public Constructor
@ -72,11 +75,11 @@ namespace ncc\Objects;
*/
public function __construct(string $scope, string $name, string $value, bool $readonly=false)
{
$this->Scope = $scope;
$this->Name = $name;
$this->Value = $value;
$this->Readonly = $readonly;
$this->Hash = Resolver::resolveConstantHash($this->Scope, $this->Name);
$this->scope = $scope;
$this->name = $name;
$this->value = $value;
$this->readonly = $readonly;
$this->hash = Resolver::resolveConstantHash($this->scope, $this->name);
}
/**
@ -86,7 +89,7 @@ namespace ncc\Objects;
*/
public function __toString(): string
{
return $this->Value;
return $this->value;
}
/**
@ -94,7 +97,7 @@ namespace ncc\Objects;
*/
public function getValue(): string
{
return $this->Value;
return $this->value;
}
/**
@ -104,23 +107,23 @@ namespace ncc\Objects;
*/
public function getFullName(): string
{
return Resolver::resolveFullConstantName($this->Scope, $this->Name);
return Resolver::resolveFullConstantName($this->scope, $this->name);
}
/**
* @param string $value
* @param bool $readonly
* @throws ConstantReadonlyException
* @throws IntegrityException
*/
public function setValue(string $value, bool $readonly=false): void
{
if($this->Readonly)
if($this->readonly)
{
throw new ConstantReadonlyException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly');
throw new IntegrityException('Cannot set value to the constant \'' . $this->getFullName() . '\', constant is readonly');
}
$this->Value = $value;
$this->Readonly = $readonly;
$this->value = $value;
$this->readonly = $readonly;
}
/**
@ -128,7 +131,7 @@ namespace ncc\Objects;
*/
public function isReadonly(): bool
{
return $this->Readonly;
return $this->readonly;
}
/**
@ -136,7 +139,7 @@ namespace ncc\Objects;
*/
public function getHash(): string
{
return $this->Hash;
return $this->hash;
}
/**
@ -144,7 +147,7 @@ namespace ncc\Objects;
*/
public function getScope(): string
{
return $this->Scope;
return $this->scope;
}
/**
@ -152,6 +155,6 @@ namespace ncc\Objects;
*/
public function getName(): string
{
return $this->Name;
return $this->name;
}
}

View file

@ -1,24 +1,24 @@
<?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.
*
*/
/*
* 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.
*
*/
/** @noinspection PhpMissingFieldTypeInspection */
@ -27,7 +27,7 @@
use ncc\Enums\Scopes;
use ncc\Enums\Versions;
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Exceptions\IOException;
use ncc\Objects\Package;
use ncc\Objects\ProjectConfiguration\UpdateSource;
use ncc\ThirdParty\jelix\Version\VersionComparator;
@ -80,7 +80,7 @@
* @param string $version
* @param bool $throw_exception
* @return VersionEntry|null
* @throws VersionNotFoundException
* @throws IOException
*/
public function getVersion(string $version, bool $throw_exception=false): ?VersionEntry
{
@ -100,7 +100,7 @@
if($throw_exception)
{
throw new VersionNotFoundException('The version entry is not found');
throw new IOException(sprintf('Version %s of %s is not installed', $version, $this->Name));
}
return null;
@ -163,7 +163,7 @@
$this->removeVersion($package->assembly->version);
}
}
catch (VersionNotFoundException $e)
catch (IOException $e)
{
unset($e);
}

View file

@ -28,12 +28,11 @@
use ncc\Enums\CompilerExtensions;
use ncc\Enums\Versions;
use ncc\Classes\PhpExtension\PhpRuntime;
use ncc\Exceptions\ConstantReadonlyException;
use ncc\Exceptions\ConfigurationException;
use ncc\Exceptions\ImportException;
use ncc\Exceptions\InvalidConstantNameException;
use ncc\Exceptions\PackageLockException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Exceptions\IntegrityException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PackageException;
use ncc\Managers\PackageManager;
use ncc\Objects\PackageLock\VersionEntry;
use ncc\Objects\ProjectConfiguration\Dependency;
@ -57,7 +56,7 @@
* @param string $package
* @param string $version
* @return bool
* @throws PackageLockException
* @throws IOException
*/
private static function isImported(string $package, string $version=Versions::LATEST): bool
{
@ -90,6 +89,7 @@
* @param string $version
* @param array $options
* @return void
* @throws IOException
* @throws ImportException
*/
public static function import(string $package, string $version=Versions::LATEST, array $options=[]): void
@ -98,10 +98,11 @@
{
$package_entry = self::getPackageManager()->getPackage($package);
}
catch (PackageLockException $e)
catch (IOException $e)
{
throw new ImportException(sprintf('Failed to import package "%s" due to a package lock exception: %s', $package, $e->getMessage()), $e);
}
if($package_entry === null)
{
throw new ImportException(sprintf("Package '%s' not found", $package));
@ -122,7 +123,7 @@
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package));
}
}
catch (VersionNotFoundException $e)
catch (IOException $e)
{
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package), $e);
}
@ -134,7 +135,7 @@
return;
}
}
catch (PackageLockException $e)
catch (IOException $e)
{
throw new ImportException(sprintf('Failed to check if package %s is imported', $package), $e);
}
@ -174,8 +175,9 @@
*
* @param string $package
* @return string
* @throws PackageLockException
* @throws PackageNotFoundException
* @throws ConfigurationException
* @throws IOException
* @throws PackageException
*/
public static function getDataPath(string $package): string
{
@ -183,7 +185,7 @@
if($package === null)
{
throw new PackageNotFoundException('Package not found (null entry error, possible bug)');
throw new PackageException('Package not found (null entry error, possible bug)');
}
return $package->getDataPath();
@ -231,8 +233,7 @@
* @param string $name
* @param string $value
* @return void
* @throws ConstantReadonlyException
* @throws InvalidConstantNameException
* @throws IntegrityException
*/
public static function setConstant(string $package, string $name, string $value): void
{

View file

@ -24,8 +24,8 @@
namespace ncc\Runtime;
use ncc\Exceptions\ConstantReadonlyException;
use ncc\Exceptions\InvalidConstantNameException;
use InvalidArgumentException;
use ncc\Exceptions\IntegrityException;
use ncc\Objects\Constant;
use ncc\Utilities\Resolver;
use ncc\Utilities\Validate;
@ -47,13 +47,14 @@
* @param string $value The value of the constant
* @param bool $readonly Indicates if the constant cannot be changed with the registerConstant function once it's registered
* @return void
* @throws ConstantReadonlyException
* @throws InvalidConstantNameException
* @throws IntegrityException
*/
public static function register(string $scope, string $name, string $value, bool $readonly=false): void
{
if(!Validate::constantName($name))
throw new InvalidConstantNameException('The name specified is not valid for a constant name');
{
throw new InvalidArgumentException(sprintf('The name \'%s\' is not a valid constant name', $name));
}
$constant_hash = Resolver::resolveConstantHash($scope, $name);
@ -72,18 +73,20 @@
* @param string $scope
* @param string $name
* @return void
* @throws ConstantReadonlyException
* @throws IntegrityException
*/
public static function delete(string $scope, string $name): void
{
if(!Validate::constantName($name))
{
return;
}
$constant_hash = Resolver::resolveConstantHash($scope, $name);
if(isset(self::$Constants[$constant_hash]) && self::$Constants[$constant_hash]->isReadonly())
{
throw new ConstantReadonlyException('Cannot delete the constant \'' . self::$Constants[$constant_hash]->getFullName() . '\', constant is readonly');
throw new IntegrityException('Cannot delete the constant \'' . self::$Constants[$constant_hash]->getFullName() . '\', constant is readonly');
}
unset(self::$Constants[$constant_hash]);
@ -99,12 +102,16 @@
public static function get(string $scope, string $name): ?string
{
if(!Validate::constantName($name))
{
return null;
}
$constant_hash = Resolver::resolveConstantHash($scope, $name);
if(isset(self::$Constants[$constant_hash]))
{
return self::$Constants[$constant_hash]->getValue();
}
return null;
}