Перенес код
This commit is contained in:
69
vendor/phpunit/php-invoker/ChangeLog.md
vendored
Normal file
69
vendor/phpunit/php-invoker/ChangeLog.md
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
# ChangeLog
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
|
||||
|
||||
## [5.0.1] - 2024-07-03
|
||||
|
||||
### Changed
|
||||
|
||||
* This project now uses PHPStan instead of Psalm for static analysis
|
||||
|
||||
## [5.0.0] - 2024-02-02
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 8.1
|
||||
|
||||
## [4.0.0] - 2023-02-03
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0
|
||||
|
||||
## [3.1.1] - 2020-09-28
|
||||
|
||||
### Changed
|
||||
|
||||
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
|
||||
|
||||
## [3.1.0] - 2020-08-06
|
||||
|
||||
### Changed
|
||||
|
||||
* [#14](https://github.com/sebastianbergmann/php-invoker/pull/14): Clear alarm in `finally` block
|
||||
|
||||
## [3.0.2] - 2020-06-26
|
||||
|
||||
### Added
|
||||
|
||||
* This component is now supported on PHP 8
|
||||
|
||||
## [3.0.1] - 2020-06-15
|
||||
|
||||
### Changed
|
||||
|
||||
* Tests etc. are now ignored for archive exports
|
||||
|
||||
## [3.0.0] - 2020-02-07
|
||||
|
||||
### Added
|
||||
|
||||
* Added `canInvokeWithTimeout()` method to check requirements for the functionality provided by this component to work
|
||||
|
||||
### Changed
|
||||
|
||||
* Moved `"ext-pcntl": "*"` requirement from `require` to `suggest` so that this component can be installed even if `ext/pcntl` is not available
|
||||
* `invoke()` now raises an exception when the requirements for the functionality provided by this component to work are not met
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 7.1 and PHP 7.2
|
||||
|
||||
[5.0.1]: https://github.com/sebastianbergmann/php-invoker/compare/5.0.1...5.0.1
|
||||
[5.0.0]: https://github.com/sebastianbergmann/php-invoker/compare/4.0...5.0.0
|
||||
[4.0.0]: https://github.com/sebastianbergmann/php-invoker/compare/3.1.1...4.0.0
|
||||
[3.1.1]: https://github.com/sebastianbergmann/php-invoker/compare/3.1.0...3.1.1
|
||||
[3.1.0]: https://github.com/sebastianbergmann/php-invoker/compare/3.0.2...3.1.0
|
||||
[3.0.2]: https://github.com/sebastianbergmann/php-invoker/compare/3.0.1...3.0.2
|
||||
[3.0.1]: https://github.com/sebastianbergmann/php-invoker/compare/3.0.0...3.0.1
|
||||
[3.0.0]: https://github.com/sebastianbergmann/php-invoker/compare/2.0.0...3.0.0
|
29
vendor/phpunit/php-invoker/LICENSE
vendored
Normal file
29
vendor/phpunit/php-invoker/LICENSE
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2011-2024, Sebastian Bergmann
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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.
|
19
vendor/phpunit/php-invoker/README.md
vendored
Normal file
19
vendor/phpunit/php-invoker/README.md
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# phpunit/php-invoker
|
||||
|
||||
[](https://packagist.org/packages/phpunit/php-invoker)
|
||||
[](https://github.com/sebastianbergmann/php-invoker/actions)
|
||||
[](https://codecov.io/gh/sebastianbergmann/php-invoker)
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
```
|
||||
composer require phpunit/php-invoker
|
||||
```
|
||||
|
||||
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
|
||||
|
||||
```
|
||||
composer require --dev phpunit/php-invoker
|
||||
```
|
30
vendor/phpunit/php-invoker/SECURITY.md
vendored
Normal file
30
vendor/phpunit/php-invoker/SECURITY.md
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
# Security Policy
|
||||
|
||||
If you believe you have found a security vulnerability in the library that is developed in this repository, please report it to us through coordinated disclosure.
|
||||
|
||||
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
|
||||
|
||||
Instead, please email `sebastian@phpunit.de`.
|
||||
|
||||
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
|
||||
|
||||
* The type of issue
|
||||
* Full paths of source file(s) related to the manifestation of the issue
|
||||
* The location of the affected source code (tag/branch/commit or direct URL)
|
||||
* Any special configuration required to reproduce the issue
|
||||
* Step-by-step instructions to reproduce the issue
|
||||
* Proof-of-concept or exploit code (if possible)
|
||||
* Impact of the issue, including how an attacker might exploit the issue
|
||||
|
||||
This information will help us triage your report more quickly.
|
||||
|
||||
## Web Context
|
||||
|
||||
The library that is developed in this repository was either extracted from [PHPUnit](https://github.com/sebastianbergmann/phpunit) or developed specifically as a dependency for PHPUnit.
|
||||
|
||||
The library is developed with a focus on development environments and the command-line. No specific testing or hardening with regard to using the library in an HTTP or web context or with untrusted input data is performed. The library might also contain functionality that intentionally exposes internal application data for debugging purposes.
|
||||
|
||||
If the library is used in a web application, the application developer is responsible for filtering inputs or escaping outputs as necessary and for verifying that the used functionality is safe for use within the intended context.
|
||||
|
||||
Vulnerabilities specific to the use outside a development context will be fixed as applicable, provided that the fix does not have an averse effect on the primary use case for development purposes.
|
||||
|
55
vendor/phpunit/php-invoker/composer.json
vendored
Normal file
55
vendor/phpunit/php-invoker/composer.json
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "phpunit/php-invoker",
|
||||
"description": "Invoke callables with a timeout",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"process"
|
||||
],
|
||||
"homepage": "https://github.com/sebastianbergmann/php-invoker/",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
|
||||
"security": "https://github.com/sebastianbergmann/php-invoker/security/policy"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.2.0"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-pcntl": "*",
|
||||
"phpunit/phpunit": "^11.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/_fixture/"
|
||||
]
|
||||
},
|
||||
"suggest": {
|
||||
"ext-pcntl": "*"
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "5.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
65
vendor/phpunit/php-invoker/src/Invoker.php
vendored
Normal file
65
vendor/phpunit/php-invoker/src/Invoker.php
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of phpunit/php-invoker.
|
||||
*
|
||||
* (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 SebastianBergmann\Invoker;
|
||||
|
||||
use const SIGALRM;
|
||||
use function call_user_func_array;
|
||||
use function extension_loaded;
|
||||
use function function_exists;
|
||||
use function pcntl_alarm;
|
||||
use function pcntl_async_signals;
|
||||
use function pcntl_signal;
|
||||
use function sprintf;
|
||||
use Throwable;
|
||||
|
||||
final class Invoker
|
||||
{
|
||||
/**
|
||||
* @param array<mixed> $arguments
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function invoke(callable $callable, array $arguments, int $timeout): mixed
|
||||
{
|
||||
if (!$this->canInvokeWithTimeout()) {
|
||||
// @codeCoverageIgnoreStart
|
||||
throw new ProcessControlExtensionNotLoadedException;
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
pcntl_signal(
|
||||
SIGALRM,
|
||||
static function () use ($timeout): void
|
||||
{
|
||||
throw new TimeoutException(
|
||||
sprintf(
|
||||
'Execution aborted after %d second%s',
|
||||
$timeout,
|
||||
$timeout === 1 ? '' : 's',
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
pcntl_async_signals(true);
|
||||
pcntl_alarm($timeout);
|
||||
|
||||
try {
|
||||
return call_user_func_array($callable, $arguments);
|
||||
} finally {
|
||||
pcntl_alarm(0);
|
||||
}
|
||||
}
|
||||
|
||||
public function canInvokeWithTimeout(): bool
|
||||
{
|
||||
return extension_loaded('pcntl') && function_exists('pcntl_signal') && function_exists('pcntl_async_signals') && function_exists('pcntl_alarm');
|
||||
}
|
||||
}
|
16
vendor/phpunit/php-invoker/src/exceptions/Exception.php
vendored
Normal file
16
vendor/phpunit/php-invoker/src/exceptions/Exception.php
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of phpunit/php-invoker.
|
||||
*
|
||||
* (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 SebastianBergmann\Invoker;
|
||||
|
||||
use Throwable;
|
||||
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
}
|
41
vendor/phpunit/php-invoker/src/exceptions/ProcessControlExtensionNotLoadedException.php
vendored
Normal file
41
vendor/phpunit/php-invoker/src/exceptions/ProcessControlExtensionNotLoadedException.php
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of phpunit/php-invoker.
|
||||
*
|
||||
* (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 SebastianBergmann\Invoker;
|
||||
|
||||
use function extension_loaded;
|
||||
use function function_exists;
|
||||
use function implode;
|
||||
use RuntimeException;
|
||||
|
||||
final class ProcessControlExtensionNotLoadedException extends RuntimeException implements Exception
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$message = [];
|
||||
|
||||
if (!extension_loaded('pcntl')) {
|
||||
$message[] = 'The pcntl (process control) extension for PHP must be loaded.';
|
||||
}
|
||||
|
||||
if (!function_exists('pcntl_signal')) {
|
||||
$message[] = 'The pcntl_signal() function must not be disabled.';
|
||||
}
|
||||
|
||||
if (!function_exists('pcntl_async_signals')) {
|
||||
$message[] = 'The pcntl_async_signals() function must not be disabled.';
|
||||
}
|
||||
|
||||
if (!function_exists('pcntl_alarm')) {
|
||||
$message[] = 'The pcntl_alarm() function must not be disabled.';
|
||||
}
|
||||
|
||||
parent::__construct(implode(PHP_EOL, $message));
|
||||
}
|
||||
}
|
16
vendor/phpunit/php-invoker/src/exceptions/TimeoutException.php
vendored
Normal file
16
vendor/phpunit/php-invoker/src/exceptions/TimeoutException.php
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of phpunit/php-invoker.
|
||||
*
|
||||
* (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 SebastianBergmann\Invoker;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
final class TimeoutException extends RuntimeException implements Exception
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user