self::UNSUPPORTED_EXTENSION_VERSION,

This commit is contained in:
Netkas 2023-08-20 17:38:36 -04:00
parent 57305c8b52
commit 14541123c0
No known key found for this signature in database
GPG key ID: 5DAF58535614062B
24 changed files with 236 additions and 435 deletions

View file

@ -121,6 +121,11 @@ features.
- Removed unused exception `GitCheckoutException` in `\ncc\Exceptions` in favor of `GitException`
- Removed unused exception `GithubServiceException` in `\ncc\Exceptions` in favor of `GitException`
- Removed unused exception `GitTagsException` in `\ncc\Exceptions` in favor of `GitException`
- Removed unused exception `GitlabServiceException` in `\ncc\Exceptions` in favor of `GitException`
- Removed unused exception `UnsupportedArchiveException` in `\ncc\Exceptions` in favor of `ArchiveException`
- Removed unused exception `NotImplementedException` in `\ncc\Exceptions` in favor of `NotSupportedException`
- Removed unused exception `UnsupportedCompilerExtensionException` in `\ncc\Exceptions` in favor of `NotSupportedException`
- Removed unused exception `UnsupportedExtensionVersionException` in `\ncc\Exceptions` (not used)

View file

@ -55,17 +55,17 @@ GitException
* GIT_CLONE_EXCEPTION
* GIT_CHECKOUT_EXCEPTION
* GITHUB_SERVICE_EXCEPTION
GITLAB_SERVICE_EXCEPTION
* GITLAB_SERVICE_EXCEPTION
* GIT_TAGS_EXCEPTION
ArchiveException
UNSUPPORTED_ARCHIVE
ARCHIVE_EXCEPTION
* UNSUPPORTED_ARCHIVE
* ARCHIVE_EXCEPTION
NotSupportedException
NOT_IMPLEMENTED
UNSUPPORTED_COMPILER_EXTENSION
UNSUPPORTED_EXTENSION_VERSION
* NOT_IMPLEMENTED
* UNSUPPORTED_COMPILER_EXTENSION
* UNSUPPORTED_EXTENSION_VERSION
UNSUPPORTED_COMPONENT_TYPE
NOT_SUPPORTED_EXCEPTION
UNSUPPORTED_PROJECT_TYPE

View file

