Работает обработка ссылок на таблицы с численностью
This commit is contained in:
68
vendor/sebastian/recursion-context/ChangeLog.md
vendored
Normal file
68
vendor/sebastian/recursion-context/ChangeLog.md
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
# ChangeLog
|
||||
|
||||
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
|
||||
|
||||
## [6.0.2] - 2024-07-03
|
||||
|
||||
### Changed
|
||||
|
||||
* This project now uses PHPStan instead of Psalm for static analysis
|
||||
|
||||
## [6.0.1] - 2024-06-17
|
||||
|
||||
### Changed
|
||||
|
||||
* [#30](https://github.com/sebastianbergmann/recursion-context/pull/30): Use more efficient `spl_object_id()` over `spl_object_hash()`
|
||||
|
||||
## [6.0.0] - 2024-02-02
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 8.1
|
||||
|
||||
## [5.0.0] - 2023-02-03
|
||||
|
||||
### Removed
|
||||
|
||||
* This component is no longer supported on PHP 7.3, PHP 7.4 and PHP 8.0
|
||||
|
||||
## [4.0.5] - 2023-02-03
|
||||
|
||||
### Fixed
|
||||
|
||||
* [#26](https://github.com/sebastianbergmann/recursion-context/pull/26): Don't clobber `null` values if `array_key_exists(PHP_INT_MAX, $array)`
|
||||
|
||||
## [4.0.4] - 2020-10-26
|
||||
|
||||
### Fixed
|
||||
|
||||
* `SebastianBergmann\RecursionContext\Exception` now correctly extends `\Throwable`
|
||||
|
||||
## [4.0.3] - 2020-09-28
|
||||
|
||||
### Changed
|
||||
|
||||
* [#21](https://github.com/sebastianbergmann/recursion-context/pull/21): Add type annotations for in/out parameters
|
||||
* Changed PHP version constraint in `composer.json` from `^7.3 || ^8.0` to `>=7.3`
|
||||
|
||||
## [4.0.2] - 2020-06-26
|
||||
|
||||
### Added
|
||||
|
||||
* This component is now supported on PHP 8
|
||||
|
||||
## [4.0.1] - 2020-06-15
|
||||
|
||||
### Changed
|
||||
|
||||
* Tests etc. are now ignored for archive exports
|
||||
|
||||
[6.0.2]: https://github.com/sebastianbergmann/recursion-context/compare/6.0.1...6.0.2
|
||||
[6.0.1]: https://github.com/sebastianbergmann/recursion-context/compare/6.0.0...6.0.1
|
||||
[6.0.0]: https://github.com/sebastianbergmann/recursion-context/compare/5.0...6.0.0
|
||||
[5.0.0]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.5...5.0.0
|
||||
[4.0.5]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.4...4.0.5
|
||||
[4.0.4]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.3...4.0.4
|
||||
[4.0.3]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.2...4.0.3
|
||||
[4.0.2]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.1...4.0.2
|
||||
[4.0.1]: https://github.com/sebastianbergmann/recursion-context/compare/4.0.0...4.0.1
|
29
vendor/sebastian/recursion-context/LICENSE
vendored
Normal file
29
vendor/sebastian/recursion-context/LICENSE
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2002-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/sebastian/recursion-context/README.md
vendored
Normal file
19
vendor/sebastian/recursion-context/README.md
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
[](https://packagist.org/packages/sebastian/recursion-context)
|
||||
[](https://github.com/sebastianbergmann/recursion-context/actions)
|
||||
[](https://codecov.io/gh/sebastianbergmann/recursion-context)
|
||||
|
||||
# sebastian/recursion-context
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
```
|
||||
composer require sebastian/recursion-context
|
||||
```
|
||||
|
||||
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 sebastian/recursion-context
|
||||
```
|
30
vendor/sebastian/recursion-context/SECURITY.md
vendored
Normal file
30
vendor/sebastian/recursion-context/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.
|
||||
|
48
vendor/sebastian/recursion-context/composer.json
vendored
Normal file
48
vendor/sebastian/recursion-context/composer.json
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "sebastian/recursion-context",
|
||||
"description": "Provides functionality to recursively process PHP variables",
|
||||
"homepage": "https://github.com/sebastianbergmann/recursion-context",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "Jeff Welch",
|
||||
"email": "whatthejeff@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Adam Harvey",
|
||||
"email": "aharvey@php.net"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
||||
"security": "https://github.com/sebastianbergmann/recursion-context/security/policy"
|
||||
},
|
||||
"prefer-stable": true,
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.2.0"
|
||||
},
|
||||
"optimize-autoloader": true,
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": ">=8.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^11.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "6.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
154
vendor/sebastian/recursion-context/src/Context.php
vendored
Normal file
154
vendor/sebastian/recursion-context/src/Context.php
vendored
Normal file
@ -0,0 +1,154 @@
|
||||
<?php declare(strict_types=1);
|
||||
/*
|
||||
* This file is part of sebastian/recursion-context.
|
||||
*
|
||||
* (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\RecursionContext;
|
||||
|
||||
use const PHP_INT_MAX;
|
||||
use const PHP_INT_MIN;
|
||||
use function array_key_exists;
|
||||
use function array_pop;
|
||||
use function array_slice;
|
||||
use function count;
|
||||
use function is_array;
|
||||
use function random_int;
|
||||
use function spl_object_id;
|
||||
use SplObjectStorage;
|
||||
|
||||
final class Context
|
||||
{
|
||||
/**
|
||||
* @var list<array<mixed>>
|
||||
*/
|
||||
private array $arrays = [];
|
||||
|
||||
/**
|
||||
* @var SplObjectStorage<object, null>
|
||||
*/
|
||||
private SplObjectStorage $objects;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->objects = new SplObjectStorage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->arrays as &$array) {
|
||||
if (is_array($array)) {
|
||||
array_pop($array);
|
||||
array_pop($array);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of object|array
|
||||
*
|
||||
* @param T $value
|
||||
*
|
||||
* @param-out T $value
|
||||
*/
|
||||
public function add(array|object &$value): false|int|string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $this->addArray($value);
|
||||
}
|
||||
|
||||
return $this->addObject($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T of object|array
|
||||
*
|
||||
* @param T $value
|
||||
*
|
||||
* @param-out T $value
|
||||
*/
|
||||
public function contains(array|object &$value): false|int|string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $this->containsArray($value);
|
||||
}
|
||||
|
||||
return $this->containsObject($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> $array
|
||||
*/
|
||||
private function addArray(array &$array): int
|
||||
{
|
||||
$key = $this->containsArray($array);
|
||||
|
||||
if ($key !== false) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
$key = count($this->arrays);
|
||||
$this->arrays[] = &$array;
|
||||
|
||||
if (!array_key_exists(PHP_INT_MAX, $array) && !array_key_exists(PHP_INT_MAX - 1, $array)) {
|
||||
$array[] = $key;
|
||||
$array[] = $this->objects;
|
||||
} else {
|
||||
/* Cover the improbable case, too.
|
||||
*
|
||||
* Note that array_slice() (used in containsArray()) will return the
|
||||
* last two values added, *not necessarily* the highest integer keys
|
||||
* in the array. Therefore, the order of these writes to $array is
|
||||
* important, but the actual keys used is not. */
|
||||
do {
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$key = random_int(PHP_INT_MIN, PHP_INT_MAX);
|
||||
} while (array_key_exists($key, $array));
|
||||
|
||||
$array[$key] = $key;
|
||||
|
||||
do {
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$key = random_int(PHP_INT_MIN, PHP_INT_MAX);
|
||||
} while (array_key_exists($key, $array));
|
||||
|
||||
$array[$key] = $this->objects;
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
private function addObject(object $object): int
|
||||
{
|
||||
if (!$this->objects->contains($object)) {
|
||||
$this->objects->attach($object);
|
||||
}
|
||||
|
||||
return spl_object_id($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> $array
|
||||
*/
|
||||
private function containsArray(array $array): false|int
|
||||
{
|
||||
$end = array_slice($array, -2);
|
||||
|
||||
return isset($end[1]) && $end[1] === $this->objects ? $end[0] : false;
|
||||
}
|
||||
|
||||
private function containsObject(object $value): false|int
|
||||
{
|
||||
if ($this->objects->contains($value)) {
|
||||
return spl_object_id($value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user