diff --git a/Makefile b/Makefile index bad0bd8..5a12f6e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,46 @@ autoload: - phpab --output src/ncc/autoload.php src/ncc + # Generates/creates all the autoloader files + make src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php + make src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php + make src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php + make src/ncc/ThirdParty/Symfony/Process/autoload_spl.php + make src/ncc/ThirdParty/Symfony/uid/autoload_spl.php + make src/ncc/autoload_spl.php + cp src/autoload/autoload.php src/ncc/autoload.php -redist: +src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php: + phpab --output src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php \ + src/ncc/ThirdParty/defuse/php-encryption + +src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php: + phpab --output src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php \ + src/ncc/ThirdParty/Symfony/polyfill-ctype + +src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php: + phpab --output src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php \ + src/ncc/ThirdParty/Symfony/polyfill-mbstring + +src/ncc/ThirdParty/Symfony/Process/autoload_spl.php: + phpab --output src/ncc/ThirdParty/Symfony/Process/autoload_spl.php \ + src/ncc/ThirdParty/Symfony/Process + +src/ncc/ThirdParty/Symfony/uid/autoload_spl.php: + phpab --output src/ncc/ThirdParty/Symfony/uid/autoload_spl.php \ + src/ncc/ThirdParty/Symfony/uid + +src/ncc/autoload_spl.php: + phpab --output src/ncc/autoload_spl.php \ + src/ncc/Abstracts \ + src/ncc/CLI \ + src/ncc/Exceptions \ + src/ncc/Extensions \ + src/ncc/Managers \ + src/ncc/Objects \ + src/ncc/Runtime \ + src/ncc/Utilities \ + src/ncc/ncc.php + +redist: autoload rm -rf build mkdir build build/src cp -rf src/ncc/* build/src @@ -10,7 +49,16 @@ redist: cp LICENSE build/src/LICENSE cp README.md build/src/README.md cp src/installer/hash_check.php build/src/hash_check.php; php build/src/hash_check.php; rm build/src/hash_check.php + cp src/installer/generate_build_files.php build/src/generate_build_files.php; php build/src/generate_build_files.php; rm build/src/generate_build_files.php tar: - rm -f build/ncc.tar.gz - cd build/src; tar -czvf ../ncc.tar.gz * \ No newline at end of file + cd build/src; tar -czvf ../ncc.tar.gz * + +clean: + rm -rf build + rm -f src/ncc/autoload_spl.php + rm -f src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php + rm -f src/ncc/ThirdParty/Symfony/polyfill-ctype/autoload_spl.php + rm -f src/ncc/ThirdParty/Symfony/polyfill-mbstring/autoload_spl.php + rm -f src/ncc/ThirdParty/Symfony/Process/autoload_spl.php + rm -f src/ncc/ThirdParty/Symfony/uid/autoload_spl.php \ No newline at end of file diff --git a/src/autoload/autoload.php b/src/autoload/autoload.php new file mode 100644 index 0000000..b63ec63 --- /dev/null +++ b/src/autoload/autoload.php @@ -0,0 +1,32 @@ + $value) + { + $path = realpath($dir . DIRECTORY_SEPARATOR . $value); + if (!is_dir($path)) + { + $results[] = str_ireplace(__DIR__ . DIRECTORY_SEPARATOR, (string)null, $path); + } + else if ($value != '.' && $value != '..') + { + $results[] = str_ireplace(__DIR__ . DIRECTORY_SEPARATOR, (string)null, $path); + scanContents($path, $results); + } + } + + return $results; + } + + $excluded_files = [ + 'hash_check.php', + 'generate_build_files.php', + 'installer', + 'checksum.bin'. + 'build_files' + ]; + + ncc\Utilities\Console::out('Creating build_files ...'); + + if(file_exists('build_files')) + { + unlink('build_files'); + } + + $build_files_content = []; + foreach(scanContents(__DIR__) as $path) + { + if(!in_array($path, $excluded_files)) + { + $build_files_content[] = $path; + } + } + $build_files = fopen(__DIR__ . DIRECTORY_SEPARATOR . 'build_files', 'a+'); + fwrite($build_files, implode("\n", $build_files_content)); + fclose($build_files); + ncc\Utilities\Console::out('Created build_files'); + exit(0); \ No newline at end of file diff --git a/src/installer/hash_check.php b/src/installer/hash_check.php index 5cc03ef..47ce688 100644 --- a/src/installer/hash_check.php +++ b/src/installer/hash_check.php @@ -33,7 +33,9 @@ $excluded_files = [ 'hash_check.php', - 'checksum.bin' + 'generate_build_files.php', + 'checksum.bin', + 'build_files' ]; $hash_values = []; diff --git a/src/installer/installer b/src/installer/installer index 3035242..ce43c6a 100644 --- a/src/installer/installer +++ b/src/installer/installer @@ -11,12 +11,16 @@ # ------------------------------------------------------------------ $hash) { - if(hash_file('sha256', __DIR__ . DIRECTORY_SEPARATOR . $file) !== $hash) + if(file_exists(__DIR__ . DIRECTORY_SEPARATOR . $file) == false) + { + \ncc\Utilities\Console::outError('Cannot check file, \'' . $file . '\' not found.'); + $checksum_failed = true; + } + elseif(hash_file('sha256', __DIR__ . DIRECTORY_SEPARATOR . $file) !== $hash) { \ncc\Utilities\Console::outWarning('The file \'' . $file . '\' does not match the original checksum'); $checksum_failed = true; @@ -55,6 +78,62 @@ } } + // Check for required extensions + foreach(\ncc\Utilities\Validate::requiredExtensions() as $ext => $installed) + { + if(!$installed) + { + \ncc\Utilities\Console::outWarning('The extension \'' . $ext . '\' is not installed, compatibility without it is not guaranteed'); + } + } + // Start of installer \ncc\Utilities\Console::out('Started NCC installer'); + + // Determine the installation path + // TODO: Add the ability to change the data path as well + while(true) + { + $user_input = null; + $user_input = \ncc\Utilities\Console::getInput("Installation Path (Default: $NCC_INSTALL_PATH): "); + if(strlen($user_input) > 0) + { + if(file_exists($user_input)) + { + if(file_exists($user_input . DIRECTORY_SEPARATOR . 'ncc')) + { + \ncc\Utilities\Console::out('NCC Seems to already be installed, the installer will repair/upgrade your current install'); + break; + } + else + { + \ncc\Utilities\Console::outError('The given directory already exists, it must be deleted before proceeding'); + } + } + else + { + break; + } + } + else + { + break; + } + } + + \ncc\Utilities\Console::out("Note: This doesn't affect your current install of composer (if you have composer installed)"); + $update_composer = \ncc\Utilities\Console::getBooleanInput('Do you want to install composer for NCC? (Recommended)'); + + // Prepare installation + if(file_exists($NCC_INSTALL_PATH)) + { + // TODO: Implement recursive directory removal + } + + mkdir($NCC_INSTALL_PATH); + mkdir($NCC_DATA_PATH); + + // Install composer + + // Install NCC ?> \ No newline at end of file diff --git a/src/ncc/ncc.sh b/src/installer/ncc.sh similarity index 100% rename from src/ncc/ncc.sh rename to src/installer/ncc.sh diff --git a/src/ncc/Abstracts/RegexPatterns.php b/src/ncc/Abstracts/RegexPatterns.php index e7dae3d..31da2d3 100644 --- a/src/ncc/Abstracts/RegexPatterns.php +++ b/src/ncc/Abstracts/RegexPatterns.php @@ -17,4 +17,8 @@ const PythonVersionFormat = '/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?$/'; const SemanticVersioning2 = '/^(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)(?:-(?P(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/m'; + + const UnixPath = '/^(((?:\.\/|\.\.\/|\/)?(?:\.?\w+\/)*)(\.?\w+\.?\w+))$/m'; + + const WindowsPath = '/^(([%][^\/:*?<>""|]*[%])|([a-zA-Z][:])|(\\\\))((\\\\{1})|((\\\\{1})[^\\\\]([^\/:*?<>""|]*))+)$/m'; } \ No newline at end of file diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index 00ee427..102bbab 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -176,8 +176,7 @@ print($prompt); } - $handle = fopen ("php://stdin","r"); - return fgets($handle); + return rtrim(fgets(STDIN), "\n"); } /** @@ -209,15 +208,16 @@ { if($display_options) { - $r = self::getInput($prompt . ' (Y/N): ', false); + $r = self::getInput($prompt . ' (Y/N): '); } else { - $r = self::getInput($prompt, false); + $r = self::getInput($prompt); } if(strlen($r) > 0) { + print($r); switch(strtoupper($r)) { case '1': diff --git a/src/ncc/Utilities/Validate.php b/src/ncc/Utilities/Validate.php index 98485b7..b236353 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -155,4 +155,35 @@ return true; } + /** + * Determines if a Unix filepath is valid + * + * @param $input + * @return bool + */ + public static function unixFilepath($input): bool + { + if(preg_match(RegexPatterns::UnixPath, $input)) + { + return true; + } + + return false; + } + + /** + * Determines if a Windows filepath is valid + * + * @param $input + * @return bool + */ + public static function windowsFilepath($input): bool + { + if(preg_match(RegexPatterns::WindowsPath, $input)) + { + return true; + } + + return false; + } } \ No newline at end of file diff --git a/src/ncc/autoload.php b/src/ncc/autoload.php index 9be2818..ef48c7b 100644 --- a/src/ncc/autoload.php +++ b/src/ncc/autoload.php @@ -1,143 +1,26 @@ '/Abstracts/AuthenticationSource.php', - 'ncc\\abstracts\\consolecolors' => '/Abstracts/ConsoleColors.php', - 'ncc\\abstracts\\exceptioncodes' => '/Abstracts/ExceptionCodes.php', - 'ncc\\abstracts\\nccbuildflags' => '/Abstracts/NccBuildFlags.php', - 'ncc\\abstracts\\options\\initializeprojectoptions' => '/Abstracts/Options/InitializeProjectOptions.php', - 'ncc\\abstracts\\regexpatterns' => '/Abstracts/RegexPatterns.php', - 'ncc\\abstracts\\remoteauthenticationtype' => '/Abstracts/RemoteAuthenticationType.php', - 'ncc\\abstracts\\remotesource' => '/Abstracts/RemoteSource.php', - 'ncc\\abstracts\\scopes' => '/Abstracts/Scopes.php', - 'ncc\\abstracts\\stringpaddingmethod' => '/Abstracts/StringPaddingMethod.php', - 'ncc\\abstracts\\versions' => '/Abstracts/Versions.php', - 'ncc\\cli\\credentialmenu' => '/CLI/CredentialMenu.php', - 'ncc\\cli\\functions' => '/CLI/Functions.php', - 'ncc\\cli\\helpmenu' => '/CLI/HelpMenu.php', - 'ncc\\cli\\main' => '/CLI/Main.php', - 'ncc\\cli\\projectmenu' => '/CLI/ProjectMenu.php', - 'ncc\\defuse\\crypto\\core' => '/ThirdParty/defuse/php-encryption/Core.php', - 'ncc\\defuse\\crypto\\crypto' => '/ThirdParty/defuse/php-encryption/Crypto.php', - 'ncc\\defuse\\crypto\\derivedkeys' => '/ThirdParty/defuse/php-encryption/DerivedKeys.php', - 'ncc\\defuse\\crypto\\encoding' => '/ThirdParty/defuse/php-encryption/Encoding.php', - 'ncc\\defuse\\crypto\\exception\\badformatexception' => '/ThirdParty/defuse/php-encryption/Exception/BadFormatException.php', - 'ncc\\defuse\\crypto\\exception\\cryptoexception' => '/ThirdParty/defuse/php-encryption/Exception/CryptoException.php', - 'ncc\\defuse\\crypto\\exception\\environmentisbrokenexception' => '/ThirdParty/defuse/php-encryption/Exception/EnvironmentIsBrokenException.php', - 'ncc\\defuse\\crypto\\exception\\ioexception' => '/ThirdParty/defuse/php-encryption/Exception/IOException.php', - 'ncc\\defuse\\crypto\\exception\\wrongkeyormodifiedciphertextexception' => '/ThirdParty/defuse/php-encryption/Exception/WrongKeyOrModifiedCiphertextException.php', - 'ncc\\defuse\\crypto\\file' => '/ThirdParty/defuse/php-encryption/File.php', - 'ncc\\defuse\\crypto\\key' => '/ThirdParty/defuse/php-encryption/Key.php', - 'ncc\\defuse\\crypto\\keyorpassword' => '/ThirdParty/defuse/php-encryption/KeyOrPassword.php', - 'ncc\\defuse\\crypto\\keyprotectedbypassword' => '/ThirdParty/defuse/php-encryption/KeyProtectedByPassword.php', - 'ncc\\defuse\\crypto\\runtimetests' => '/ThirdParty/defuse/php-encryption/RuntimeTests.php', - 'ncc\\exceptions\\accessdeniedexception' => '/Exceptions/AccessDeniedException.php', - 'ncc\\exceptions\\componentversionnotfoundexception' => '/Exceptions/ComponentVersionNotFoundException.php', - 'ncc\\exceptions\\constantreadonlyexception' => '/Exceptions/ConstantReadonlyException.php', - 'ncc\\exceptions\\directorynotfoundexception' => '/Exceptions/DirectoryNotFoundException.php', - 'ncc\\exceptions\\filenotfoundexception' => '/Exceptions/FileNotFoundException.php', - 'ncc\\exceptions\\invalidcredentialsentryexception' => '/Exceptions/InvalidCredentialsEntryException.php', - 'ncc\\exceptions\\invalidpackagenameexception' => '/Exceptions/InvalidPackageNameException.php', - 'ncc\\exceptions\\invalidprojectconfigurationexception' => '/Exceptions/InvalidProjectConfigurationException.php', - 'ncc\\exceptions\\invalidprojectnameexception' => '/Exceptions/InvalidProjectNameException.php', - 'ncc\\exceptions\\invalidscopeexception' => '/Exceptions/InvalidScopeException.php', - 'ncc\\exceptions\\invalidversionnumberexception' => '/Exceptions/InvalidVersionNumberException.php', - 'ncc\\exceptions\\malformedjsonexception' => '/Exceptions/MalformedJsonException.php', - 'ncc\\exceptions\\projectalreadyexistsexception' => '/Exceptions/ProjectAlreadyExistsException.php', - 'ncc\\exceptions\\runtimeexception' => '/Exceptions/RuntimeException.php', - 'ncc\\managers\\credentialmanager' => '/Managers/CredentialManager.php', - 'ncc\\managers\\projectmanager' => '/Managers/ProjectManager.php', - 'ncc\\ncc' => '/ncc.php', - 'ncc\\ncc\\ziproto\\typetransformer\\binarytransformer' => '/Extensions/ZiProto/TypeTransformer/BinaryTransformer.php', - 'ncc\\ncc\\ziproto\\typetransformer\\extension' => '/Extensions/ZiProto/TypeTransformer/Extension.php', - 'ncc\\ncc\\ziproto\\typetransformer\\validator' => '/Extensions/ZiProto/TypeTransformer/Validator.php', - 'ncc\\objects\\clihelpsection' => '/Objects/CliHelpSection.php', - 'ncc\\objects\\constant' => '/Objects/Constant.php', - 'ncc\\objects\\nccupdateinformation' => '/Objects/NccUpdateInformation.php', - 'ncc\\objects\\nccversioninformation' => '/Objects/NccVersionInformation.php', - 'ncc\\objects\\nccversioninformation\\component' => '/Objects/NccVersionInformation/Component.php', - 'ncc\\objects\\projectconfiguration' => '/Objects/ProjectConfiguration.php', - 'ncc\\objects\\projectconfiguration\\assembly' => '/Objects/ProjectConfiguration/Assembly.php', - 'ncc\\objects\\projectconfiguration\\build' => '/Objects/ProjectConfiguration/Build.php', - 'ncc\\objects\\projectconfiguration\\buildconfiguration' => '/Objects/ProjectConfiguration/BuildConfiguration.php', - 'ncc\\objects\\projectconfiguration\\compiler' => '/Objects/ProjectConfiguration/Compiler.php', - 'ncc\\objects\\projectconfiguration\\dependency' => '/Objects/ProjectConfiguration/Dependency.php', - 'ncc\\objects\\projectconfiguration\\project' => '/Objects/ProjectConfiguration/Project.php', - 'ncc\\objects\\vault' => '/Objects/Vault.php', - 'ncc\\objects\\vault\\defaultentry' => '/Objects/Vault/DefaultEntry.php', - 'ncc\\objects\\vault\\entry' => '/Objects/Vault/Entry.php', - 'ncc\\runtime\\constants' => '/Runtime/Constants.php', - 'ncc\\symfony\\component\\process\\exception\\exceptioninterface' => '/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php', - 'ncc\\symfony\\component\\process\\exception\\invalidargumentexception' => '/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php', - 'ncc\\symfony\\component\\process\\exception\\logicexception' => '/ThirdParty/Symfony/Process/Exception/LogicException.php', - 'ncc\\symfony\\component\\process\\exception\\processfailedexception' => '/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php', - 'ncc\\symfony\\component\\process\\exception\\processsignaledexception' => '/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php', - 'ncc\\symfony\\component\\process\\exception\\processtimedoutexception' => '/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php', - 'ncc\\symfony\\component\\process\\exception\\runtimeexception' => '/ThirdParty/Symfony/Process/Exception/RuntimeException.php', - 'ncc\\symfony\\component\\process\\executablefinder' => '/ThirdParty/Symfony/Process/ExecutableFinder.php', - 'ncc\\symfony\\component\\process\\inputstream' => '/ThirdParty/Symfony/Process/InputStream.php', - 'ncc\\symfony\\component\\process\\phpexecutablefinder' => '/ThirdParty/Symfony/Process/PhpExecutableFinder.php', - 'ncc\\symfony\\component\\process\\phpprocess' => '/ThirdParty/Symfony/Process/PhpProcess.php', - 'ncc\\symfony\\component\\process\\pipes\\abstractpipes' => '/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php', - 'ncc\\symfony\\component\\process\\pipes\\pipesinterface' => '/ThirdParty/Symfony/Process/Pipes/PipesInterface.php', - 'ncc\\symfony\\component\\process\\pipes\\unixpipes' => '/ThirdParty/Symfony/Process/Pipes/UnixPipes.php', - 'ncc\\symfony\\component\\process\\pipes\\windowspipes' => '/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php', - 'ncc\\symfony\\component\\process\\process' => '/ThirdParty/Symfony/Process/Process.php', - 'ncc\\symfony\\component\\process\\processutils' => '/ThirdParty/Symfony/Process/ProcessUtils.php', - 'ncc\\symfony\\component\\uid\\abstractuid' => '/ThirdParty/Symfony/uid/AbstractUid.php', - 'ncc\\symfony\\component\\uid\\binaryutil' => '/ThirdParty/Symfony/uid/BinaryUtil.php', - 'ncc\\symfony\\component\\uid\\factory\\namebaseduuidfactory' => '/ThirdParty/Symfony/uid/Factory/NameBasedUuidFactory.php', - 'ncc\\symfony\\component\\uid\\factory\\randombaseduuidfactory' => '/ThirdParty/Symfony/uid/Factory/RandomBasedUuidFactory.php', - 'ncc\\symfony\\component\\uid\\factory\\timebaseduuidfactory' => '/ThirdParty/Symfony/uid/Factory/TimeBasedUuidFactory.php', - 'ncc\\symfony\\component\\uid\\factory\\ulidfactory' => '/ThirdParty/Symfony/uid/Factory/UlidFactory.php', - 'ncc\\symfony\\component\\uid\\factory\\uuidfactory' => '/ThirdParty/Symfony/uid/Factory/UuidFactory.php', - 'ncc\\symfony\\component\\uid\\nilulid' => '/ThirdParty/Symfony/uid/NilUlid.php', - 'ncc\\symfony\\component\\uid\\niluuid' => '/ThirdParty/Symfony/uid/NilUuid.php', - 'ncc\\symfony\\component\\uid\\ulid' => '/ThirdParty/Symfony/uid/Ulid.php', - 'ncc\\symfony\\component\\uid\\uuid' => '/ThirdParty/Symfony/uid/Uuid.php', - 'ncc\\symfony\\component\\uid\\uuidv1' => '/ThirdParty/Symfony/uid/UuidV1.php', - 'ncc\\symfony\\component\\uid\\uuidv3' => '/ThirdParty/Symfony/uid/UuidV3.php', - 'ncc\\symfony\\component\\uid\\uuidv4' => '/ThirdParty/Symfony/uid/UuidV4.php', - 'ncc\\symfony\\component\\uid\\uuidv5' => '/ThirdParty/Symfony/uid/UuidV5.php', - 'ncc\\symfony\\component\\uid\\uuidv6' => '/ThirdParty/Symfony/uid/UuidV6.php', - 'ncc\\symfony\\polyfill\\ctype\\ctype' => '/ThirdParty/Symfony/polyfill-ctype/Ctype.php', - 'ncc\\symfony\\polyfill\\mbstring\\mbstring' => '/ThirdParty/Symfony/polyfill-mbstring/Mbstring.php', - 'ncc\\utilities\\console' => '/Utilities/Console.php', - 'ncc\\utilities\\functions' => '/Utilities/Functions.php', - 'ncc\\utilities\\pathfinder' => '/Utilities/PathFinder.php', - 'ncc\\utilities\\resolver' => '/Utilities/Resolver.php', - 'ncc\\utilities\\security' => '/Utilities/Security.php', - 'ncc\\utilities\\validate' => '/Utilities/Validate.php', - 'ncc\\ziproto\\abstracts\\options' => '/Extensions/ZiProto/Abstracts/Options.php', - 'ncc\\ziproto\\abstracts\\regex' => '/Extensions/ZiProto/Abstracts/Regex.php', - 'ncc\\ziproto\\bufferstream' => '/Extensions/ZiProto/BufferStream.php', - 'ncc\\ziproto\\decodingoptions' => '/Extensions/ZiProto/DecodingOptions.php', - 'ncc\\ziproto\\encodingoptions' => '/Extensions/ZiProto/EncodingOptions.php', - 'ncc\\ziproto\\exception\\decodingfailedexception' => '/Extensions/ZiProto/Exception/DecodingFailedException.php', - 'ncc\\ziproto\\exception\\encodingfailedexception' => '/Extensions/ZiProto/Exception/EncodingFailedException.php', - 'ncc\\ziproto\\exception\\insufficientdataexception' => '/Extensions/ZiProto/Exception/InsufficientDataException.php', - 'ncc\\ziproto\\exception\\integeroverflowexception' => '/Extensions/ZiProto/Exception/IntegerOverflowException.php', - 'ncc\\ziproto\\exception\\invalidoptionexception' => '/Extensions/ZiProto/Exception/InvalidOptionException.php', - 'ncc\\ziproto\\ext' => '/Extensions/ZiProto/Ext.php', - 'ncc\\ziproto\\packet' => '/Extensions/ZiProto/Packet.php', - 'ncc\\ziproto\\type\\binary' => '/Extensions/ZiProto/Type/Binary.php', - 'ncc\\ziproto\\type\\map' => '/Extensions/ZiProto/Type/Map.php', - 'ncc\\ziproto\\typetransformer\\maptransformer' => '/Extensions/ZiProto/TypeTransformer/MapTransformer.php', - 'ncc\\ziproto\\ziproto' => '/Extensions/ZiProto/ZiProto.php' - ); + + /** + * NCC Autoloader file v1.0 + * + * This file attempts to autoload all the required files for NCC and + * initialize NCC immediately, this file checks for initialization + * before proceeding to improve performance. + */ + + if(defined('NCC_INIT') == false) + { + // polyfill-mbstring + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'ThirdParty' . DIRECTORY_SEPARATOR . 'Symfony' . DIRECTORY_SEPARATOR . 'polyfill-mbstring' . DIRECTORY_SEPARATOR . 'bootstrap.php'); + + // polyfill-ctype + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'ThirdParty' . DIRECTORY_SEPARATOR . 'Symfony' . DIRECTORY_SEPARATOR . 'polyfill-ctype' . DIRECTORY_SEPARATOR . 'bootstrap.php'); + + // Generated SPL file + require_once(__DIR__ . DIRECTORY_SEPARATOR . 'autoload_spl.php'); + + if(\ncc\ncc::initialize() == false) + { + trigger_error('NCC Failed to initialize', E_USER_WARNING); } - $cn = strtolower($class); - if (isset($classes[$cn])) { - require __DIR__ . $classes[$cn]; - } - }, - true, - false -); -// @codeCoverageIgnoreEnd + } \ No newline at end of file diff --git a/src/ncc/bootstrap.php b/src/ncc/bootstrap.php deleted file mode 100644 index 317eb34..0000000 --- a/src/ncc/bootstrap.php +++ /dev/null @@ -1,7 +0,0 @@ -