@ -40,14 +40,12 @@ namespace ncc\Classes\ComposerExtension;
use ncc\Exceptions\ComposerNotAvailableException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\InternalComposerNotAvailableException;
use ncc\Exceptions\InvalidScopeException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackageNotFoundException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UserAbortedOperationException;
use ncc\Interfaces\ServiceSourceInterface;
use ncc\Managers\ProjectManager;
@ -89,14 +87,12 @@ namespace ncc\Classes\ComposerExtension;
* @throws ComposerNotAvailableException
* @throws IOException
* @throws InternalComposerNotAvailableException
* @throws InvalidScopeException
* @throws MalformedJsonException
* @throws PackageNotFoundException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
* @throws ProjectConfigurationNotFoundException
* @throws RuntimeException
* @throws UnsupportedCompilerExtensionException
* @throws UserAbortedOperationException
*/
public static function fetch(RemotePackageInput $packageInput): string
@ -136,7 +132,6 @@ namespace ncc\Classes\ComposerExtension;
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
* @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException
* @throws UserAbortedOperationException
*/
public static function fromLocal(string $path): string
@ -208,7 +203,6 @@ namespace ncc\Classes\ComposerExtension;
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
* @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException
*/
private static function compilePackages(string $composer_lock_path): array
{
@ -529,21 +523,19 @@ namespace ncc\Classes\ComposerExtension;
* @param string $package
* @param string|null $version
* @return string
* @throws AccessDeniedException
* @throws ComposerDisabledException
* @throws ComposerException
* @throws ComposerNotAvailableException
* @throws PathNotFoundException
* @throws IOException
* @throws InternalComposerNotAvailableException
* @throws InvalidScopeException
* @throws PathNotFoundException
* @throws UserAbortedOperationException
*/
private static function require(string $vendor, string $package, ?string $version = null): string
{
if (Resolver::resolveScope() !== Scopes::SYSTEM)
{
throw new AccessDeniedException('Insufficient permissions to require');
throw new \RuntimeException('Cannot require a package with insufficient permissions');
}
if ($version === null)
@ -693,10 +685,10 @@ namespace ncc\Classes\ComposerExtension;
* @param array $version_map
* @param mixed $composer_package
* @return ProjectConfiguration
* @throws AccessDeniedException
* @throws IOException
* @throws MalformedJsonException
* @throws PackagePreparationFailedException
* @throws PathNotFoundException
*/
private static function convertProject(string $package_path, array $version_map, ?ComposerJson $composer_package=null): ProjectConfiguration
{

View file

@ -27,7 +27,6 @@
use ncc\Classes\HttpClient;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitException;
use ncc\Exceptions\GitlabServiceException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\VersionNotFoundException;
@ -51,7 +50,6 @@
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitException
* @throws GitlabServiceException
* @throws HttpException
* @throws MalformedJsonException
*/
@ -78,20 +76,19 @@
/**
* Returns the download URL of the requested version of the package.
*
* @param RemotePackageInput $packageInput
* @param DefinedRemoteSource $definedRemoteSource
* @param RemotePackageInput $package_input
* @param DefinedRemoteSource $defined_remote_source
* @param Entry|null $entry
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitException
* @throws GitlabServiceException
* @throws HttpException
* @throws MalformedJsonException
* @throws VersionNotFoundException
*/
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
{
return self::processReleases($packageInput, $definedRemoteSource, $entry);
return self::processReleases($package_input, $defined_remote_source, $entry);
}
/**
@ -101,7 +98,6 @@
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitException
* @throws GitlabServiceException
* @throws HttpException
* @throws MalformedJsonException
* @throws VersionNotFoundException
@ -120,7 +116,6 @@
* @return array
* @throws AuthenticationException
* @throws GitException
* @throws GitlabServiceException
* @throws HttpException
* @throws MalformedJsonException
*/
@ -195,7 +190,6 @@
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
* @throws GitlabServiceException
*/
private static function getJsonResponse(HttpRequest $httpRequest, ?Entry $entry): array
{
@ -221,7 +215,6 @@
* @return mixed
* @throws AuthenticationException
* @throws GitException
* @throws GitlabServiceException
* @throws HttpException
* @throws MalformedJsonException
* @throws VersionNotFoundException

View file

@ -1,35 +1,35 @@
<?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\GitlabExtension;
use ncc\Enums\Versions;
use ncc\Classes\HttpClient;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitlabServiceException;
use ncc\Exceptions\GitException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Exceptions\ResourceNotFoundException;
use ncc\Interfaces\RepositorySourceInterface;
use ncc\Objects\DefinedRemoteSource;
use ncc\Objects\HttpRequest;
@ -50,7 +50,7 @@
* @param Entry|null $entry
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitlabServiceException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
*/
@ -69,8 +69,7 @@
if($response->StatusCode !== 200)
{
throw new GitlabServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
throw new GitException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
}
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);
@ -88,27 +87,27 @@
/**
* Returns the download URL of the requested version of the package.
*
* @param RemotePackageInput $packageInput
* @param DefinedRemoteSource $definedRemoteSource
* @param RemotePackageInput $package_input
* @param DefinedRemoteSource $defined_remote_source
* @param Entry|null $entry
* @return RepositoryQueryResults
* @throws AuthenticationException
* @throws GitlabServiceException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
* @throws VersionNotFoundException
* @throws ResourceNotFoundException
*/
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults
{
$releases = self::getReleases($packageInput->vendor, $packageInput->package, $definedRemoteSource, $entry);
$releases = self::getReleases($package_input->vendor, $package_input->package, $defined_remote_source, $entry);
if(count($releases) === 0)
{
throw new VersionNotFoundException('No releases found for the given repository.');
throw new ResourceNotFoundException(sprintf('No releases found for the repository %s/%s (selected version: %s)', $package_input->vendor, $package_input->package, $package_input->version));
}
// Query the latest package only
if($packageInput->version === Versions::LATEST)
if($package_input->version === Versions::LATEST)
{
$latest_version = null;
foreach($releases as $release)
@ -129,7 +128,7 @@
}
// Query a specific version
if(!isset($releases[$packageInput->version]))
if(!isset($releases[$package_input->version]))
{
// Find the closest thing to the requested version
$selected_version = null;
@ -141,7 +140,7 @@
continue;
}
if(VersionComparator::compareVersion($version, $packageInput->version) === 1)
if(VersionComparator::compareVersion($version, $package_input->version) === 1)
{
$selected_version = $version;
}
@ -149,18 +148,17 @@
if($selected_version === null)
{
throw new VersionNotFoundException('No releases found for the given repository.');
throw new ResourceNotFoundException(sprintf('Could not find a release for %s/%s with the version %s', $package_input->vendor, $package_input->package, $package_input->version));
}
}
else
{
$selected_version = $packageInput->version;
$selected_version = $package_input->version;
}
if(!isset($releases[$selected_version]))
{
throw new VersionNotFoundException(sprintf('No releases found for the given repository. (Selected version: %s)', $selected_version));
throw new ResourceNotFoundException(sprintf('Could not find a release for %s/%s with the version %s', $package_input->vendor, $package_input->package, $package_input->version));
}
return $releases[$selected_version];
@ -187,7 +185,7 @@
* @param Entry|null $entry
* @return array
* @throws AuthenticationException
* @throws GitlabServiceException
* @throws GitException
* @throws HttpException
* @throws MalformedJsonException
*/
@ -207,7 +205,7 @@
if($response->StatusCode !== 200)
{
throw new GitlabServiceException(sprintf('Failed to fetch releases for the given repository. Status code: %s', $response->StatusCode));
throw new GitException(sprintf('Failed to fetch releases for repository %s/%s. Status code: %s', $owner, $repository, $response->StatusCode));
}
$response_decoded = Functions::loadJson($response->Body, Functions::FORCE_ARRAY);

View file

@ -36,10 +36,10 @@
use ncc\Exceptions\BuildException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedProjectTypeException;
use ncc\Interfaces\CompilerInterface;
use ncc\Managers\ProjectManager;
@ -65,9 +65,9 @@
* @throws BuildException
* @throws IOException
* @throws MalformedJsonException
* @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException
* @throws NotSupportedException
* @throws PathNotFoundException
* @throws ProjectConfigurationNotFoundException
*/
public static function compile(ProjectManager $manager, string $build_configuration=BuildConfigurationValues::DEFAULT): string
{
@ -93,7 +93,7 @@
}
else
{
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
throw new NotSupportedException('The compiler extension \'' . $configuration->project->compiler->extension . '\' is not supported');
}
$build_configuration = $configuration->build->getBuildConfiguration($build_configuration)->name;

View file

@ -1,32 +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.
*
*/
namespace ncc\Enums;
use ncc\Exceptions\GitException;
use ncc\Exceptions\InvalidDependencyConfiguration;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\SymlinkException;
use ncc\Exceptions\UnsupportedArchiveException;
namespace ncc\Enums;
/**
* @author Zi Xing Narrakas
@ -104,16 +98,6 @@ namespace ncc\Enums;
*/
public const NO_UNITS_FOUND = -1715;
/**
* @see UnsupportedPackageException
*/
public const UNSUPPORTED_PACKAGE = -1716;
/**
* @see NotImplementedException
*/
public const NOT_IMPLEMENTED = -1717;
/**
* @see InvalidPackageException
*/
@ -139,11 +123,6 @@ namespace ncc\Enums;
*/
public const INVALID_PROJECT_BUILD_CONFIGURATION = -1722;
/**
* @see UnsupportedCompilerExtensionException
*/
public const UNSUPPORTED_COMPILER_EXTENSION = -1723;
/**
* @see InvalidPropertyValueException
*/
@ -154,11 +133,6 @@ namespace ncc\Enums;
*/
public const INVALID_VERSION_CONFIGURATION = -1725;
/**
* @see UnsupportedExtensionVersionException
*/
public const UNSUPPORTED_EXTENSION_VERSION = -1726;
/**
* @see BuildException
*/
@ -284,11 +258,6 @@ namespace ncc\Enums;
*/
public const UNSUPPORTED_REMOTE_SOURCE_TYPE = -1753;
/**
* @see GitlabServiceException
*/
public const GITLAB_SERVICE_EXCEPTION = -1756;
/**
* @see ImportException
*/
@ -309,11 +278,6 @@ namespace ncc\Enums;
*/
public const UNSUPPORTED_PROJECT_TYPE = -1762;
/**
* @see UnsupportedArchiveException
*/
public const UNSUPPORTED_ARCHIVE = -1763;
/**
* @see ArchiveException
*/
@ -349,6 +313,11 @@ namespace ncc\Enums;
*/
public const GIT_EXCEPTION = -1770;
/**
* @see ResourceNotFoundException
*/
public const RESOURCE_NOT_FOUND = -1771;
/**
* All the exception codes from NCC
*/
@ -367,17 +336,13 @@ namespace ncc\Enums;
self::PROJECT_ALREADY_EXISTS,
self::AUTOLOAD_GENERATOR,
self::NO_UNITS_FOUND,
self::UNSUPPORTED_PACKAGE,
self::NOT_IMPLEMENTED,
self::INVALID_PACKAGE,
self::INVALID_CONSTANT_NAME,
self::PACKAGE_PREPARATION_FAILED,
self::BUILD_CONFIGURATION_NOT_FOUND,
self::INVALID_PROJECT_BUILD_CONFIGURATION,
self::UNSUPPORTED_COMPILER_EXTENSION,
self::INVALID_PROPERTY_VALUE,
self::INVALID_VERSION_CONFIGURATION,
self::UNSUPPORTED_EXTENSION_VERSION,
self::BUILD_EXCEPTION,
self::PACKAGE_PARSING_EXCEPTION,
self::PACKAGE_LOCK_EXCEPTION,
@ -402,17 +367,16 @@ namespace ncc\Enums;
self::MISSING_DEPENDENCY,
self::HTTP_EXCEPTION,
self::UNSUPPORTED_REMOTE_SOURCE_TYPE,
self::GITLAB_SERVICE_EXCEPTION,
self::AUTHENTICATION_EXCEPTION,
self::NOT_SUPPORTED_EXCEPTION,
self::UNSUPPORTED_PROJECT_TYPE,
self::UNSUPPORTED_ARCHIVE,
self::ARCHIVE_EXCEPTION,
self::PACKAGE_FETCH_EXCEPTION,
self::INVALID_BUILD_CONFIGURATION,
self::INVALID_DEPENDENCY_CONFIGURATION,
self::SYMLINK_EXCEPTION,
self::PATH_NOT_FOUND,
self::GIT_EXCEPTION
self::GIT_EXCEPTION,
self::RESOURCE_NOT_FOUND,
];
}

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.
*
*/
namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;

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 GitlabServiceException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::GITLAB_SERVICE_EXCEPTION, $previous);
}
}

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.
*
*/
namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;

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 NotImplementedException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::NOT_IMPLEMENTED, $previous);
}
}

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.
*
*/
namespace ncc\Exceptions;
namespace ncc\Exceptions;
use Exception;
use ncc\Enums\ExceptionCodes;

