diff --git a/LICENSE b/LICENSE index b5c7e1b..3d860d9 100644 --- a/LICENSE +++ b/LICENSE @@ -153,4 +153,28 @@ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +POSSIBILITY OF SUCH DAMAGE. + + +------------------------ +Symfony - Filesystem + +Copyright (c) 2004-2022 Fabien Potencier + +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 NONINFRINGEMENT. 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. diff --git a/Makefile b/Makefile index ec71218..a4e4801 100644 --- a/Makefile +++ b/Makefile @@ -5,32 +5,38 @@ autoload: 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/ThirdParty/Symfony/Filesystem/autoload_spl.php make src/ncc/autoload_spl.php cp src/autoload/autoload.php src/ncc/autoload.php src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php: - phpab --output src/ncc/ThirdParty/defuse/php-encryption/autoload_spl.php \ + /usr/bin/env 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 \ + /usr/bin/env 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 \ + /usr/bin/env 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 \ + /usr/bin/env 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/ThirdParty/Symfony/Filesystem/autoload_spl.php: + /usr/bin/env phpab --output src/ncc/ThirdParty/Symfony/Filesystem/autoload_spl.php \ + src/ncc/ThirdParty/Symfony/Filesystem + src/ncc/autoload_spl.php: - phpab --output src/ncc/autoload_spl.php \ + /usr/bin/env phpab --output src/ncc/autoload_spl.php \ src/ncc/Abstracts \ + src/ncc/Classes \ src/ncc/CLI \ src/ncc/Exceptions \ src/ncc/Extensions \ @@ -44,12 +50,14 @@ redist: autoload rm -rf build mkdir build build/src cp -rf src/ncc/* build/src - cp src/installer/installer build/src/install - chmod +x build/src/install + cp src/installer/installer build/src/INSTALL + cp src/installer/ncc.sh build/src/ncc.sh + cp src/installer/extension build/src/extension + chmod +x build/src/INSTALL 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 + cp src/installer/hash_check.php build/src/hash_check.php; /usr/bin/env 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; /usr/bin/env php build/src/generate_build_files.php; rm build/src/generate_build_files.php tar: redist cd build/src; tar -czvf ../ncc.tar.gz * @@ -61,4 +69,5 @@ clean: 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 + rm -f src/ncc/ThirdParty/Symfony/Uid/autoload_spl.php + rm -f src/ncc/ThirdParty/Symfony/Filesystem/autoload_spl.php \ No newline at end of file diff --git a/src/installer/generate_build_files.php b/src/installer/generate_build_files.php index 092f2d9..c29c17b 100644 --- a/src/installer/generate_build_files.php +++ b/src/installer/generate_build_files.php @@ -35,7 +35,9 @@ 'generate_build_files.php', 'installer', 'checksum.bin'. - 'build_files' + 'build_files', + 'ncc.sh', + 'extension' ]; ncc\Utilities\Console::out('Creating build_files ...'); diff --git a/src/installer/installer b/src/installer/installer index e69de29..f9c5c40 100644 --- a/src/installer/installer +++ b/src/installer/installer @@ -0,0 +1,503 @@ +#!/bin/php + +# ------------------------------------------------------------------ +# Nosial Code Compiler (NCC) Installation Script +# +# Nosial Code Compiler is a program written in PHP designed +# to be a multipurpose compiler, package manager and toolkit. +# +# Dependency: +# PHP 8.0+ +# ------------------------------------------------------------------ + +getMessage() . ' (Error Code: ' . $e->getCode() . ')'); + exit(1); + } + + $NCC_ARGS = null; + $NCC_FILESYSTEM = new Filesystem(); + + // Options Parser + if(isset($argv)) + { + $NCC_ARGS = Resolver::parseArguments(implode(' ', $argv)); + } + + if(isset($NCC_ARGS['help'])) + { + $options = [ + new CliHelpSection(['--help'], 'Displays this help menu about the installer'), + new CliHelpSection(['--auto'], 'Automates the installation process'), + new CliHelpSection(['--install-composer'], 'Require composer to be installed alongside NCC'), + new CliHelpSection(['--install-dir'], 'Specifies the installation directory for NCC'), + ]; + + $options_padding = Functions::detectParametersPadding($options) + 4; + + Console::out('Usage: ' . __FILE__ . ' [options]'); + Console::out('Options:' . PHP_EOL); + foreach($options as $option) + { + Console::out(' ' . $option->toString($options_padding)); + } + exit(0); + } + + // Detect if running in Windows + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') + { + print('This installer can only run on Linux based machines' . PHP_EOL); + } + + // Detect the server API + if(defined('PHP_SAPI')) + { + if(strtolower(PHP_SAPI) !== 'cli') + { + print('This installation script is meant to be running in your terminal' . PHP_EOL); + } + } + elseif(function_exists('php_sapi_name') && strtolower(php_sapi_name()) !== 'cli') + { + print('This installation script is meant to be running in your terminal' . PHP_EOL); + } + else + { + Console::outWarning( + 'The installer cannot determine the Server API (SAPI), the installer will continue but it is ' . + 'recommended to be running this installer in a terminal' + ); + } + + // Check if running in a TTY + if(stream_isatty(STDERR)) + { + Console::outWarning('Your terminal may have some issues rendering the output of this installer'); + } + + // Check if running as root + if (posix_getuid() !== 0) + { + Console::outError('You must be running as root'); + exit(1); + } + + // Find the PHP executable + $executable_finder = new PhpExecutableFinder(); + $NCC_PHP_EXECUTABLE = $executable_finder->find(); + if(!$NCC_PHP_EXECUTABLE) + { + Console::outError('Cannot find PHP executable path'); + exit(1); + } + + // Check for the required files + $required_files = [ + __DIR__ . DIRECTORY_SEPARATOR . 'LICENSE', + __DIR__ . DIRECTORY_SEPARATOR . 'build_files', + __DIR__ . DIRECTORY_SEPARATOR . 'ncc.sh', + ]; + foreach($required_files as $path) + { + if(!file_exists($path)) + { + Console::outError('Missing file \'' . $path . '\', installation failed.', true, 1); + exit(1); + } + } + + // Preform the checksum validation + if(!file_exists($NCC_CHECKSUM)) + { + Console::outWarning('The file \'checksum.bin\' was not found, the contents of the program cannot be verified to be safe'); + } + else + { + Console::out('Running checksum'); + + $checksum = ZiProto::decode(file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'checksum.bin')); + $checksum_failed = false; + + foreach($checksum as $path => $hash) + { + if(!file_exists(__DIR__ . DIRECTORY_SEPARATOR . $path)) + { + Console::outError('Cannot check file, \'' . $path . '\' not found.'); + $checksum_failed = true; + } + elseif(hash_file('sha256', __DIR__ . DIRECTORY_SEPARATOR . $path) !== $hash) + { + Console::outWarning('The file \'' . $path . '\' does not match the original checksum'); + $checksum_failed = true; + } + } + + if($checksum_failed) + { + Console::outError('Checksum failed, the contents of the program cannot be verified to be safe'); + exit(1); + } + else + { + Console::out('Checksum passed'); + } + } + + // Check for required extensions + $curl_available = true; + foreach(Validate::requiredExtensions() as $ext => $installed) + { + if(!$installed) + { + switch($ext) + { + case 'curl': + Console::outWarning('This installer requires the \'curl\' extension to install composer'); + $curl_available = false; + break; + + default: + Console::outWarning('The extension \'' . $ext . '\' is not installed, compatibility without it is not guaranteed'); + break; + } + } + } + + // Attempt to load version information + try + { + $VersionInformation = ncc::getVersionInformation(); + } + catch (FileNotFoundException|\ncc\Exceptions\RuntimeException $e) + { + Console::outError('Cannot get version information, ' . $e->getMessage() . ' (Error Code: ' . $e->getCode() . ')'); + exit(1); + } + + // Start of installer + Console::out('Started NCC installer'); + + // Display version information + Console::out('NCC Version: ' . NCC_VERSION_NUMBER . ' (' . NCC_VERSION_BRANCH . ')'); + Console::out('Build Flags: ' . implode(',', NCC_VERSION_FLAGS)); + + foreach($VersionInformation->Components as $component) + { + $full_name = $component->Vendor . '/' . $component->PackageName; + + try + { + Console::out($full_name . ' Version: ' . $component->getVersion()); + } + catch (ComponentVersionNotFoundException $e) + { + Console::outWarning('Cannot determine component version of ' . $full_name); + } + } + + // Determine the installation path + // TODO: Add the ability to change the data path as well + if($NCC_ARGS == null && !isset($NCC_ARGS['auto'])) + { + while(true) + { + $user_input = null; + $user_input = 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')) + { + Console::out('NCC Seems to already be installed, the installer will repair/upgrade your current install'); + break; + } + else + { + Console::outError('The given directory already exists, it must be deleted before proceeding'); + } + } + else + { + break; + } + } + else + { + break; + } + } + } + else + { + if(strlen($NCC_ARGS['install-dir']) > 0) + { + if(file_exists($NCC_ARGS['install-dir'])) + { + if(file_exists($NCC_ARGS['install-dir'] . DIRECTORY_SEPARATOR . 'ncc')) + { + Console::out('NCC Seems to already be installed, the installer will repair/upgrade your current install'); + } + else + { + Console::outError('The given directory already exists, it must be deleted before proceeding'); + exit(1); + } + } + } + } + + // Ask to install composer if curl is available + if($curl_available) + { + if($NCC_ARGS !== null && isset($NCC_ARGS['auto']) && isset($NCC_ARGS['install-composer'])) + { + $update_composer = true; + } + elseif(isset($NCC_ARGS['install-composer'])) + { + $update_composer = true; + } + else + { + Console::out("Note: This doesn't affect your current install of composer (if you have composer installed)"); + $update_composer = Console::getBooleanInput('Do you want to install composer for NCC? (Recommended)'); + } + } + + if($NCC_ARGS == null && !isset($NCC_ARGS['auto'])) + { + if(!Console::getBooleanInput('Do you want install NCC?')) + { + Console::outError('Installation cancelled by user'); + exit(1); + } + } + + // Prepare installation + if(file_exists($NCC_INSTALL_PATH)) + { + try + { + $NCC_FILESYSTEM->remove([$NCC_INSTALL_PATH]); + } + catch(IOException $e) + { + Console::outError('Cannot delete directory \'' . $NCC_INSTALL_PATH . '\', ' . $e->getMessage()); + exit(1); + } + } + + // Create the required directories + $required_dirs = [ + $NCC_INSTALL_PATH, + $NCC_DATA_PATH, + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'packages', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'cache', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'repos', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'downloads', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'config', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'data', + $NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'ext', + ]; + + $NCC_FILESYSTEM->mkdir($required_dirs); + foreach($required_dirs as $dir) + { + $NCC_FILESYSTEM->chmod([$dir], 0755); + } + $NCC_FILESYSTEM->chmod([$NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'config'], 0755); + $NCC_FILESYSTEM->chmod([$NCC_DATA_PATH . DIRECTORY_SEPARATOR . 'cache'], 0755); + + // Install composer + if($curl_available && $update_composer) + { + Console::out('Installing composer for NCC'); + + $fp = fopen($NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'composer-setup.php', 'w+'); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, 'https://getcomposer.org/installer'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 600); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_USERAGENT, 'ncc/' . NCC_VERSION_NUMBER . ' (' . NCC_VERSION_BRANCH . ')'); + curl_exec($ch); + curl_close($ch); + fclose($fp); + + Console::out('Running composer installer'); + // TODO: Unescaped shell arguments are a security issue + $Process = Process::fromShellCommandline(implode(' ', [ + $NCC_PHP_EXECUTABLE, + $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'composer-setup.php', + '--install-dir=' . $NCC_INSTALL_PATH, + '--filename=composer.phar' + ])); + $Process->setWorkingDirectory($NCC_INSTALL_PATH); + $Process->setTty(true); + + try + { + $Process->mustRun(); + } + catch(ProcessFailedException $e) + { + Console::outError('Cannot install composer, ' . $e->getMessage()); + exit(1); + } + + $NCC_FILESYSTEM->remove([$NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'composer-setup.php']); + $NCC_FILESYSTEM->chmod([$NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'composer.phar'], 0755); + Console::out('Installed composer successfully'); + } + + // Install NCC + Console::out('Copying files to \'' . $NCC_INSTALL_PATH . '\''); + $build_files = explode("\n", file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'build_files')); + $total_items = count($build_files); + $processed_items = 0; + + // Create all the directories first + foreach($build_files as $path) + { + if(is_dir(__DIR__ . DIRECTORY_SEPARATOR . $path)) + { + $NCC_FILESYSTEM->mkdir([$NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . $path]); + $NCC_FILESYSTEM->chmod([$NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . $path], 0755); + $processed_items += 1; + } + + Console::inlineProgressBar($processed_items, $total_items); + } + + // Copy over all the files + foreach($build_files as $file) + { + if(is_file(__DIR__ . DIRECTORY_SEPARATOR . $file)) + { + $NCC_FILESYSTEM->copy(__DIR__ . DIRECTORY_SEPARATOR . $file, $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . $file); + $NCC_FILESYSTEM->chmod([$NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . $file], 0755); + $processed_items += 1; + } + + Console::inlineProgressBar($processed_items, $total_items); + } + + // Create credential store if needed + Console::out('Processing Credential Store'); + $credential_manager = new CredentialManager(); + + try + { + $credential_manager->constructStore(); + } + catch (AccessDeniedException|\ncc\Exceptions\RuntimeException $e) + { + Console::outError('Cannot construct credential store, ' . $e->getMessage() . ' (Error Code: ' . $e->getCode() . ')'); + } + + try + { + $NCC_FILESYSTEM->touch([PathFinder::getPackageLock(Scopes::System)]); + } + catch (InvalidScopeException $e) + { + Console::outError('Cannot create package lock, ' . $e->getMessage()); + exit(0); + } + + // Generate executable shortcut + Console::out('Creating shortcut'); + $executable_shortcut = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'ncc.sh'); + $executable_shortcut = str_ireplace('%php_exec', $NCC_PHP_EXECUTABLE, $executable_shortcut); + $executable_shortcut = str_ireplace('%ncc_exec', $NCC_INSTALL_PATH . DIRECTORY_SEPARATOR . 'ncc', $executable_shortcut); + + $bin_paths = [ + DIRECTORY_SEPARATOR . 'usr' . DIRECTORY_SEPARATOR . 'bin', + DIRECTORY_SEPARATOR . 'usr' . DIRECTORY_SEPARATOR . 'local' . DIRECTORY_SEPARATOR . 'bin', + DIRECTORY_SEPARATOR . 'usr' . DIRECTORY_SEPARATOR . 'share' + ]; + + foreach($bin_paths as $path) + { + if($NCC_FILESYSTEM->exists([$path])) + { + file_put_contents($path . DIRECTORY_SEPARATOR . 'ncc', $executable_shortcut); + $NCC_FILESYSTEM->chmod([$path . DIRECTORY_SEPARATOR . 'ncc'], 0755); + } + } + + // Register the ncc extension + Console::out('Registering extension'); + $extension_shortcut = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'extension'); + $extension_shortcut = str_ireplace('%ncc_install', $NCC_INSTALL_PATH, $extension_shortcut); + + if(function_exists('get_include_path')) + { + + foreach(explode(':', get_include_path()) as $path) + { + switch($path) + { + case '.': + case '..': + break; + + default: + file_put_contents($path . DIRECTORY_SEPARATOR . 'ncc', $extension_shortcut); + $NCC_FILESYSTEM->chmod([$path . DIRECTORY_SEPARATOR . 'ncc'], 0755); + break; + } + } + } + + Console::out('NCC has been successfully installed'); + exit(0); \ No newline at end of file diff --git a/src/installer/ncc.sh b/src/installer/ncc.sh index dff9de7..6447543 100755 --- a/src/installer/ncc.sh +++ b/src/installer/ncc.sh @@ -1 +1 @@ -php ncc --ncc-cli "$@" \ No newline at end of file +%php_exec %ncc_exec --ncc-cli "$@" \ No newline at end of file diff --git a/src/ncc/Managers/CredentialManager.php b/src/ncc/Managers/CredentialManager.php index fc1d61e..543e537 100644 --- a/src/ncc/Managers/CredentialManager.php +++ b/src/ncc/Managers/CredentialManager.php @@ -55,7 +55,7 @@ */ public function constructStore(): void { - // Do not continue the function if the file already exists, if the file is damaged a seperate function + // Do not continue the function if the file already exists, if the file is damaged a separate function // is to be executed to fix the damaged file. if(file_exists($this->CredentialsPath)) return; @@ -68,11 +68,12 @@ $VaultObject = new Vault(); $VaultObject->Version = Versions::CredentialsStoreVersion; - // TODO: Set proper permissions for root access only for the file if(!@file_put_contents($this->CredentialsPath, ZiProto::encode($VaultObject->toArray()))) { throw new RuntimeException('Cannot create file \'' . $this->CredentialsPath . '\''); } + + chmod($this->CredentialsPath, 0600); } /** diff --git a/src/ncc/Objects/NccVersionInformation.php b/src/ncc/Objects/NccVersionInformation.php index 074244d..17e7e90 100644 --- a/src/ncc/Objects/NccVersionInformation.php +++ b/src/ncc/Objects/NccVersionInformation.php @@ -23,7 +23,7 @@ /** * Flags for the current build * - * @var string|null + * @var array|null */ public $Flags; diff --git a/src/ncc/Objects/NccVersionInformation/Component.php b/src/ncc/Objects/NccVersionInformation/Component.php index 35bbe79..68b7568 100644 --- a/src/ncc/Objects/NccVersionInformation/Component.php +++ b/src/ncc/Objects/NccVersionInformation/Component.php @@ -23,19 +23,12 @@ /** * Attempts to resolve the component's build version * - * @param string $ncc_installation_path * @return string * @throws ComponentVersionNotFoundException */ - public function getVersion(string $ncc_installation_path): string + public function getVersion(): string { - // Auto-resolve the trailing slash - if(substr($ncc_installation_path, -1) !== '/') - { - $ncc_installation_path .= $ncc_installation_path . DIRECTORY_SEPARATOR; - } - - $third_party_path = $ncc_installation_path . DIRECTORY_SEPARATOR . 'ThirdParty' . DIRECTORY_SEPARATOR; + $third_party_path = NCC_EXEC_LOCATION . DIRECTORY_SEPARATOR . 'ThirdParty' . DIRECTORY_SEPARATOR; $component_path = $third_party_path . $this->Vendor . DIRECTORY_SEPARATOR . $this->PackageName . DIRECTORY_SEPARATOR; if(file_exists($component_path . 'VERSION') == false) diff --git a/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md b/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md index 09c93d8..8931cbf 100644 --- a/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md +++ b/src/ncc/ThirdParty/Symfony/Process/CHANGELOG.md @@ -4,74 +4,74 @@ CHANGELOG 5.2.0 ----- - * added `process::setOptions()` to set `process` specific options - * added option `create_new_console` to allow a subprocess to continue + * added `Process::setOptions()` to set `Process` specific options + * added option `create_new_console` to allow a subProcess to continue to run after the main script exited, both on Linux and on Windows 5.1.0 ----- - * added `process::getStartTime()` to retrieve the start time of the process as float + * added `Process::getStartTime()` to retrieve the start time of the Process as float 5.0.0 ----- - * removed `process::inheritEnvironmentVariables()` - * removed `Phpprocess::setPhpBinary()` - * `process` must be instantiated with a command array, use `process::fromShellCommandline()` when the command should be parsed by the shell - * removed `process::setCommandLine()` + * removed `Process::inheritEnvironmentVariables()` + * removed `PhpProcess::setPhpBinary()` + * `Process` must be instantiated with a command array, use `Process::fromShellCommandline()` when the command should be parsed by the shell + * removed `Process::setCommandLine()` 4.4.0 ----- - * deprecated `process::inheritEnvironmentVariables()`: env variables are always inherited. - * added `process::getLastOutputTime()` method + * deprecated `Process::inheritEnvironmentVariables()`: env variables are always inherited. + * added `Process::getLastOutputTime()` method 4.2.0 ----- - * added the `process::fromShellCommandline()` to run commands in a shell wrapper - * deprecated passing a command as string when creating a `process` instance - * deprecated the `process::setCommandline()` and the `Phpprocess::setPhpBinary()` methods - * added the `process::waitUntil()` method to wait for the process only for a + * added the `Process::fromShellCommandline()` to run commands in a shell wrapper + * deprecated passing a command as string when creating a `Process` instance + * deprecated the `Process::setCommandline()` and the `PhpProcess::setPhpBinary()` methods + * added the `Process::waitUntil()` method to wait for the Process only for a specific output, then continue the normal execution of your application 4.1.0 ----- - * added the `process::isTtySupported()` method that allows to check for TTY support + * added the `Process::isTtySupported()` method that allows to check for TTY support * made `PhpExecutableFinder` look for the `PHP_BINARY` env var when searching the php binary - * added the `processSignaledException` class to properly catch signaled process errors + * added the `ProcessSignaledException` class to properly catch signaled Process errors 4.0.0 ----- * environment variables will always be inherited * added a second `array $env = []` argument to the `start()`, `run()`, - `mustRun()`, and `restart()` methods of the `process` class + `mustRun()`, and `restart()` methods of the `Process` class * added a second `array $env = []` argument to the `start()` method of the - `Phpprocess` class - * the `processUtils::escapeArgument()` method has been removed + `PhpProcess` class + * the `ProcessUtils::escapeArgument()` method has been removed * the `areEnvironmentVariablesInherited()`, `getOptions()`, and `setOptions()` - methods of the `process` class have been removed + methods of the `Process` class have been removed * support for passing `proc_open()` options has been removed - * removed the `processBuilder` class, use the `process` class instead - * removed the `getEnhanceWindowsCompatibility()` and `setEnhanceWindowsCompatibility()` methods of the `process` class - * passing a not existing working directory to the constructor of the `Symfony\Component\process\process` class is not + * removed the `ProcessBuilder` class, use the `Process` class instead + * removed the `getEnhanceWindowsCompatibility()` and `setEnhanceWindowsCompatibility()` methods of the `Process` class + * passing a not existing working directory to the constructor of the `Symfony\Component\Process\Process` class is not supported anymore 3.4.0 ----- - * deprecated the processBuilder class - * deprecated calling `process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor) + * deprecated the ProcessBuilder class + * deprecated calling `Process::start()` without setting a valid working directory beforehand (via `setWorkingDirectory()` or constructor) 3.3.0 ----- - * added command line arrays in the `process` class - * added `$env` argument to `process::start()`, `run()`, `mustRun()` and `restart()` methods - * deprecated the `processUtils::escapeArgument()` method + * added command line arrays in the `Process` class + * added `$env` argument to `Process::start()`, `run()`, `mustRun()` and `restart()` methods + * deprecated the `ProcessUtils::escapeArgument()` method * deprecated not inheriting environment variables * deprecated configuring `proc_open()` options * deprecated configuring enhanced Windows compatibility @@ -82,9 +82,9 @@ CHANGELOG * added support for PTY mode * added the convenience method "mustRun" - * deprecation: process::setStdin() is deprecated in favor of process::setInput() - * deprecation: process::getStdin() is deprecated in favor of process::getInput() - * deprecation: process::setInput() and processBuilder::setInput() do not accept non-scalar types + * deprecation: Process::setStdin() is deprecated in favor of Process::setInput() + * deprecation: Process::getStdin() is deprecated in favor of Process::getInput() + * deprecation: Process::setInput() and ProcessBuilder::setInput() do not accept non-scalar types 2.4.0 ----- @@ -94,23 +94,23 @@ CHANGELOG 2.3.0 ----- - * added processUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows - * added process::signal() - * added process::getPid() + * added ProcessUtils::escapeArgument() to fix the bug in escapeshellarg() function on Windows + * added Process::signal() + * added Process::getPid() * added support for a TTY mode 2.2.0 ----- - * added processBuilder::setArguments() to reset the arguments on a builder + * added ProcessBuilder::setArguments() to reset the arguments on a builder * added a way to retrieve the standard and error output incrementally - * added process:restart() + * added Process:restart() 2.1.0 ----- - * added support for non-blocking processes (start(), wait(), isRunning(), stop()) + * added support for non-blocking Processes (start(), wait(), isRunning(), stop()) * enhanced Windows compatibility - * added process::getExitCodeText() that returns a string representation for - the exit code returned by the process - * added processBuilder + * added Process::getExitCodeText() that returns a string representation for + the exit code returned by the Process + * added ProcessBuilder diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php index 300b0f6..309378e 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ExceptionInterface.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; /** - * Marker Interface for the process Component. + * Marker Interface for the Process Component. * * @author Johannes M. Schmitt */ diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php index 74100a5..e81d4cc 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/InvalidArgumentException.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; /** - * InvalidArgumentException for the process Component. + * InvalidArgumentException for the Process Component. * * @author Romain Neutron */ diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/LogicException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/LogicException.php index fc5aeef..3852e60 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/LogicException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/LogicException.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; /** - * LogicException for the process Component. + * LogicException for the Process Component. * * @author Romain Neutron */ diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php index 020dc39..de57a50 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessFailedException.php @@ -9,46 +9,46 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; -use ncc\ThirdParty\Symfony\process\process; +use ncc\ThirdParty\Symfony\Process\Process; /** - * Exception for failed processes. + * Exception for failed Processes. * * @author Johannes M. Schmitt */ -class processFailedException extends RuntimeException +class ProcessFailedException extends RuntimeException { - private $process; + private $Process; - public function __construct(process $process) + public function __construct(Process $Process) { - if ($process->isSuccessful()) { - throw new InvalidArgumentException('Expected a failed process, but the given process was successful.'); + if ($Process->isSuccessful()) { + throw new InvalidArgumentException('Expected a failed Process, but the given Process was successful.'); } $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s", - $process->getCommandLine(), - $process->getExitCode(), - $process->getExitCodeText(), - $process->getWorkingDirectory() + $Process->getCommandLine(), + $Process->getExitCode(), + $Process->getExitCodeText(), + $Process->getWorkingDirectory() ); - if (!$process->isOutputDisabled()) { + if (!$Process->isOutputDisabled()) { $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s", - $process->getOutput(), - $process->getErrorOutput() + $Process->getOutput(), + $Process->getErrorOutput() ); } parent::__construct($error); - $this->process = $process; + $this->Process = $Process; } - public function getprocess() + public function getProcess() { - return $this->process; + return $this->Process; } } diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php index 295588c..ccb3b1b 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessSignaledException.php @@ -9,33 +9,33 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; -use ncc\ThirdParty\Symfony\process\process; +use ncc\ThirdParty\Symfony\Process\Process; /** - * Exception that is thrown when a process has been signaled. + * Exception that is thrown when a Process has been signaled. * * @author Sullivan Senechal */ -final class processSignaledException extends RuntimeException +final class ProcessSignaledException extends RuntimeException { - private $process; + private $Process; - public function __construct(process $process) + public function __construct(Process $Process) { - $this->process = $process; + $this->Process = $Process; - parent::__construct(sprintf('The process has been signaled with signal "%s".', $process->getTermSignal())); + parent::__construct(sprintf('The Process has been signaled with signal "%s".', $Process->getTermSignal())); } - public function getprocess(): process + public function getProcess(): Process { - return $this->process; + return $this->Process; } public function getSignal(): int { - return $this->getprocess()->getTermSignal(); + return $this->getProcess()->getTermSignal(); } } diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php index 6bc52c1..9b6c307 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/ProcessTimedOutException.php @@ -9,38 +9,38 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; -use ncc\ThirdParty\Symfony\process\process; +use ncc\ThirdParty\Symfony\Process\Process; /** - * Exception that is thrown when a process times out. + * Exception that is thrown when a Process times out. * * @author Johannes M. Schmitt */ -class processTimedOutException extends RuntimeException +class ProcessTimedOutException extends RuntimeException { public const TYPE_GENERAL = 1; public const TYPE_IDLE = 2; - private $process; + private $Process; private $timeoutType; - public function __construct(process $process, int $timeoutType) + public function __construct(Process $Process, int $timeoutType) { - $this->process = $process; + $this->Process = $Process; $this->timeoutType = $timeoutType; parent::__construct(sprintf( - 'The process "%s" exceeded the timeout of %s seconds.', - $process->getCommandLine(), + 'The Process "%s" exceeded the timeout of %s seconds.', + $Process->getCommandLine(), $this->getExceededTimeout() )); } - public function getprocess() + public function getProcess() { - return $this->process; + return $this->Process; } public function isGeneralTimeout() @@ -56,8 +56,8 @@ class processTimedOutException extends RuntimeException public function getExceededTimeout() { return match ($this->timeoutType) { - self::TYPE_GENERAL => $this->process->getTimeout(), - self::TYPE_IDLE => $this->process->getIdleTimeout(), + self::TYPE_GENERAL => $this->Process->getTimeout(), + self::TYPE_IDLE => $this->Process->getIdleTimeout(), default => throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType)), }; } diff --git a/src/ncc/ThirdParty/Symfony/Process/Exception/RuntimeException.php b/src/ncc/ThirdParty/Symfony/Process/Exception/RuntimeException.php index de5e4e0..7836a13 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Exception/RuntimeException.php +++ b/src/ncc/ThirdParty/Symfony/Process/Exception/RuntimeException.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Exception; +namespace ncc\ThirdParty\Symfony\Process\Exception; /** - * RuntimeException for the process Component. + * RuntimeException for the Process Component. * * @author Johannes M. Schmitt */ diff --git a/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php b/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php index 060bd78..2041415 100644 --- a/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php +++ b/src/ncc/ThirdParty/Symfony/Process/ExecutableFinder.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; /** * Generic executable finder. diff --git a/src/ncc/ThirdParty/Symfony/Process/InputStream.php b/src/ncc/ThirdParty/Symfony/Process/InputStream.php index c0e1718..c231617 100644 --- a/src/ncc/ThirdParty/Symfony/Process/InputStream.php +++ b/src/ncc/ThirdParty/Symfony/Process/InputStream.php @@ -9,12 +9,12 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; -use ncc\ThirdParty\Symfony\process\Exception\RuntimeException; +use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; /** - * Provides a way to continuously write to the input of a process until the InputStream is closed. + * Provides a way to continuously write to the input of a Process until the InputStream is closed. * * @author Nicolas Grekas * @@ -49,7 +49,7 @@ class InputStream implements \IteratorAggregate if ($this->isClosed()) { throw new RuntimeException(sprintf('"%s" is closed.', static::class)); } - $this->input[] = processUtils::validateInput(__METHOD__, $input); + $this->input[] = ProcessUtils::validateInput(__METHOD__, $input); } /** diff --git a/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php b/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php index 95ec9ac..8d5e56e 100644 --- a/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php +++ b/src/ncc/ThirdParty/Symfony/Process/PhpExecutableFinder.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; /** * An executable finder specifically designed for the PHP executable. diff --git a/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php b/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php index ade2c00..860e588 100644 --- a/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php +++ b/src/ncc/ThirdParty/Symfony/Process/PhpProcess.php @@ -9,26 +9,26 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; -use ncc\ThirdParty\Symfony\process\Exception\LogicException; -use ncc\ThirdParty\Symfony\process\Exception\RuntimeException; +use ncc\ThirdParty\Symfony\Process\Exception\LogicException; +use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; /** - * Phpprocess runs a PHP script in an independent process. + * PhpProcess runs a PHP script in an independent Process. * - * $p = new Phpprocess(''); + * $p = new PhpProcess(''); * $p->run(); * print $p->getOutput()."\n"; * * @author Fabien Potencier */ -class Phpprocess extends process +class PhpProcess extends Process { /** * @param string $script The PHP script to run (as a string) - * @param string|null $cwd The working directory or null to use the working dir of the current PHP process - * @param array|null $env The environment variables or null to use the same environment as the current PHP process + * @param string|null $cwd The working directory or null to use the working dir of the current PHP Process + * @param array|null $env The environment variables or null to use the same environment as the current PHP Process * @param int $timeout The timeout in seconds * @param array|null $php Path to the PHP binary to use with any additional arguments */ diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php index 962ad92..4539386 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/AbstractPipes.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Pipes; +namespace ncc\ThirdParty\Symfony\Process\Pipes; -use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException; +use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException; /** * @author Romain Neutron diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/PipesInterface.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/PipesInterface.php index 9fbbb3e..ccc419f 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/PipesInterface.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/PipesInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Pipes; +namespace ncc\ThirdParty\Symfony\Process\Pipes; /** * PipesInterface manages descriptors and pipes for the use of proc_open. diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php index bb43cca..f13cdcb 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/UnixPipes.php @@ -9,9 +9,9 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Pipes; +namespace ncc\ThirdParty\Symfony\Process\Pipes; -use ncc\ThirdParty\Symfony\process\process; +use ncc\ThirdParty\Symfony\Process\Process; /** * UnixPipes implementation uses unix pipes as handles. @@ -73,7 +73,7 @@ class UnixPipes extends AbstractPipes ]; } - if ($this->ptyMode && process::isPtySupported()) { + if ($this->ptyMode && Process::isPtySupported()) { return [ ['pty'], ['pty'], @@ -110,7 +110,7 @@ class UnixPipes extends AbstractPipes // let's have a look if something changed in streams set_error_handler($this->handleError(...)); - if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? process::TIMEOUT_PRECISION * 1E6 : 0)) { + if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) { restore_error_handler(); // if a system call has been interrupted, forget about it, let's try again // otherwise, an error occurred, let's reset pipes diff --git a/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php b/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php index 3174d7a..677cefb 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php +++ b/src/ncc/ThirdParty/Symfony/Process/Pipes/WindowsPipes.php @@ -9,10 +9,10 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process\Pipes; +namespace ncc\ThirdParty\Symfony\Process\Pipes; -use ncc\ThirdParty\Symfony\process\Exception\RuntimeException; -use ncc\ThirdParty\Symfony\process\process; +use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; +use ncc\ThirdParty\Symfony\Process\Process; /** * WindowsPipes implementation uses temporary files as handles. @@ -30,8 +30,8 @@ class WindowsPipes extends AbstractPipes private $fileHandles = []; private $lockHandles = []; private $readBytes = [ - process::STDOUT => 0, - process::STDERR => 0, + Process::STDOUT => 0, + Process::STDERR => 0, ]; private $haveReadSupport; @@ -45,8 +45,8 @@ class WindowsPipes extends AbstractPipes // // @see https://bugs.php.net/51800 $pipes = [ - process::STDOUT => process::OUT, - process::STDERR => process::ERR, + Process::STDOUT => Process::OUT, + Process::STDERR => Process::ERR, ]; $tmpDir = sys_get_temp_dir(); $lastError = 'unknown reason'; @@ -60,7 +60,7 @@ class WindowsPipes extends AbstractPipes continue 2; } restore_error_handler(); - throw new RuntimeException('A temporary file could not be opened to write the process output: '.$lastError); + throw new RuntimeException('A temporary file could not be opened to write the Process output: '.$lastError); } if (!flock($h, \LOCK_EX | \LOCK_NB)) { continue 2; @@ -120,7 +120,7 @@ class WindowsPipes extends AbstractPipes // We're not using pipe on Windows platform as it hangs (https://bugs.php.net/51800) // We're not using file handles as it can produce corrupted output https://bugs.php.net/65650 - // So we redirect output within the commandline and pass the nul device to the process + // So we redirect output within the commandline and pass the nul device to the Process return [ ['pipe', 'r'], ['file', 'NUL', 'w'], @@ -147,9 +147,9 @@ class WindowsPipes extends AbstractPipes if ($blocking) { if ($w) { - @stream_select($r, $w, $e, 0, process::TIMEOUT_PRECISION * 1E6); + @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6); } elseif ($this->fileHandles) { - usleep(process::TIMEOUT_PRECISION * 1E6); + usleep(Process::TIMEOUT_PRECISION * 1E6); } } foreach ($this->fileHandles as $type => $fileHandle) { diff --git a/src/ncc/ThirdParty/Symfony/Process/Process.php b/src/ncc/ThirdParty/Symfony/Process/Process.php index c9f4e0c..3c6ccba 100644 --- a/src/ncc/ThirdParty/Symfony/Process/Process.php +++ b/src/ncc/ThirdParty/Symfony/Process/Process.php @@ -9,28 +9,28 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; -use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException; -use ncc\ThirdParty\Symfony\process\Exception\LogicException; -use ncc\ThirdParty\Symfony\process\Exception\processFailedException; -use ncc\ThirdParty\Symfony\process\Exception\processSignaledException; -use ncc\ThirdParty\Symfony\process\Exception\processTimedOutException; -use ncc\ThirdParty\Symfony\process\Exception\RuntimeException; -use ncc\ThirdParty\Symfony\process\Pipes\PipesInterface; -use ncc\ThirdParty\Symfony\process\Pipes\UnixPipes; -use ncc\ThirdParty\Symfony\process\Pipes\WindowsPipes; +use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException; +use ncc\ThirdParty\Symfony\Process\Exception\LogicException; +use ncc\ThirdParty\Symfony\Process\Exception\ProcessFailedException; +use ncc\ThirdParty\Symfony\Process\Exception\ProcessSignaledException; +use ncc\ThirdParty\Symfony\Process\Exception\ProcessTimedOutException; +use ncc\ThirdParty\Symfony\Process\Exception\RuntimeException; +use ncc\ThirdParty\Symfony\Process\Pipes\PipesInterface; +use ncc\ThirdParty\Symfony\Process\Pipes\UnixPipes; +use ncc\ThirdParty\Symfony\Process\Pipes\WindowsPipes; /** - * process is a thin wrapper around proc_* functions to easily - * start independent PHP processes. + * Process is a thin wrapper around proc_* functions to easily + * start independent PHP Processes. * * @author Fabien Potencier * @author Romain Neutron * * @implements \IteratorAggregate */ -class process implements \IteratorAggregate +class Process implements \IteratorAggregate { public const ERR = 'err'; public const OUT = 'out'; @@ -63,11 +63,11 @@ class process implements \IteratorAggregate private $idleTimeout; private $exitcode; private $fallbackStatus = []; - private $processInformation; + private $ProcessInformation; private $outputDisabled = false; private $stdout; private $stderr; - private $process; + private $Process; private $status = self::STATUS_READY; private $incrementalOutputOffset = 0; private $incrementalErrorOutputOffset = 0; @@ -77,7 +77,7 @@ class process implements \IteratorAggregate private $useFileHandles = false; /** @var PipesInterface */ - private $processPipes; + private $ProcessPipes; private $latestSignal; @@ -103,7 +103,7 @@ class process implements \IteratorAggregate 131 => 'Quit and dump core', 132 => 'Illegal instruction', 133 => 'Trace/breakpoint trap', - 134 => 'process aborted', + 134 => 'Process aborted', 135 => 'Bus error: "access to undefined portion of memory object"', 136 => 'Floating point exception: "erroneous arithmetic operation"', 137 => 'Kill (terminate immediately)', @@ -114,12 +114,12 @@ class process implements \IteratorAggregate 142 => 'Signal raised by alarm', 143 => 'Termination (request to terminate)', // 144 - not defined - 145 => 'Child process terminated, stopped (or continued*)', + 145 => 'Child Process terminated, stopped (or continued*)', 146 => 'Continue if stopped', 147 => 'Stop executing temporarily', 148 => 'Terminal stop signal', - 149 => 'Background process attempting to read from tty ("in")', - 150 => 'Background process attempting to write to tty ("out")', + 149 => 'Background Process attempting to read from tty ("in")', + 150 => 'Background Process attempting to write to tty ("out")', 151 => 'Urgent data available on socket', 152 => 'CPU time limit exceeded', 153 => 'File size limit exceeded', @@ -133,8 +133,8 @@ class process implements \IteratorAggregate /** * @param array $command The command to run and its arguments listed as separate entries - * @param string|null $cwd The working directory or null to use the working dir of the current PHP process - * @param array|null $env The environment variables or null to use the same environment as the current PHP process + * @param string|null $cwd The working directory or null to use the working dir of the current PHP Process + * @param array|null $env The environment variables or null to use the same environment as the current PHP Process * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * @@ -143,7 +143,7 @@ class process implements \IteratorAggregate public function __construct(array $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60) { if (!\function_exists('proc_open')) { - throw new LogicException('The process class relies on proc_open, which is not available on your PHP installation.'); + throw new LogicException('The Process class relies on proc_open, which is not available on your PHP installation.'); } $this->commandline = $command; @@ -167,7 +167,7 @@ class process implements \IteratorAggregate } /** - * Creates a process instance as a command-line to be run in a shell wrapper. + * Creates a Process instance as a command-line to be run in a shell wrapper. * * Command-lines are parsed by the shell of your OS (/bin/sh on Unix-like, cmd.exe on Windows.) * This allows using e.g. pipes or conditional execution. In this mode, signals are sent to the @@ -176,12 +176,12 @@ class process implements \IteratorAggregate * In order to inject dynamic values into command-lines, we strongly recommend using placeholders. * This will save escaping values, which is not portable nor secure anyway: * - * $process = process::fromShellCommandline('my_command "${:MY_VAR}"'); - * $process->run(null, ['MY_VAR' => $theValue]); + * $Process = Process::fromShellCommandline('my_command "${:MY_VAR}"'); + * $Process->run(null, ['MY_VAR' => $theValue]); * * @param string $command The command line to pass to the shell of the OS - * @param string|null $cwd The working directory or null to use the working dir of the current PHP process - * @param array|null $env The environment variables or null to use the same environment as the current PHP process + * @param string|null $cwd The working directory or null to use the working dir of the current PHP Process + * @param array|null $env The environment variables or null to use the same environment as the current PHP Process * @param mixed $input The input as stream resource, scalar or \Traversable, or null for no input * @param int|float|null $timeout The timeout in seconds or null to disable * @@ -189,10 +189,10 @@ class process implements \IteratorAggregate */ public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, mixed $input = null, ?float $timeout = 60): static { - $process = new static([], $cwd, $env, $input, $timeout); - $process->commandline = $command; + $Process = new static([], $cwd, $env, $input, $timeout); + $Process->commandline = $command; - return $process; + return $Process; } public function __sleep(): array @@ -208,7 +208,7 @@ class process implements \IteratorAggregate public function __destruct() { if ($this->options['create_new_console'] ?? false) { - $this->processPipes->close(); + $this->ProcessPipes->close(); } else { $this->stop(0); } @@ -216,17 +216,17 @@ class process implements \IteratorAggregate public function __clone() { - $this->resetprocessData(); + $this->resetProcessData(); } /** - * Runs the process. + * Runs the Process. * * The callback receives the type of output (out or err) and * some bytes from the output in real-time. It allows to have feedback - * from the independent process during execution. + * from the independent Process during execution. * - * The STDOUT and STDERR are also available after the process is finished + * The STDOUT and STDERR are also available after the Process is finished * via the getOutput() and getErrorOutput() methods. * * @param callable|null $callback A PHP callback to run whenever there is some @@ -234,10 +234,10 @@ class process implements \IteratorAggregate * * @return int The exit status code * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running - * @throws processTimedOutException When process timed out - * @throws processSignaledException When process stopped after receiving signal + * @throws RuntimeException When Process can't be launched + * @throws RuntimeException When Process is already running + * @throws ProcessTimedOutException When Process timed out + * @throws ProcessSignaledException When Process stopped after receiving signal * @throws LogicException In case a callback is provided and output has been disabled * * @final @@ -250,52 +250,52 @@ class process implements \IteratorAggregate } /** - * Runs the process. + * Runs the Process. * - * This is identical to run() except that an exception is thrown if the process + * This is identical to run() except that an exception is thrown if the Process * exits with a non-zero exit code. * * @return $this * - * @throws processFailedException if the process didn't terminate successfully + * @throws ProcessFailedException if the Process didn't terminate successfully * * @final */ public function mustRun(callable $callback = null, array $env = []): static { if (0 !== $this->run($callback, $env)) { - throw new processFailedException($this); + throw new ProcessFailedException($this); } return $this; } /** - * Starts the process and returns after writing the input to STDIN. + * Starts the Process and returns after writing the input to STDIN. * - * This method blocks until all STDIN data is sent to the process then it - * returns while the process runs in the background. + * This method blocks until all STDIN data is sent to the Process then it + * returns while the Process runs in the background. * - * The termination of the process can be awaited with wait(). + * The termination of the Process can be awaited with wait(). * * The callback receives the type of output (out or err) and some bytes from - * the output in real-time while writing the standard input to the process. - * It allows to have feedback from the independent process during execution. + * the output in real-time while writing the standard input to the Process. + * It allows to have feedback from the independent Process during execution. * * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running + * @throws RuntimeException When Process can't be launched + * @throws RuntimeException When Process is already running * @throws LogicException In case a callback is provided and output has been disabled */ public function start(callable $callback = null, array $env = []) { if ($this->isRunning()) { - throw new RuntimeException('process is already running.'); + throw new RuntimeException('Process is already running.'); } - $this->resetprocessData(); + $this->resetProcessData(); $this->starttime = $this->lastOutputTime = microtime(true); $this->callback = $this->buildCallback($callback); $this->hasCallback = null !== $callback; @@ -311,7 +311,7 @@ class process implements \IteratorAggregate $commandline = implode(' ', array_map($this->escapeArgument(...), $commandline)); if ('\\' !== \DIRECTORY_SEPARATOR) { - // exec is mandatory to deal with sending a signal to the process + // exec is mandatory to deal with sending a signal to the Process $commandline = 'exec '.$commandline; } } else { @@ -324,7 +324,7 @@ class process implements \IteratorAggregate // last exit code is output on the fourth pipe and caught to work around --enable-sigchild $descriptors[3] = ['pipe', 'w']; - // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input + // See https://unix.stackexchange.com/questions/71205/background-Process-pipe-input $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code'; @@ -344,15 +344,15 @@ class process implements \IteratorAggregate throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd)); } - $this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options); + $this->Process = @proc_open($commandline, $descriptors, $this->ProcessPipes->pipes, $this->cwd, $envPairs, $this->options); - if (!\is_resource($this->process)) { - throw new RuntimeException('Unable to launch a new process.'); + if (!\is_resource($this->Process)) { + throw new RuntimeException('Unable to launch a new Process.'); } $this->status = self::STATUS_STARTED; if (isset($descriptors[3])) { - $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]); + $this->fallbackStatus['pid'] = (int) fgets($this->ProcessPipes->pipes[3]); } if ($this->tty) { @@ -364,15 +364,15 @@ class process implements \IteratorAggregate } /** - * Restarts the process. + * Restarts the Process. * - * Be warned that the process is cloned before being started. + * Be warned that the Process is cloned before being started. * * @param callable|null $callback A PHP callback to run whenever there is some * output available on STDOUT or STDERR * - * @throws RuntimeException When process can't be launched - * @throws RuntimeException When process is already running + * @throws RuntimeException When Process can't be launched + * @throws RuntimeException When Process is already running * * @see start() * @@ -381,47 +381,47 @@ class process implements \IteratorAggregate public function restart(callable $callback = null, array $env = []): static { if ($this->isRunning()) { - throw new RuntimeException('process is already running.'); + throw new RuntimeException('Process is already running.'); } - $process = clone $this; - $process->start($callback, $env); + $Process = clone $this; + $Process->start($callback, $env); - return $process; + return $Process; } /** - * Waits for the process to terminate. + * Waits for the Process to terminate. * * The callback receives the type of output (out or err) and some bytes - * from the output in real-time while writing the standard input to the process. - * It allows to have feedback from the independent process during execution. + * from the output in real-time while writing the standard input to the Process. + * It allows to have feedback from the independent Process during execution. * * @param callable|null $callback A valid PHP callback * - * @return int The exitcode of the process + * @return int The exitcode of the Process * - * @throws processTimedOutException When process timed out - * @throws processSignaledException When process stopped after receiving signal - * @throws LogicException When process is not yet started + * @throws ProcessTimedOutException When Process timed out + * @throws ProcessSignaledException When Process stopped after receiving signal + * @throws LogicException When Process is not yet started */ public function wait(callable $callback = null): int { - $this->requireprocessIsStarted(__FUNCTION__); + $this->requireProcessIsStarted(__FUNCTION__); $this->updateStatus(false); if (null !== $callback) { - if (!$this->processPipes->haveReadSupport()) { + if (!$this->ProcessPipes->haveReadSupport()) { $this->stop(0); - throw new LogicException('Pass the callback to the "process::start" method or call enableOutput to use a callback with "process::wait".'); + throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::wait".'); } $this->callback = $this->buildCallback($callback); } do { $this->checkTimeout(); - $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen(); + $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->ProcessPipes->areOpen(); $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running); } while ($running); @@ -430,8 +430,8 @@ class process implements \IteratorAggregate usleep(1000); } - if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) { - throw new processSignaledException($this); + if ($this->ProcessInformation['signaled'] && $this->ProcessInformation['termsig'] !== $this->latestSignal) { + throw new ProcessSignaledException($this); } return $this->exitcode; @@ -441,29 +441,29 @@ class process implements \IteratorAggregate * Waits until the callback returns true. * * The callback receives the type of output (out or err) and some bytes - * from the output in real-time while writing the standard input to the process. - * It allows to have feedback from the independent process during execution. + * from the output in real-time while writing the standard input to the Process. + * It allows to have feedback from the independent Process during execution. * - * @throws RuntimeException When process timed out - * @throws LogicException When process is not yet started - * @throws processTimedOutException In case the timeout was reached + * @throws RuntimeException When Process timed out + * @throws LogicException When Process is not yet started + * @throws ProcessTimedOutException In case the timeout was reached */ public function waitUntil(callable $callback): bool { - $this->requireprocessIsStarted(__FUNCTION__); + $this->requireProcessIsStarted(__FUNCTION__); $this->updateStatus(false); - if (!$this->processPipes->haveReadSupport()) { + if (!$this->ProcessPipes->haveReadSupport()) { $this->stop(0); - throw new LogicException('Pass the callback to the "process::start" method or call enableOutput to use a callback with "process::waitUntil".'); + throw new LogicException('Pass the callback to the "Process::start" method or call enableOutput to use a callback with "Process::waitUntil".'); } $callback = $this->buildCallback($callback); $ready = false; while (true) { $this->checkTimeout(); - $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen(); - $output = $this->processPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running); + $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->ProcessPipes->areOpen(); + $output = $this->ProcessPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running); foreach ($output as $type => $data) { if (3 !== $type) { @@ -484,24 +484,24 @@ class process implements \IteratorAggregate } /** - * Returns the Pid (process identifier), if applicable. + * Returns the Pid (Process identifier), if applicable. * - * @return int|null The process id if running, null otherwise + * @return int|null The Process id if running, null otherwise */ public function getPid(): ?int { - return $this->isRunning() ? $this->processInformation['pid'] : null; + return $this->isRunning() ? $this->ProcessInformation['pid'] : null; } /** - * Sends a POSIX signal to the process. + * Sends a POSIX signal to the Process. * * @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants) * * @return $this * - * @throws LogicException In case the process is not running - * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed + * @throws LogicException In case the Process is not running + * @throws RuntimeException In case --enable-sigchild is activated and the Process can't be killed * @throws RuntimeException In case of failure */ public function signal(int $signal): static @@ -512,17 +512,17 @@ class process implements \IteratorAggregate } /** - * Disables fetching output and error output from the underlying process. + * Disables fetching output and error output from the underlying Process. * * @return $this * - * @throws RuntimeException In case the process is already running + * @throws RuntimeException In case the Process is already running * @throws LogicException if an idle timeout is set */ public function disableOutput(): static { if ($this->isRunning()) { - throw new RuntimeException('Disabling output while the process is running is not possible.'); + throw new RuntimeException('Disabling output while the Process is running is not possible.'); } if (null !== $this->idleTimeout) { throw new LogicException('Output cannot be disabled while an idle timeout is set.'); @@ -534,16 +534,16 @@ class process implements \IteratorAggregate } /** - * Enables fetching output and error output from the underlying process. + * Enables fetching output and error output from the underlying Process. * * @return $this * - * @throws RuntimeException In case the process is already running + * @throws RuntimeException In case the Process is already running */ public function enableOutput(): static { if ($this->isRunning()) { - throw new RuntimeException('Enabling output while the process is running is not possible.'); + throw new RuntimeException('Enabling output while the Process is running is not possible.'); } $this->outputDisabled = false; @@ -560,10 +560,10 @@ class process implements \IteratorAggregate } /** - * Returns the current output of the process (STDOUT). + * Returns the current output of the Process (STDOUT). * * @throws LogicException in case the output has been disabled - * @throws LogicException In case the process is not started + * @throws LogicException In case the Process is not started */ public function getOutput(): string { @@ -583,7 +583,7 @@ class process implements \IteratorAggregate * output, this one returns the new output since the last call. * * @throws LogicException in case the output has been disabled - * @throws LogicException In case the process is not started + * @throws LogicException In case the Process is not started */ public function getIncrementalOutput(): string { @@ -600,12 +600,12 @@ class process implements \IteratorAggregate } /** - * Returns an iterator to the output of the process, with the output type as keys (process::OUT/ERR). + * Returns an iterator to the output of the Process, with the output type as keys (Process::OUT/ERR). * - * @param int $flags A bit field of process::ITER_* flags + * @param int $flags A bit field of Process::ITER_* flags * * @throws LogicException in case the output has been disabled - * @throws LogicException In case the process is not started + * @throws LogicException In case the Process is not started */ public function getIterator(int $flags = 0): \Generator { @@ -655,7 +655,7 @@ class process implements \IteratorAggregate } /** - * Clears the process output. + * Clears the Process output. * * @return $this */ @@ -669,10 +669,10 @@ class process implements \IteratorAggregate } /** - * Returns the current error output of the process (STDERR). + * Returns the current error output of the Process (STDERR). * * @throws LogicException in case the output has been disabled - * @throws LogicException In case the process is not started + * @throws LogicException In case the Process is not started */ public function getErrorOutput(): string { @@ -693,7 +693,7 @@ class process implements \IteratorAggregate * call. * * @throws LogicException in case the output has been disabled - * @throws LogicException In case the process is not started + * @throws LogicException In case the Process is not started */ public function getIncrementalErrorOutput(): string { @@ -710,7 +710,7 @@ class process implements \IteratorAggregate } /** - * Clears the process output. + * Clears the Process output. * * @return $this */ @@ -724,9 +724,9 @@ class process implements \IteratorAggregate } /** - * Returns the exit code returned by the process. + * Returns the exit code returned by the Process. * - * @return int|null The exit status code, null if the process is not terminated + * @return int|null The exit status code, null if the Process is not terminated */ public function getExitCode(): ?int { @@ -736,12 +736,12 @@ class process implements \IteratorAggregate } /** - * Returns a string representation for the exit code returned by the process. + * Returns a string representation for the exit code returned by the Process. * * This method relies on the Unix exit code status standardization * and might not be relevant for other operating systems. * - * @return string|null A string representation for the exit status code, null if the process is not terminated + * @return string|null A string representation for the exit status code, null if the Process is not terminated * * @see http://tldp.org/LDP/abs/html/exitcodes.html * @see http://en.wikipedia.org/wiki/Unix_signal @@ -756,7 +756,7 @@ class process implements \IteratorAggregate } /** - * Checks if the process ended successfully. + * Checks if the Process ended successfully. */ public function isSuccessful(): bool { @@ -764,68 +764,68 @@ class process implements \IteratorAggregate } /** - * Returns true if the child process has been terminated by an uncaught signal. + * Returns true if the child Process has been terminated by an uncaught signal. * * It always returns false on Windows. * - * @throws LogicException In case the process is not terminated + * @throws LogicException In case the Process is not terminated */ public function hasBeenSignaled(): bool { - $this->requireprocessIsTerminated(__FUNCTION__); + $this->requireProcessIsTerminated(__FUNCTION__); - return $this->processInformation['signaled']; + return $this->ProcessInformation['signaled']; } /** - * Returns the number of the signal that caused the child process to terminate its execution. + * Returns the number of the signal that caused the child Process to terminate its execution. * * It is only meaningful if hasBeenSignaled() returns true. * * @throws RuntimeException In case --enable-sigchild is activated - * @throws LogicException In case the process is not terminated + * @throws LogicException In case the Process is not terminated */ public function getTermSignal(): int { - $this->requireprocessIsTerminated(__FUNCTION__); + $this->requireProcessIsTerminated(__FUNCTION__); - if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) { + if ($this->isSigchildEnabled() && -1 === $this->ProcessInformation['termsig']) { throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal cannot be retrieved.'); } - return $this->processInformation['termsig']; + return $this->ProcessInformation['termsig']; } /** - * Returns true if the child process has been stopped by a signal. + * Returns true if the child Process has been stopped by a signal. * * It always returns false on Windows. * - * @throws LogicException In case the process is not terminated + * @throws LogicException In case the Process is not terminated */ public function hasBeenStopped(): bool { - $this->requireprocessIsTerminated(__FUNCTION__); + $this->requireProcessIsTerminated(__FUNCTION__); - return $this->processInformation['stopped']; + return $this->ProcessInformation['stopped']; } /** - * Returns the number of the signal that caused the child process to stop its execution. + * Returns the number of the signal that caused the child Process to stop its execution. * * It is only meaningful if hasBeenStopped() returns true. * - * @throws LogicException In case the process is not terminated + * @throws LogicException In case the Process is not terminated */ public function getStopSignal(): int { - $this->requireprocessIsTerminated(__FUNCTION__); + $this->requireProcessIsTerminated(__FUNCTION__); - return $this->processInformation['stopsig']; + return $this->ProcessInformation['stopsig']; } /** - * Checks if the process is currently running. + * Checks if the Process is currently running. */ public function isRunning(): bool { @@ -835,11 +835,11 @@ class process implements \IteratorAggregate $this->updateStatus(false); - return $this->processInformation['running']; + return $this->ProcessInformation['running']; } /** - * Checks if the process has been started with no regard to the current state. + * Checks if the Process has been started with no regard to the current state. */ public function isStarted(): bool { @@ -847,7 +847,7 @@ class process implements \IteratorAggregate } /** - * Checks if the process is terminated. + * Checks if the Process is terminated. */ public function isTerminated(): bool { @@ -857,7 +857,7 @@ class process implements \IteratorAggregate } /** - * Gets the process status. + * Gets the Process status. * * The status is one of: ready, started, terminated. */ @@ -869,12 +869,12 @@ class process implements \IteratorAggregate } /** - * Stops the process. + * Stops the Process. * * @param int|float $timeout The timeout in seconds - * @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9) + * @param int $signal A POSIX signal to send in case the Process has not stop at timeout, default is SIGKILL (9) * - * @return int|null The exit-code of the process or null if it's not running + * @return int|null The exit-code of the Process or null if it's not running */ public function stop(float $timeout = 10, int $signal = null): ?int { @@ -887,7 +887,7 @@ class process implements \IteratorAggregate } while ($this->isRunning() && microtime(true) < $timeoutMicro); if ($this->isRunning()) { - // Avoid exception here: process is supposed to be running, but it might have stopped just + // Avoid exception here: Process is supposed to be running, but it might have stopped just // after this line. In any case, let's silently discard the error, we cannot do anything. $this->doSignal($signal ?: 9, false); } @@ -950,7 +950,7 @@ class process implements \IteratorAggregate } /** - * Gets the process timeout in seconds (max. runtime). + * Gets the Process timeout in seconds (max. runtime). */ public function getTimeout(): ?float { @@ -958,7 +958,7 @@ class process implements \IteratorAggregate } /** - * Gets the process idle timeout in seconds (max. time since last output). + * Gets the Process idle timeout in seconds (max. time since last output). */ public function getIdleTimeout(): ?float { @@ -966,7 +966,7 @@ class process implements \IteratorAggregate } /** - * Sets the process timeout (max. runtime) in seconds. + * Sets the Process timeout (max. runtime) in seconds. * * To disable the timeout, set this value to null. * @@ -982,7 +982,7 @@ class process implements \IteratorAggregate } /** - * Sets the process idle timeout (max. time since last output) in seconds. + * Sets the Process idle timeout (max. time since last output) in seconds. * * To disable the timeout, set this value to null. * @@ -1101,7 +1101,7 @@ class process implements \IteratorAggregate } /** - * Gets the process input. + * Gets the Process input. * * @return resource|string|\Iterator|null */ @@ -1113,32 +1113,32 @@ class process implements \IteratorAggregate /** * Sets the input. * - * This content will be passed to the underlying process standard input. + * This content will be passed to the underlying Process standard input. * * @param string|int|float|bool|resource|\Traversable|null $input The content * * @return $this * - * @throws LogicException In case the process is running + * @throws LogicException In case the Process is running */ public function setInput(mixed $input): static { if ($this->isRunning()) { - throw new LogicException('Input cannot be set while the process is running.'); + throw new LogicException('Input cannot be set while the Process is running.'); } - $this->input = processUtils::validateInput(__METHOD__, $input); + $this->input = ProcessUtils::validateInput(__METHOD__, $input); return $this; } /** - * Performs a check between the timeout definition and the time the process started. + * Performs a check between the timeout definition and the time the Process started. * - * In case you run a background process (with the start method), you should - * trigger this method regularly to ensure the process timeout + * In case you run a background Process (with the start method), you should + * trigger this method regularly to ensure the Process timeout * - * @throws processTimedOutException In case the timeout was reached + * @throws ProcessTimedOutException In case the timeout was reached */ public function checkTimeout() { @@ -1149,23 +1149,23 @@ class process implements \IteratorAggregate if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) { $this->stop(0); - throw new processTimedOutException($this, processTimedOutException::TYPE_GENERAL); + throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL); } if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) { $this->stop(0); - throw new processTimedOutException($this, processTimedOutException::TYPE_IDLE); + throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE); } } /** - * @throws LogicException in case process is not started + * @throws LogicException in case Process is not started */ public function getStartTime(): float { if (!$this->isStarted()) { - throw new LogicException('Start time is only available after process start.'); + throw new LogicException('Start time is only available after Process start.'); } return $this->starttime; @@ -1176,17 +1176,17 @@ class process implements \IteratorAggregate * * @see https://php.net/proc_open for the options supported by PHP. * - * Enabling the "create_new_console" option allows a subprocess to continue - * to run after the main process exited, on both Windows and *nix + * Enabling the "create_new_console" option allows a subProcess to continue + * to run after the main Process exited, on both Windows and *nix */ public function setOptions(array $options) { if ($this->isRunning()) { - throw new RuntimeException('Setting options while the process is running is not possible.'); + throw new RuntimeException('Setting options while the Process is running is not possible.'); } $defaultOptions = $this->options; - $existingOptions = ['blocking_pipes', 'create_process_group', 'create_new_console']; + $existingOptions = ['blocking_pipes', 'create_Process_group', 'create_new_console']; foreach ($options as $key => $value) { if (!\in_array($key, $existingOptions)) { @@ -1238,12 +1238,12 @@ class process implements \IteratorAggregate $this->input->rewind(); } if ('\\' === \DIRECTORY_SEPARATOR) { - $this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); + $this->ProcessPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback); } else { - $this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); + $this->ProcessPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDisabled || $this->hasCallback); } - return $this->processPipes->getDescriptors(); + return $this->ProcessPipes->getDescriptors(); } /** @@ -1276,7 +1276,7 @@ class process implements \IteratorAggregate } /** - * Updates the status of the process, reads pipes. + * Updates the status of the Process, reads pipes. * * @param bool $blocking Whether to use a blocking read call */ @@ -1286,13 +1286,13 @@ class process implements \IteratorAggregate return; } - $this->processInformation = proc_get_status($this->process); - $running = $this->processInformation['running']; + $this->ProcessInformation = proc_get_status($this->Process); + $running = $this->ProcessInformation['running']; $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running); if ($this->fallbackStatus && $this->isSigchildEnabled()) { - $this->processInformation = $this->fallbackStatus + $this->processInformation; + $this->ProcessInformation = $this->fallbackStatus + $this->ProcessInformation; } if (!$running) { @@ -1325,7 +1325,7 @@ class process implements \IteratorAggregate * @param string $caller The name of the method that needs fresh outputs * @param bool $blocking Whether to use blocking calls or not * - * @throws LogicException in case output has been disabled or process is not started + * @throws LogicException in case output has been disabled or Process is not started */ private function readPipesForOutput(string $caller, bool $blocking = false) { @@ -1333,7 +1333,7 @@ class process implements \IteratorAggregate throw new LogicException('Output has been disabled.'); } - $this->requireprocessIsStarted($caller); + $this->requireProcessIsStarted($caller); $this->updateStatus($blocking); } @@ -1364,7 +1364,7 @@ class process implements \IteratorAggregate */ private function readPipes(bool $blocking, bool $close) { - $result = $this->processPipes->readAndWrite($blocking, $close); + $result = $this->ProcessPipes->readAndWrite($blocking, $close); $callback = $this->callback; foreach ($result as $type => $data) { @@ -1377,26 +1377,26 @@ class process implements \IteratorAggregate } /** - * Closes process resource, closes file handles, sets the exitcode. + * Closes Process resource, closes file handles, sets the exitcode. * * @return int The exitcode */ private function close(): int { - $this->processPipes->close(); - if (\is_resource($this->process)) { - proc_close($this->process); + $this->ProcessPipes->close(); + if (\is_resource($this->Process)) { + proc_close($this->Process); } - $this->exitcode = $this->processInformation['exitcode']; + $this->exitcode = $this->ProcessInformation['exitcode']; $this->status = self::STATUS_TERMINATED; if (-1 === $this->exitcode) { - if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) { - // if process has been signaled, no exitcode but a valid termsig, apply Unix convention - $this->exitcode = 128 + $this->processInformation['termsig']; + if ($this->ProcessInformation['signaled'] && 0 < $this->ProcessInformation['termsig']) { + // if Process has been signaled, no exitcode but a valid termsig, apply Unix convention + $this->exitcode = 128 + $this->ProcessInformation['termsig']; } elseif ($this->isSigchildEnabled()) { - $this->processInformation['signaled'] = true; - $this->processInformation['termsig'] = -1; + $this->ProcessInformation['signaled'] = true; + $this->ProcessInformation['termsig'] = -1; } } @@ -1409,18 +1409,18 @@ class process implements \IteratorAggregate } /** - * Resets data related to the latest run of the process. + * Resets data related to the latest run of the Process. */ - private function resetprocessData() + private function resetProcessData() { $this->starttime = null; $this->callback = null; $this->exitcode = null; $this->fallbackStatus = []; - $this->processInformation = null; + $this->ProcessInformation = null; $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+'); - $this->process = null; + $this->Process = null; $this->latestSignal = null; $this->status = self::STATUS_READY; $this->incrementalOutputOffset = 0; @@ -1428,20 +1428,20 @@ class process implements \IteratorAggregate } /** - * Sends a POSIX signal to the process. + * Sends a POSIX signal to the Process. * * @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants) * @param bool $throwException Whether to throw exception in case signal failed * - * @throws LogicException In case the process is not running - * @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed + * @throws LogicException In case the Process is not running + * @throws RuntimeException In case --enable-sigchild is activated and the Process can't be killed * @throws RuntimeException In case of failure */ private function doSignal(int $signal, bool $throwException): bool { if (null === $pid = $this->getPid()) { if ($throwException) { - throw new LogicException('Cannot send signal on a non running process.'); + throw new LogicException('Cannot send signal on a non running Process.'); } return false; @@ -1451,14 +1451,14 @@ class process implements \IteratorAggregate exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode); if ($exitCode && $this->isRunning()) { if ($throwException) { - throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output))); + throw new RuntimeException(sprintf('Unable to kill the Process (%s).', implode(' ', $output))); } return false; } } else { if (!$this->isSigchildEnabled()) { - $ok = @proc_terminate($this->process, $signal); + $ok = @proc_terminate($this->Process, $signal); } elseif (\function_exists('posix_kill')) { $ok = @posix_kill($pid, $signal); } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), [2 => ['pipe', 'w']], $pipes)) { @@ -1520,7 +1520,7 @@ class process implements \IteratorAggregate ); $cmd = 'cmd /V:ON /E:ON /D /C ('.str_replace("\n", ' ', $cmd).')'; - foreach ($this->processPipes->getFiles() as $offset => $filename) { + foreach ($this->ProcessPipes->getFiles() as $offset => $filename) { $cmd .= ' '.$offset.'>"'.$filename.'"'; } @@ -1528,26 +1528,26 @@ class process implements \IteratorAggregate } /** - * Ensures the process is running or terminated, throws a LogicException if the process has a not started. + * Ensures the Process is running or terminated, throws a LogicException if the Process has a not started. * - * @throws LogicException if the process has not run + * @throws LogicException if the Process has not run */ - private function requireprocessIsStarted(string $functionName) + private function requireProcessIsStarted(string $functionName) { if (!$this->isStarted()) { - throw new LogicException(sprintf('process must be started before calling "%s()".', $functionName)); + throw new LogicException(sprintf('Process must be started before calling "%s()".', $functionName)); } } /** - * Ensures the process is terminated, throws a LogicException if the process has a status different than "terminated". + * Ensures the Process is terminated, throws a LogicException if the Process has a status different than "terminated". * - * @throws LogicException if the process is not yet terminated + * @throws LogicException if the Process is not yet terminated */ - private function requireprocessIsTerminated(string $functionName) + private function requireProcessIsTerminated(string $functionName) { if (!$this->isTerminated()) { - throw new LogicException(sprintf('process must be terminated before calling "%s()".', $functionName)); + throw new LogicException(sprintf('Process must be terminated before calling "%s()".', $functionName)); } } diff --git a/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php b/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php index bd66db2..fae0b5f 100644 --- a/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php +++ b/src/ncc/ThirdParty/Symfony/Process/ProcessUtils.php @@ -9,18 +9,18 @@ * file that was distributed with this source code. */ -namespace ncc\ThirdParty\Symfony\process; +namespace ncc\ThirdParty\Symfony\Process; -use ncc\ThirdParty\Symfony\process\Exception\InvalidArgumentException; +use ncc\ThirdParty\Symfony\Process\Exception\InvalidArgumentException; /** - * processUtils is a bunch of utility methods. + * ProcessUtils is a bunch of utility methods. * * This class contains static methods only and is not meant to be instantiated. * * @author Martin HasoĊˆ */ -class processUtils +class ProcessUtils { /** * This class should not be instantiated. @@ -30,7 +30,7 @@ class processUtils } /** - * Validates and normalizes a process input. + * Validates and normalizes a Process input. * * @param string $caller The name of method call that validates the input * @param mixed $input The input to validate @@ -49,7 +49,7 @@ class processUtils if (\is_scalar($input)) { return (string) $input; } - if ($input instanceof process) { + if ($input instanceof Process) { return $input->getIterator($input::ITER_SKIP_ERR); } if ($input instanceof \Iterator) { diff --git a/src/ncc/ThirdParty/Symfony/Process/README.md b/src/ncc/ThirdParty/Symfony/Process/README.md index d9d900f..4b88104 100644 --- a/src/ncc/ThirdParty/Symfony/Process/README.md +++ b/src/ncc/ThirdParty/Symfony/Process/README.md @@ -1,12 +1,12 @@ -process Component +Process Component ================= -The process component executes commands in sub-processes. +The Process component executes commands in sub-Processes. Sponsor ------- -The process component for Symfony 6.1 is [backed][1] by [SensioLabs][2]. +The Process component for Symfony 6.1 is [backed][1] by [SensioLabs][2]. As the creator of Symfony, SensioLabs supports companies using Symfony, with an offering encompassing consultancy, expertise, services, training, and technical @@ -17,7 +17,7 @@ Help Symfony by [sponsoring][3] its development! Resources --------- - * [Documentation](https://symfony.com/doc/current/components/process.html) + * [Documentation](https://symfony.com/doc/current/components/Process.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) diff --git a/src/ncc/Utilities/Console.php b/src/ncc/Utilities/Console.php index 102bbab..01d8418 100644 --- a/src/ncc/Utilities/Console.php +++ b/src/ncc/Utilities/Console.php @@ -11,14 +11,14 @@ * Inline Progress bar, created by dealnews.com. * * // TODO: Add non-inline option - * @copyright Copyright (c) 2010, dealnews.com, Inc. All rights reserved. * @param int $value * @param int $total * @param int $size - * @param array $flags + * @param array $options * @return void + *@copyright Copyright (c) 2010, dealnews.com, Inc. All rights reserved. */ - public static function inlineProgressBar(int $value, int $total, int $size=38, array $flags=[]) + public static function inlineProgressBar(int $value, int $total, int $size=38, array $options=[]) { static $start_time; @@ -48,10 +48,15 @@ $rate = ($now-$start_time)/$value; $left = $total - $value; $eta = round($rate * $left, 2); - $elapsed = $now - $start_time; - $status_bar.= " remaining: ".number_format($eta)." sec. elapsed: ".number_format($elapsed)." sec."; + $remaining_text = 'remaining: '; + if(isset($options['remaining_text'])) + { + $remaining_text = $options['remaining_text']; + } + + $status_bar.= " $remaining_text ".number_format($eta)." sec. elapsed: ".number_format($elapsed)." sec."; echo "$status_bar "; @@ -217,7 +222,6 @@ 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 b236353..deb1050 100644 --- a/src/ncc/Utilities/Validate.php +++ b/src/ncc/Utilities/Validate.php @@ -21,6 +21,7 @@ $requirements = [ 'zlib', 'libxml', + 'curl', 'ctype', 'json', 'mbstring', diff --git a/src/ncc/autoload.php b/src/ncc/autoload.php index e906f54..a1d00d1 100644 --- a/src/ncc/autoload.php +++ b/src/ncc/autoload.php @@ -20,6 +20,7 @@ $third_party_path . 'Symfony' . DIRECTORY_SEPARATOR . 'polyfill-mbstring' . DIRECTORY_SEPARATOR . 'bootstrap.php', $third_party_path . 'Symfony' . DIRECTORY_SEPARATOR . 'Process' . DIRECTORY_SEPARATOR . 'autoload_spl.php', $third_party_path . 'Symfony' . DIRECTORY_SEPARATOR . 'Uid' . DIRECTORY_SEPARATOR . 'autoload_spl.php', + $third_party_path . 'Symfony' . DIRECTORY_SEPARATOR . 'Filesystem' . DIRECTORY_SEPARATOR . 'autoload_spl.php', ]; foreach($target_files as $file) diff --git a/src/ncc/ncc b/src/ncc/ncc index 826662f..2ff9e10 100644 --- a/src/ncc/ncc +++ b/src/ncc/ncc @@ -1,5 +1,4 @@ UpdateSource); define('NCC_VERSION_FLAGS', $VersionInformation->Flags); + define('NCC_INIT', 1); return true; } diff --git a/src/ncc/version.json b/src/ncc/version.json index dfceba6..74a3702 100644 --- a/src/ncc/version.json +++ b/src/ncc/version.json @@ -17,11 +17,11 @@ }, { "vendor": "Symfony", - "package_name": "polyfill-Process" + "package_name": "Process" }, { "vendor": "Symfony", - "package_name": "polyfill-uid" + "package_name": "Uid" }, { "vendor": "Symfony",