One Hat Cyber Team
Your IP:
216.73.216.102
Server IP:
198.54.114.155
Server:
Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
Server Software:
LiteSpeed
PHP Version:
5.6.40
Create File
|
Create Folder
Execute
Dir :
~
/
home
/
fluxyjvi
/
public_html
/
assets
/
images
/
Edit File:
PHP.tar
DefaultPhpProcess.php 0000644 00000010076 15107473155 0010664 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of PHPUnit. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PHPUnit\Util\PHP; use function array_merge; use function fclose; use function file_put_contents; use function fwrite; use function is_array; use function is_resource; use function proc_close; use function proc_open; use function rewind; use function stream_get_contents; use function sys_get_temp_dir; use function tempnam; use function unlink; use PHPUnit\Framework\Exception; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ class DefaultPhpProcess extends AbstractPhpProcess { private ?string $tempFile = null; /** * Runs a single job (PHP code) using a separate PHP process. * * @psalm-return array{stdout: string, stderr: string} * * @throws Exception * @throws PhpProcessException */ public function runJob(string $job, array $settings = []): array { if ($this->stdin || $this->useTemporaryFile()) { if (!($this->tempFile = tempnam(sys_get_temp_dir(), 'phpunit_')) || file_put_contents($this->tempFile, $job) === false) { throw new PhpProcessException( 'Unable to write temporary file', ); } $job = $this->stdin; } return $this->runProcess($job, $settings); } /** * Returns an array of file handles to be used in place of pipes. */ protected function getHandles(): array { return []; } /** * Handles creating the child process and returning the STDOUT and STDERR. * * @psalm-return array{stdout: string, stderr: string} * * @throws Exception * @throws PhpProcessException */ protected function runProcess(string $job, array $settings): array { $handles = $this->getHandles(); $env = null; if ($this->env) { $env = $_SERVER ?? []; unset($env['argv'], $env['argc']); $env = array_merge($env, $this->env); foreach ($env as $envKey => $envVar) { if (is_array($envVar)) { unset($env[$envKey]); } } } $pipeSpec = [ 0 => $handles[0] ?? ['pipe', 'r'], 1 => $handles[1] ?? ['pipe', 'w'], 2 => $handles[2] ?? ['pipe', 'w'], ]; $process = proc_open( $this->getCommand($settings, $this->tempFile), $pipeSpec, $pipes, null, $env, ); if (!is_resource($process)) { throw new PhpProcessException( 'Unable to spawn worker process', ); } if ($job) { $this->process($pipes[0], $job); } fclose($pipes[0]); $stderr = $stdout = ''; if (isset($pipes[1])) { $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); } if (isset($pipes[2])) { $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); } if (isset($handles[1])) { rewind($handles[1]); $stdout = stream_get_contents($handles[1]); fclose($handles[1]); } if (isset($handles[2])) { rewind($handles[2]); $stderr = stream_get_contents($handles[2]); fclose($handles[2]); } proc_close($process); $this->cleanup(); return ['stdout' => $stdout, 'stderr' => $stderr]; } /** * @param resource $pipe */ protected function process($pipe, string $job): void { fwrite($pipe, $job); } protected function cleanup(): void { if ($this->tempFile) { unlink($this->tempFile); } } protected function useTemporaryFile(): bool { return false; } } Template/TestCaseMethod.tpl 0000644 00000006226 15107473155 0011732 0 ustar 00 <?php declare(strict_types=1); use PHPUnit\Event\Facade; use PHPUnit\Runner\CodeCoverage; use PHPUnit\TextUI\Configuration\Registry as ConfigurationRegistry; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\TextUI\XmlConfiguration\Loader; use PHPUnit\TextUI\Configuration\PhpHandler; use PHPUnit\TestRunner\TestResult\PassedTests; // php://stdout does not obey output buffering. Any output would break // unserialization of child process results in the parent process. if (!defined('STDOUT')) { define('STDOUT', fopen('php://temp', 'w+b')); define('STDERR', fopen('php://stderr', 'wb')); } {iniSettings} ini_set('display_errors', 'stderr'); set_include_path('{include_path}'); $composerAutoload = {composerAutoload}; $phar = {phar}; ob_start(); if ($composerAutoload) { require_once $composerAutoload; define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload); } else if ($phar) { require $phar; } function __phpunit_run_isolated_test() { $dispatcher = Facade::instance()->initForIsolation( PHPUnit\Event\Telemetry\HRTime::fromSecondsAndNanoseconds( {offsetSeconds}, {offsetNanoseconds} ), {exportObjects}, ); require_once '{filename}'; if ({collectCodeCoverageInformation}) { CodeCoverage::instance()->init(ConfigurationRegistry::get(), CodeCoverageFilterRegistry::instance(), true); CodeCoverage::instance()->ignoreLines({linesToBeIgnored}); } $test = new {className}('{methodName}'); $test->setData('{dataName}', unserialize('{data}')); $test->setDependencyInput(unserialize('{dependencyInput}')); $test->setInIsolation(true); ob_end_clean(); $test->run(); $output = ''; if (!$test->expectsOutput()) { $output = $test->output(); } ini_set('xdebug.scream', '0'); // Not every STDOUT target stream is rewindable @rewind(STDOUT); if ($stdout = @stream_get_contents(STDOUT)) { $output = $stdout . $output; $streamMetaData = stream_get_meta_data(STDOUT); if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) { @ftruncate(STDOUT, 0); @rewind(STDOUT); } } file_put_contents( '{processResultFile}', serialize( [ 'testResult' => $test->result(), 'codeCoverage' => {collectCodeCoverageInformation} ? CodeCoverage::instance()->codeCoverage() : null, 'numAssertions' => $test->numberOfAssertionsPerformed(), 'output' => $output, 'events' => $dispatcher->flush(), 'passedTests' => PassedTests::instance() ] ) ); } function __phpunit_error_handler($errno, $errstr, $errfile, $errline) { return true; } set_error_handler('__phpunit_error_handler'); {constants} {included_files} {globals} restore_error_handler(); ConfigurationRegistry::loadFrom('{serializedConfiguration}'); (new PhpHandler)->handle(ConfigurationRegistry::get()->php()); if ('{bootstrap}' !== '') { require_once '{bootstrap}'; } __phpunit_run_isolated_test(); Template/PhptTestCase.tpl 0000644 00000002243 15107473155 0011420 0 ustar 00 <?php declare(strict_types=1); use SebastianBergmann\CodeCoverage\CodeCoverage; use SebastianBergmann\CodeCoverage\Driver\Selector; use SebastianBergmann\CodeCoverage\Filter; $composerAutoload = {composerAutoload}; $phar = {phar}; ob_start(); $GLOBALS['__PHPUNIT_ISOLATION_EXCLUDE_LIST'][] = '{job}'; if ($composerAutoload) { require_once $composerAutoload; define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload); } else if ($phar) { require $phar; } $coverage = null; if ('{bootstrap}' !== '') { require_once '{bootstrap}'; } if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) { $filter = new Filter; $coverage = new CodeCoverage( (new Selector)->{driverMethod}($filter), $filter ); if ({codeCoverageCacheDirectory}) { $coverage->cacheStaticAnalysis({codeCoverageCacheDirectory}); } $coverage->start(__FILE__); } register_shutdown_function( function() use ($coverage) { $output = null; if ($coverage) { $output = $coverage->stop(); } file_put_contents('{coverageFile}', serialize($output)); } ); ob_end_clean(); require '{job}'; Template/TestCaseClass.tpl 0000644 00000006220 15107473155 0011551 0 ustar 00 <?php declare(strict_types=1); use PHPUnit\Event\Facade; use PHPUnit\Runner\CodeCoverage; use PHPUnit\TextUI\Configuration\Registry as ConfigurationRegistry; use PHPUnit\TextUI\Configuration\CodeCoverageFilterRegistry; use PHPUnit\TextUI\XmlConfiguration\Loader; use PHPUnit\TextUI\Configuration\PhpHandler; use PHPUnit\TestRunner\TestResult\PassedTests; // php://stdout does not obey output buffering. Any output would break // unserialization of child process results in the parent process. if (!defined('STDOUT')) { define('STDOUT', fopen('php://temp', 'w+b')); define('STDERR', fopen('php://stderr', 'wb')); } {iniSettings} ini_set('display_errors', 'stderr'); set_include_path('{include_path}'); $composerAutoload = {composerAutoload}; $phar = {phar}; ob_start(); if ($composerAutoload) { require_once $composerAutoload; define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload); } else if ($phar) { require $phar; } function __phpunit_run_isolated_test() { $dispatcher = Facade::instance()->initForIsolation( PHPUnit\Event\Telemetry\HRTime::fromSecondsAndNanoseconds( {offsetSeconds}, {offsetNanoseconds} ), {exportObjects}, ); require_once '{filename}'; if ({collectCodeCoverageInformation}) { CodeCoverage::instance()->init(ConfigurationRegistry::get(), CodeCoverageFilterRegistry::instance(), true); CodeCoverage::instance()->ignoreLines({linesToBeIgnored}); } $test = new {className}('{name}'); $test->setData('{dataName}', unserialize('{data}')); $test->setDependencyInput(unserialize('{dependencyInput}')); $test->setInIsolation(true); ob_end_clean(); $test->run(); $output = ''; if (!$test->expectsOutput()) { $output = $test->output(); } ini_set('xdebug.scream', '0'); // Not every STDOUT target stream is rewindable @rewind(STDOUT); if ($stdout = @stream_get_contents(STDOUT)) { $output = $stdout . $output; $streamMetaData = stream_get_meta_data(STDOUT); if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) { @ftruncate(STDOUT, 0); @rewind(STDOUT); } } file_put_contents( '{processResultFile}', serialize( [ 'testResult' => $test->result(), 'codeCoverage' => {collectCodeCoverageInformation} ? CodeCoverage::instance()->codeCoverage() : null, 'numAssertions' => $test->numberOfAssertionsPerformed(), 'output' => $output, 'events' => $dispatcher->flush(), 'passedTests' => PassedTests::instance() ] ) ); } function __phpunit_error_handler($errno, $errstr, $errfile, $errline) { return true; } set_error_handler('__phpunit_error_handler'); {constants} {included_files} {globals} restore_error_handler(); ConfigurationRegistry::loadFrom('{serializedConfiguration}'); (new PhpHandler)->handle(ConfigurationRegistry::get()->php()); if ('{bootstrap}' !== '') { require_once '{bootstrap}'; } __phpunit_run_isolated_test(); WindowsPhpProcess.php 0000644 00000002034 15107473155 0010725 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of PHPUnit. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PHPUnit\Util\PHP; use function tmpfile; use PHPUnit\Framework\Exception; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit * * @see https://bugs.php.net/bug.php?id=51800 */ final class WindowsPhpProcess extends DefaultPhpProcess { /** * @throws Exception * @throws PhpProcessException */ protected function getHandles(): array { if (false === $stdout_handle = tmpfile()) { throw new PhpProcessException( 'A temporary file could not be created; verify that your TEMP environment variable is writable', ); } return [ 1 => $stdout_handle, ]; } protected function useTemporaryFile(): bool { return true; } } AbstractPhpProcess.php 0000644 00000020436 15107473155 0011044 0 ustar 00 <?php declare(strict_types=1); /* * This file is part of PHPUnit. * * (c) Sebastian Bergmann <sebastian@phpunit.de> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace PHPUnit\Util\PHP; use const PHP_SAPI; use function array_keys; use function array_merge; use function assert; use function escapeshellarg; use function file_exists; use function file_get_contents; use function ini_get_all; use function restore_error_handler; use function set_error_handler; use function trim; use function unlink; use function unserialize; use ErrorException; use PHPUnit\Event\Code\TestMethodBuilder; use PHPUnit\Event\Code\ThrowableBuilder; use PHPUnit\Event\Facade; use PHPUnit\Event\NoPreviousThrowableException; use PHPUnit\Event\TestData\MoreThanOneDataSetFromDataProviderException; use PHPUnit\Framework\AssertionFailedError; use PHPUnit\Framework\Exception; use PHPUnit\Framework\Test; use PHPUnit\Framework\TestCase; use PHPUnit\Runner\CodeCoverage; use PHPUnit\TestRunner\TestResult\PassedTests; use SebastianBergmann\Environment\Runtime; /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ abstract class AbstractPhpProcess { protected bool $stderrRedirection = false; protected string $stdin = ''; protected string $arguments = ''; /** * @psalm-var array<string, string> */ protected array $env = []; public static function factory(): self { if (PHP_OS_FAMILY === 'Windows') { return new WindowsPhpProcess; } return new DefaultPhpProcess; } /** * Defines if should use STDERR redirection or not. * * Then $stderrRedirection is TRUE, STDERR is redirected to STDOUT. */ public function setUseStderrRedirection(bool $stderrRedirection): void { $this->stderrRedirection = $stderrRedirection; } /** * Returns TRUE if uses STDERR redirection or FALSE if not. */ public function useStderrRedirection(): bool { return $this->stderrRedirection; } /** * Sets the input string to be sent via STDIN. */ public function setStdin(string $stdin): void { $this->stdin = $stdin; } /** * Returns the input string to be sent via STDIN. */ public function getStdin(): string { return $this->stdin; } /** * Sets the string of arguments to pass to the php job. */ public function setArgs(string $arguments): void { $this->arguments = $arguments; } /** * Returns the string of arguments to pass to the php job. */ public function getArgs(): string { return $this->arguments; } /** * Sets the array of environment variables to start the child process with. * * @psalm-param array<string, string> $env */ public function setEnv(array $env): void { $this->env = $env; } /** * Returns the array of environment variables to start the child process with. */ public function getEnv(): array { return $this->env; } /** * Runs a single test in a separate PHP process. * * @throws \PHPUnit\Runner\Exception * @throws Exception * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ public function runTestJob(string $job, Test $test, string $processResultFile): void { $_result = $this->runJob($job); $processResult = ''; if (file_exists($processResultFile)) { $processResult = file_get_contents($processResultFile); @unlink($processResultFile); } $this->processChildResult( $test, $processResult, $_result['stderr'], ); } /** * Returns the command based into the configurations. */ public function getCommand(array $settings, string $file = null): string { $runtime = new Runtime; $command = $runtime->getBinary(); if ($runtime->hasPCOV()) { $settings = array_merge( $settings, $runtime->getCurrentSettings( array_keys(ini_get_all('pcov')), ), ); } elseif ($runtime->hasXdebug()) { $settings = array_merge( $settings, $runtime->getCurrentSettings( array_keys(ini_get_all('xdebug')), ), ); } $command .= $this->settingsToParameters($settings); if (PHP_SAPI === 'phpdbg') { $command .= ' -qrr'; if (!$file) { $command .= 's='; } } if ($file) { $command .= ' ' . escapeshellarg($file); } if ($this->arguments) { if (!$file) { $command .= ' --'; } $command .= ' ' . $this->arguments; } if ($this->stderrRedirection) { $command .= ' 2>&1'; } return $command; } /** * Runs a single job (PHP code) using a separate PHP process. */ abstract public function runJob(string $job, array $settings = []): array; protected function settingsToParameters(array $settings): string { $buffer = ''; foreach ($settings as $setting) { $buffer .= ' -d ' . escapeshellarg($setting); } return $buffer; } /** * @throws \PHPUnit\Runner\Exception * @throws Exception * @throws MoreThanOneDataSetFromDataProviderException * @throws NoPreviousThrowableException */ private function processChildResult(Test $test, string $stdout, string $stderr): void { if (!empty($stderr)) { $exception = new Exception(trim($stderr)); assert($test instanceof TestCase); Facade::emitter()->testErrored( TestMethodBuilder::fromTestCase($test), ThrowableBuilder::from($exception), ); return; } set_error_handler( /** * @throws ErrorException */ static function (int $errno, string $errstr, string $errfile, int $errline): never { throw new ErrorException($errstr, $errno, $errno, $errfile, $errline); }, ); try { $childResult = unserialize($stdout); restore_error_handler(); if ($childResult === false) { $exception = new AssertionFailedError('Test was run in child process and ended unexpectedly'); assert($test instanceof TestCase); Facade::emitter()->testErrored( TestMethodBuilder::fromTestCase($test), ThrowableBuilder::from($exception), ); Facade::emitter()->testFinished( TestMethodBuilder::fromTestCase($test), 0, ); } } catch (ErrorException $e) { restore_error_handler(); $childResult = false; $exception = new Exception(trim($stdout), 0, $e); assert($test instanceof TestCase); Facade::emitter()->testErrored( TestMethodBuilder::fromTestCase($test), ThrowableBuilder::from($exception), ); } if ($childResult !== false) { if (!empty($childResult['output'])) { $output = $childResult['output']; } Facade::instance()->forward($childResult['events']); PassedTests::instance()->import($childResult['passedTests']); assert($test instanceof TestCase); $test->setResult($childResult['testResult']); $test->addToAssertionCount($childResult['numAssertions']); if (CodeCoverage::instance()->isActive() && $childResult['codeCoverage'] instanceof \SebastianBergmann\CodeCoverage\CodeCoverage) { CodeCoverage::instance()->codeCoverage()->merge( $childResult['codeCoverage'], ); } } if (!empty($output)) { print $output; } } }
Simpan