View file

@ -0,0 +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\Exceptions;
class ResourceNotFoundException extends \Exception
{
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 UnsupportedArchiveException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::UNSUPPORTED_ARCHIVE, $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 UnsupportedCompilerExtensionException extends Exception
{
/**
* @param string $message
* @param Throwable|null $previous
*/
public function __construct(string $message = "", ?Throwable $previous = null)
{
parent::__construct($message, ExceptionCodes::UNSUPPORTED_COMPILER_EXTENSION, $previous);
}
}

View file

@ -42,12 +42,12 @@ namespace ncc\Interfaces;
/**
* Returns the release url of the repository, versions can be specified.
*
* @param RemotePackageInput $packageInput
* @param DefinedRemoteSource $definedRemoteSource
* @param RemotePackageInput $package_input
* @param DefinedRemoteSource $defined_remote_source
* @param Entry|null $entry
* @return RepositoryQueryResults
*/
public static function getRelease(RemotePackageInput $packageInput, DefinedRemoteSource $definedRemoteSource, ?Entry $entry = null): RepositoryQueryResults;
public static function getRelease(RemotePackageInput $package_input, DefinedRemoteSource $defined_remote_source, ?Entry $entry = null): RepositoryQueryResults;
/**
* Returns the download URL of the pre-compiled .ncc package if available

View file

@ -44,7 +44,7 @@
use ncc\Exceptions\InvalidScopeException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MissingDependencyException;
use ncc\Exceptions\NotImplementedException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\PackageAlreadyInstalledException;
use ncc\Exceptions\PackageFetchException;
use ncc\Exceptions\PackageLockException;
@ -53,7 +53,6 @@
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\SymlinkException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\VersionNotFoundException;
use ncc\Objects\DefinedRemoteSource;
use ncc\Objects\InstallationPaths;
@ -112,7 +111,7 @@
* @throws InvalidPackageNameException
* @throws InvalidScopeException
* @throws MissingDependencyException
* @throws NotImplementedException
* @throws NotSupportedException
* @throws PackageAlreadyInstalledException
* @throws PackageLockException
* @throws PackageNotFoundException
@ -120,7 +119,6 @@
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
* @throws UnsupportedCompilerExtensionException
* @throws VersionNotFoundException
*/
public function install(string $package_path, ?Entry $entry=null, array $options=[]): string
@ -149,7 +147,7 @@
$installer = match ($extension)
{
CompilerExtensions::PHP => new PhpInstaller($package),
default => throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $extension . '\' is not supported'),
default => throw new NotSupportedException(sprintf('Compiler extension %s is not supported with ncc', $extension))
};
if($this->getPackageVersion($package->assembly->package, $package->assembly->version) !== null)
@ -440,6 +438,7 @@
if($sources_manager->getRemoteSource($package->header->UpdateSource->repository->name) === null)
{
Console::outVerbose('Adding remote source ' . $package->header->UpdateSource->repository->name);
$defined_remote_source = new DefinedRemoteSource();
$defined_remote_source->name = $package->header->UpdateSource->repository->name;
$defined_remote_source->host = $package->header->UpdateSource->repository->host;
@ -463,7 +462,7 @@
* @param Entry|null $entry
* @return string
* @throws InstallationException
* @throws NotImplementedException
* @throws NotSupportedException
* @throws PackageFetchException
*/
public function fetchFromSource(string $source, ?Entry $entry=null): string
@ -504,7 +503,7 @@
}
}
throw new NotImplementedException('Builtin source type ' . $input->source . ' is not implemented');
throw new NotSupportedException(sprintf('Builtin source %s is not supported', $input->source));
}
if($remote_source_type === RemoteSourceType::DEFINED)
@ -659,7 +658,7 @@
* @throws InvalidPackageNameException
* @throws InvalidScopeException
* @throws MissingDependencyException
* @throws NotImplementedException
* @throws NotSupportedException
* @throws PackageAlreadyInstalledException
* @throws PackageLockException
* @throws PackageNotFoundException
@ -667,9 +666,7 @@
* @throws PathNotFoundException
* @throws RunnerExecutionException
* @throws SymlinkException
* @throws UnsupportedCompilerExtensionException
* @throws VersionNotFoundException
* @throws PathNotFoundException
*/
private function processDependency(Dependency $dependency, Package $package, string $package_path, ?Entry $entry=null, array $options=[]): void
{
@ -728,12 +725,12 @@
break;
default:
throw new NotImplementedException('Dependency source type ' . $dependency->source_type . ' is not implemented');
throw new NotSupportedException(sprintf('Dependency source type %s is not supported', $dependency->source_type));
}
}
elseif(!$dependency_met)
{
throw new MissingDependencyException(sprintf('The dependency %s=%s for %s=%s is not met', $dependency->name, $dependency->version, $package->assembly->package, $package->assembly->version));
throw new PackageNotFoundException(sprintf('Required dependency %s=%s is not installed', $dependency->name, $dependency->version));
}
}

View file

@ -35,11 +35,9 @@
use ncc\Exceptions\InvalidProjectNameException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PackagePreparationFailedException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\ProjectAlreadyExistsException;
use ncc\Exceptions\ProjectConfigurationNotFoundException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Objects\ProjectConfiguration;
use ncc\Objects\ProjectConfiguration\Compiler;
use ncc\ThirdParty\Symfony\Uid\Uuid;
@ -294,7 +292,6 @@
* @throws MalformedJsonException
* @throws PathNotFoundException
* @throws ProjectConfigurationNotFoundException
* @throws UnsupportedCompilerExtensionException
*/
public function build(string $build_configuration=BuildConfigurationValues::DEFAULT): string
{

View file

@ -26,7 +26,6 @@
use Exception;
use ncc\Enums\Options\BuildConfigurationValues;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\BuildConfigurationNotFoundException;
use ncc\Exceptions\InvalidBuildConfigurationException;
use ncc\Exceptions\InvalidConstantNameException;
@ -38,8 +37,6 @@
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UndefinedExecutionPolicyException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedExtensionVersionException;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Objects\ProjectConfiguration\Assembly;
use ncc\Objects\ProjectConfiguration\Build;
@ -113,8 +110,6 @@
* @throws InvalidPropertyValueException
* @throws RuntimeException
* @throws UndefinedExecutionPolicyException
* @throws UnsupportedCompilerExtensionException
* @throws UnsupportedExtensionVersionException
* @throws InvalidBuildConfigurationException
*/
public function validate(bool $throw_exception=True): bool
@ -403,7 +398,6 @@
*
* @param string $path
* @return ProjectConfiguration
* @throws AccessDeniedException
* @throws IOException
* @throws MalformedJsonException
* @throws PathNotFoundException

View file

@ -29,9 +29,8 @@
use ncc\Enums\CompilerExtensionSupportedVersions;
use ncc\Exceptions\InvalidPropertyValueException;
use ncc\Exceptions\InvalidVersionConfigurationException;
use ncc\Exceptions\NotSupportedException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedExtensionVersionException;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\ThirdParty\jelix\Version\VersionComparator;
use ncc\Utilities\Functions;
@ -69,9 +68,8 @@
* @param bool $throw_exception
* @return bool
* @throws InvalidPropertyValueException
* @throws NotSupportedException
* @throws RuntimeException
* @throws UnsupportedCompilerExtensionException
* @throws UnsupportedExtensionVersionException
*/
public function validate(bool $throw_exception=True): bool
{
@ -126,7 +124,7 @@
{
if($throw_exception)
{
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported');
}
return False;
@ -139,7 +137,7 @@
{
if($throw_exception)
{
throw new UnsupportedExtensionVersionException('The MaximumVersion does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension);
throw new NotSupportedException('The MaximumVersion does not support version ' . $this->maximum_version . ' for the extension ' . $this->extension);
}
return False;
}
@ -148,14 +146,14 @@
{
if($throw_exception)
{
throw new UnsupportedExtensionVersionException('The MinimumVersion does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension);
throw new NotSupportedException('The MinimumVersion does not support version ' . $this->minimum_version . ' for the extension ' . $this->extension);
}
return False;
}
break;
default:
throw new UnsupportedCompilerExtensionException('The compiler extension \'' . $this->extension . '\' is not supported');
throw new NotSupportedException('The compiler extension \'' . $this->extension . '\' is not supported');
}
return True;

View file

@ -26,8 +26,6 @@
use ncc\Exceptions\InvalidPropertyValueException;
use ncc\Exceptions\RuntimeException;
use ncc\Exceptions\UnsupportedCompilerExtensionException;
use ncc\Exceptions\UnsupportedExtensionVersionException;
use ncc\Interfaces\BytecodeObjectInterface;
use ncc\Utilities\Functions;
@ -68,8 +66,6 @@
* @return bool
* @throws InvalidPropertyValueException
* @throws RuntimeException
* @throws UnsupportedCompilerExtensionException
* @throws UnsupportedExtensionVersionException
*/
public function validate(bool $throw_exception=True): bool
{

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 */
@ -109,7 +109,7 @@
if($version === Versions::LATEST)
{
$version = $package_entry->getLatestVersion();
$version = $package_entry?->getLatestVersion();
}
try
@ -119,7 +119,7 @@
if($version_entry === null)
{
throw new VersionNotFoundException();
throw new ImportException(sprintf('Version %s of %s is not installed', $version, $package));
}
}
catch (VersionNotFoundException $e)

View file

@ -42,13 +42,11 @@
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\ArchiveException;
use ncc\Exceptions\AuthenticationException;
use ncc\Exceptions\GitlabServiceException;
use ncc\Exceptions\HttpException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\MalformedJsonException;
use ncc\Exceptions\PathNotFoundException;
use ncc\Exceptions\RunnerExecutionException;
use ncc\Exceptions\UnsupportedArchiveException;
use ncc\Managers\ConfigurationManager;
use ncc\Managers\CredentialManager;
use ncc\Managers\PackageLockManager;
@ -123,7 +121,6 @@
* @param string $path
* @param int $flags
* @return mixed
* @throws AccessDeniedException
* @throws IOException
* @throws MalformedJsonException
* @throws PathNotFoundException
@ -231,8 +228,8 @@
* @param string $copyright
* @param bool $basic_ascii
* @return string
* @throws AccessDeniedException
* @throws IOException
* @throws PathNotFoundException
*/
public static function getBanner(string $version, string $copyright, bool $basic_ascii=false): string
{
@ -424,9 +421,9 @@
*
* @param string $path
* @return ComposerJson
* @throws AccessDeniedException
* @throws IOException
* @throws MalformedJsonException
* @throws PathNotFoundException
*/
public static function loadComposerJson(string $path): ComposerJson
{
@ -568,7 +565,6 @@
* @param bool $expect_json
* @return HttpRequest
* @throws AuthenticationException
* @throws GitlabServiceException
*/
public static function prepareGitServiceRequest(HttpRequest $http_request, ?Entry $entry=null, bool $expect_json=true): HttpRequest
{
@ -576,7 +572,7 @@
{
if(!$entry->isCurrentlyDecrypted())
{
throw new GitlabServiceException('The given Vault entry is not decrypted.');
throw new RuntimeException('The given Vault entry is not decrypted.');
}
switch ($entry->getPassword()?->getAuthenticationType())
@ -586,7 +582,7 @@
break;
case AuthenticationType::USERNAME_PASSWORD:
throw new AuthenticationException('Username/Password authentication is not supported');
throw new AuthenticationException(sprintf('The given Vault entry is using the %s authentication type, which is not supported for Gitlab', AuthenticationType::USERNAME_PASSWORD));
}
}
@ -606,7 +602,6 @@
* @param Entry|null $entry
* @return string
* @throws AuthenticationException
* @throws GitlabServiceException
* @throws HttpException
*/
public static function downloadGitServiceFile(string $url, ?Entry $entry=null): string
@ -633,7 +628,6 @@
* @param string $path
* @return string|null
* @throws ArchiveException
* @throws UnsupportedArchiveException
*/
public static function extractArchive(string $path): ?string
{
@ -650,12 +644,12 @@
RuntimeCache::setFileAsTemporary($out_path);
$mimeType = mime_content_type($path);
$supportedTypes = [];
$mime_type = mime_content_type($path);
$supported_types = [];
if($unzip_executable !== null)
{
$supportedTypes = array_merge($supportedTypes, [
$supported_types = array_merge($supported_types, [
'application/zip',
'application/x-zip',
'application/x-zip-compressed',
@ -673,7 +667,7 @@
if($tar_executable !== null)
{
$supportedTypes = array_merge($supportedTypes, [
$supported_types = array_merge($supported_types, [
'application/x-tar',
'application/x-gzip',
'application/x-bzip2',
@ -686,17 +680,17 @@
RuntimeCache::set('warning_tar_shown', true);
}
if(!in_array($mimeType, $supportedTypes, true))
if(!in_array($mime_type, $supported_types, true))
{
throw new UnsupportedArchiveException("Unsupported archive type: $mimeType");
throw new ArchiveException(sprintf('Cannot extract archive %s, unsupported archive type %s', $path, $mime_type));
}
$command = match ($mimeType) {
$command = match ($mime_type) {
'application/zip' => [$unzip_executable, $path, '-d', $out_path],
'application/x-tar' => [$tar_executable, '--verbose', '-xf', $path, '-C', $out_path],
'application/x-gzip' => [$tar_executable, '--verbose', '-xzf', $path, '-C', $out_path],
'application/x-bzip2' => [$tar_executable, '--verbose', '-xjf', $path, '-C', $out_path],
default => throw new UnsupportedArchiveException("Unsupported archive type: $mimeType"),
default => throw new ArchiveException(sprintf('Cannot extract archive %s, unsupported archive type %s', $path, $mime_type)),
};
Console::out("Extracting archive $path");

View file

@ -22,7 +22,6 @@
namespace ncc\Utilities;
use ncc\Exceptions\AccessDeniedException;
use ncc\Exceptions\IOException;
use ncc\Exceptions\PathNotFoundException;
use SplFileInfo;
@ -81,7 +80,6 @@
* @param string $mode
* @param int|null $length
* @return string
* @throws AccessDeniedException
* @throws IOException
* @throws PathNotFoundException
*/
@ -101,7 +99,7 @@
if(!is_readable($uri))
{
throw new AccessDeniedException(sprintf('Unable to read file: (%s)', $uri));
throw new IOException(sprintf('Unable to read file (permission issue?): (%s)', $uri));
}
$file = new SplFileObject($uri, $mode);