init
This commit is contained in:
44
backend/vendor/doctrine/collections/CONTRIBUTING.md
vendored
Normal file
44
backend/vendor/doctrine/collections/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# Contribute to Doctrine
|
||||
|
||||
Thank you for contributing to Doctrine!
|
||||
|
||||
Before we can merge your Pull-Request here are some guidelines that you need to follow.
|
||||
These guidelines exist not to annoy you, but to keep the code base clean,
|
||||
unified and future proof.
|
||||
|
||||
## Coding Standard
|
||||
|
||||
We use the [Doctrine Coding Standard](https://github.com/doctrine/coding-standard).
|
||||
|
||||
## Unit-Tests
|
||||
|
||||
Please try to add a test for your pull-request.
|
||||
|
||||
* If you want to contribute new functionality add unit- or functional tests
|
||||
depending on the scope of the feature.
|
||||
|
||||
You can run the unit-tests by calling ``vendor/bin/phpunit`` from the root of the project.
|
||||
It will run all the project tests.
|
||||
|
||||
In order to do that, you will need a fresh copy of doctrine/collections, and you
|
||||
will have to run a composer installation in the project:
|
||||
|
||||
```sh
|
||||
git clone git@github.com:doctrine/collections.git
|
||||
cd collections
|
||||
curl -sS https://getcomposer.org/installer | php --
|
||||
./composer.phar install
|
||||
```
|
||||
|
||||
## Github Actions
|
||||
|
||||
We automatically run your pull request through Github Actions against supported
|
||||
PHP versions. If you break the tests, we cannot merge your code, so please make
|
||||
sure that your code is working before opening up a Pull-Request.
|
||||
|
||||
## Getting merged
|
||||
|
||||
Please allow us time to review your pull requests. We will give our best to review
|
||||
everything as fast as possible, but cannot always live up to our own expectations.
|
||||
|
||||
Thank you very much again for your contribution!
|
||||
19
backend/vendor/doctrine/collections/LICENSE
vendored
Normal file
19
backend/vendor/doctrine/collections/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2013 Doctrine Project
|
||||
|
||||
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.
|
||||
6
backend/vendor/doctrine/collections/README.md
vendored
Normal file
6
backend/vendor/doctrine/collections/README.md
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
# Doctrine Collections
|
||||
|
||||
[](https://github.com/doctrine/collections/actions)
|
||||
[](https://codecov.io/gh/doctrine/collections/branch/2.0.x)
|
||||
|
||||
Collections Abstraction library
|
||||
151
backend/vendor/doctrine/collections/UPGRADE.md
vendored
Normal file
151
backend/vendor/doctrine/collections/UPGRADE.md
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
Note about upgrading: Doctrine uses static and runtime mechanisms to raise
|
||||
awareness about deprecated code.
|
||||
|
||||
- Use of `@deprecated` docblock that is detected by IDEs (like PHPStorm) or
|
||||
Static Analysis tools (like Psalm, phpstan)
|
||||
- Use of our low-overhead runtime deprecation API, details:
|
||||
https://github.com/doctrine/deprecations/
|
||||
|
||||
# Upgrade to 2.6
|
||||
|
||||
When extending `Doctrine\Common\Collections\AbstractLazyCollection`, the
|
||||
backing collection initialized in `doInitialize()` must implement
|
||||
`Doctrine\Common\Collections\Selectable`. Initializing with a collection that
|
||||
does not implement `Selectable` is deprecated and will throw an exception in 3.0.
|
||||
|
||||
Also, implementing `ReadableCollection` without implementing `Selectable`
|
||||
deprecated and will be an error in 3.0.
|
||||
|
||||
# Upgrade to 2.5
|
||||
|
||||
Extending the following classes is deprecated and will no longer be possible in 3.0:
|
||||
|
||||
- `Doctrine\Common\Collections\Criteria`
|
||||
- `Doctrine\Common\Collections\Expr\ClosureExpressionVisitor`
|
||||
- `Doctrine\Common\Collections\Expr\Comparison`
|
||||
- `Doctrine\Common\Collections\Expr\CompositeExpression`
|
||||
- `Doctrine\Common\Collections\Expr\Value`
|
||||
- `Doctrine\Common\Collections\ExpressionBuilder`
|
||||
|
||||
# Upgrade to 2.4
|
||||
|
||||
## Deprecated accessing fields through other means than raw field access when using the criteria filtering API (the `Doctrine\Common\Collections\Selectable` interface)
|
||||
|
||||
Starting with the next major version, the only way to access data when using the criteria filtering
|
||||
API is through direct (reflection-based) access at properties directly, also bypassing property hooks.
|
||||
This is to ensure consistency with how the ORM/ODM works. See https://github.com/doctrine/collections/pull/472 for
|
||||
the full motivation.
|
||||
|
||||
To opt-in to the new behaviour, pass `true` for the `$accessRawFieldValues` parameter when creating a `Criteria`
|
||||
object through either `Doctrine\Common\Collections\Criteria::create()` or when calling the `Doctrine\Common\Collections\Criteria` constructor.
|
||||
|
||||
Be aware that switching to reflection-based field access may prevent ORM or ODM proxy objects
|
||||
becoming initialized, since their triggers (like calling public methods) are bypassed. This might lead
|
||||
to `null` values being read from such objects, which may cause wrong filtering or sorting results.
|
||||
To avoid this issue, use native lazy objects added in PHP 8.4.
|
||||
See https://github.com/doctrine/collections/issues/487 for more details on when this may happen.
|
||||
|
||||
# Upgrade to 2.2
|
||||
|
||||
## Deprecated string representation of sort order
|
||||
|
||||
Criteria orderings direction is now represented by the
|
||||
`Doctrine\Common\Collection\Order` enum.
|
||||
|
||||
As a consequence:
|
||||
|
||||
- `Criteria::ASC` and `Criteria::DESC` are deprecated in favor of
|
||||
`Order::Ascending` and `Order::Descending`, respectively.
|
||||
- `Criteria::getOrderings()` is deprecated in favor of `Criteria::orderings()`,
|
||||
which returns `array<string, Order>`.
|
||||
- `Criteria::orderBy()` accepts `array<string, string|Order>`, but passing
|
||||
anything other than `array<string, Order>` is deprecated.
|
||||
|
||||
# Upgrade to 2.0
|
||||
|
||||
## BC breaking changes
|
||||
|
||||
Native parameter types were added. Native return types will be added in 3.0.x
|
||||
As a consequence, some signatures were changed and will have to be adjusted in sub-classes.
|
||||
|
||||
Note that in order to keep compatibility with both 1.x and 2.x versions,
|
||||
extending code would have to omit the added parameter types.
|
||||
This would only work in PHP 7.2+ which is the first version featuring
|
||||
[parameter widening](https://wiki.php.net/rfc/parameter-no-type-variance).
|
||||
It is also recommended to add return types according to the tables below
|
||||
|
||||
You can find a list of major changes to public API below.
|
||||
|
||||
### Doctrine\Common\Collections\Collection
|
||||
|
||||
| 1.0.x | 3.0.x |
|
||||
|---------------------------------:|:-------------------------------------------------|
|
||||
| `add($element)` | `add(mixed $element): void` |
|
||||
| `clear()` | `clear(): void` |
|
||||
| `contains($element)` | `contains(mixed $element): bool` |
|
||||
| `isEmpty()` | `isEmpty(): bool` |
|
||||
| `removeElement($element)` | `removeElement(mixed $element): bool` |
|
||||
| `containsKey($key)` | `containsKey(string\|int $key): bool` |
|
||||
| `get()` | `get(string\|int $key): mixed` |
|
||||
| `getKeys()` | `getKeys(): array` |
|
||||
| `getValues()` | `getValues(): array` |
|
||||
| `set($key, $value)` | `set(string\|int $key, $value): void` |
|
||||
| `toArray()` | `toArray(): array` |
|
||||
| `first()` | `first(): mixed` |
|
||||
| `last()` | `last(): mixed` |
|
||||
| `key()` | `key(): int\|string\|null` |
|
||||
| `current()` | `current(): mixed` |
|
||||
| `next()` | `next(): mixed` |
|
||||
| `exists(Closure $p)` | `exists(Closure $p): bool` |
|
||||
| `filter(Closure $p)` | `filter(Closure $p): self` |
|
||||
| `forAll(Closure $p)` | `forAll(Closure $p): bool` |
|
||||
| `map(Closure $func)` | `map(Closure $func): self` |
|
||||
| `partition(Closure $p)` | `partition(Closure $p): array` |
|
||||
| `indexOf($element)` | `indexOf(mixed $element): int\|string\|false` |
|
||||
| `slice($offset, $length = null)` | `slice(int $offset, ?int $length = null): array` |
|
||||
| `count()` | `count(): int` |
|
||||
| `getIterator()` | `getIterator(): \Traversable` |
|
||||
| `offsetSet($offset, $value)` | `offsetSet(mixed $offset, mixed $value): void` |
|
||||
| `offsetUnset($offset)` | `offsetUnset(mixed $offset): void` |
|
||||
| `offsetExists($offset)` | `offsetExists(mixed $offset): bool` |
|
||||
|
||||
### Doctrine\Common\Collections\AbstractLazyCollection
|
||||
|
||||
| 1.0.x | 3.0.x |
|
||||
|------------------:|:------------------------|
|
||||
| `isInitialized()` | `isInitialized(): bool` |
|
||||
| `initialize()` | `initialize(): void` |
|
||||
| `doInitialize()` | `doInitialize(): void` |
|
||||
|
||||
### Doctrine\Common\Collections\ArrayCollection
|
||||
|
||||
| 1.0.x | 3.0.x |
|
||||
|------------------------------:|:--------------------------------------|
|
||||
| `createFrom(array $elements)` | `createFrom(array $elements): static` |
|
||||
| `__toString()` | `__toString(): string` |
|
||||
|
||||
### Doctrine\Common\Collections\Criteria
|
||||
|
||||
| 1.0.x | 3.0.x |
|
||||
|------------------------------------------:|:--------------------------------------------|
|
||||
| `where(Expression $expression): self` | `where(Expression $expression): static` |
|
||||
| `andWhere(Expression $expression): self` | `andWhere(Expression $expression): static` |
|
||||
| `orWhere(Expression $expression): self` | `orWhere(Expression $expression): static` |
|
||||
| `orderBy(array $orderings): self` | `orderBy(array $orderings): static` |
|
||||
| `setFirstResult(?int $firstResult): self` | `setFirstResult(?int $firstResult): static` |
|
||||
| `setMaxResult(?int $maxResults): self` | `setMaxResults(?int $maxResults): static` |
|
||||
|
||||
### Doctrine\Common\Collections\Selectable
|
||||
|
||||
| 1.0.x | 3.0.x |
|
||||
|-------------------------------:|:-------------------------------------------|
|
||||
| `matching(Criteria $criteria)` | `matching(Criteria $criteria): Collection` |
|
||||
|
||||
# Upgrade to 1.7
|
||||
|
||||
## Deprecated null first result
|
||||
|
||||
Passing null as `$firstResult` to
|
||||
`Doctrine\Common\Collections\Criteria::__construct()` and to
|
||||
`Doctrine\Common\Collections\Criteria::setFirstResult()` is deprecated.
|
||||
Use `0` instead.
|
||||
63
backend/vendor/doctrine/collections/composer.json
vendored
Normal file
63
backend/vendor/doctrine/collections/composer.json
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "doctrine/collections",
|
||||
"description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"php",
|
||||
"collections",
|
||||
"array",
|
||||
"iterators"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Guilherme Blanco",
|
||||
"email": "guilhermeblanco@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Roman Borschel",
|
||||
"email": "roman@code-factory.org"
|
||||
},
|
||||
{
|
||||
"name": "Benjamin Eberlei",
|
||||
"email": "kontakt@beberlei.de"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Wage",
|
||||
"email": "jonwage@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Johannes Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/collections.html",
|
||||
"require": {
|
||||
"php": "^8.1",
|
||||
"doctrine/deprecations": "^1",
|
||||
"symfony/polyfill-php84": "^1.30"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-json": "*",
|
||||
"doctrine/coding-standard": "^14",
|
||||
"phpstan/phpstan": "^2.1.30",
|
||||
"phpstan/phpstan-phpunit": "^2.0.7",
|
||||
"phpunit/phpunit": "^10.5.58 || ^11.5.42 || ^12.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Collections\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Tests\\Common\\Collections\\": "tests"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"composer/package-versions-deprecated": true,
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
5
backend/vendor/doctrine/collections/docs/composer.json
vendored
Normal file
5
backend/vendor/doctrine/collections/docs/composer.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"doctrine/docs-builder": "^1.0"
|
||||
}
|
||||
}
|
||||
26
backend/vendor/doctrine/collections/docs/en/derived-collections.rst
vendored
Normal file
26
backend/vendor/doctrine/collections/docs/en/derived-collections.rst
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Derived Collections
|
||||
===================
|
||||
|
||||
You can create custom collection classes by extending the
|
||||
``Doctrine\Common\Collections\ArrayCollection`` class. If the
|
||||
``__construct`` semantics are different from the default ``ArrayCollection``
|
||||
you can override the ``createFrom`` method:
|
||||
|
||||
.. code-block:: php
|
||||
final class DerivedArrayCollection extends ArrayCollection
|
||||
{
|
||||
/** @var \stdClass */
|
||||
private $foo;
|
||||
|
||||
public function __construct(\stdClass $foo, array $elements = [])
|
||||
{
|
||||
$this->foo = $foo;
|
||||
|
||||
parent::__construct($elements);
|
||||
}
|
||||
|
||||
protected function createFrom(array $elements) : self
|
||||
{
|
||||
return new static($this->foo, $elements);
|
||||
}
|
||||
}
|
||||
195
backend/vendor/doctrine/collections/docs/en/expression-builder.rst
vendored
Normal file
195
backend/vendor/doctrine/collections/docs/en/expression-builder.rst
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
Expression Builder
|
||||
==================
|
||||
|
||||
The Expression Builder is a convenient fluent interface for
|
||||
building expressions to be used with the ``Doctrine\Common\Collections\Criteria``
|
||||
class:
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->where($expressionBuilder->eq('name', 'jwage'));
|
||||
$criteria->orWhere($expressionBuilder->eq('name', 'romanb'));
|
||||
|
||||
$collection->matching($criteria);
|
||||
|
||||
The ``ExpressionBuilder`` has the following API:
|
||||
|
||||
andX
|
||||
----
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->andX(
|
||||
$expressionBuilder->eq('foo', 1),
|
||||
$expressionBuilder->eq('bar', 1)
|
||||
);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
orX
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->orX(
|
||||
$expressionBuilder->eq('foo', 1),
|
||||
$expressionBuilder->eq('bar', 1)
|
||||
);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
not
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->not(
|
||||
$expressionBuilder->eq('foo', 1)
|
||||
);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
eq
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->eq('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
gt
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->gt('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
lt
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->lt('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
gte
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->gte('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
lte
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->lte('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
neq
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->neq('foo', 1);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
isNull
|
||||
------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->isNull('foo');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
isNotNull
|
||||
---------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->isNotNull('foo');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
in
|
||||
---
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->in('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
notIn
|
||||
-----
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->notIn('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
contains
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->contains('foo', 'value1');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
memberOf
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->memberOf('foo', ['value1', 'value2']);
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
startsWith
|
||||
----------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->startsWith('foo', 'hello');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
|
||||
endsWith
|
||||
--------
|
||||
|
||||
.. code-block:: php
|
||||
$expressionBuilder = Criteria::expr();
|
||||
|
||||
$expression = $expressionBuilder->endsWith('foo', 'world');
|
||||
|
||||
$collection->matching(new Criteria($expression));
|
||||
117
backend/vendor/doctrine/collections/docs/en/expressions.rst
vendored
Normal file
117
backend/vendor/doctrine/collections/docs/en/expressions.rst
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
Expressions
|
||||
===========
|
||||
|
||||
The ``Doctrine\Common\Collections\Expr\Comparison`` class
|
||||
can be used to create comparison expressions to be used with the
|
||||
``Doctrine\Common\Collections\Criteria`` class. It has the
|
||||
following operator constants:
|
||||
|
||||
- ``Comparison::EQ``
|
||||
- ``Comparison::NEQ``
|
||||
- ``Comparison::LT``
|
||||
- ``Comparison::LTE``
|
||||
- ``Comparison::GT``
|
||||
- ``Comparison::GTE``
|
||||
- ``Comparison::IS``
|
||||
- ``Comparison::IN``
|
||||
- ``Comparison::NIN``
|
||||
- ``Comparison::CONTAINS``
|
||||
- ``Comparison::MEMBER_OF``
|
||||
- ``Comparison::STARTS_WITH``
|
||||
- ``Comparison::ENDS_WITH``
|
||||
|
||||
The ``Doctrine\Common\Collections\Expr\CompositeExpression`` class
|
||||
can be used to create composite expressions to be used with the
|
||||
``Doctrine\Common\Collections\Criteria`` class. It has the
|
||||
following operator constants:
|
||||
|
||||
- ``CompositeExpression::TYPE_AND``
|
||||
- ``CompositeExpression::TYPE_OR``
|
||||
- ``CompositeExpression::TYPE_NOT``
|
||||
|
||||
When using the ``TYPE_OR`` and ``TYPE_AND`` operators the
|
||||
``CompositeExpression`` accepts multiple expressions as parameter
|
||||
but only one expression can be provided when using the ``NOT`` operator.
|
||||
|
||||
The ``Doctrine\Common\Collections\Criteria`` class has the following
|
||||
API to be used with expressions:
|
||||
|
||||
where
|
||||
-----
|
||||
|
||||
Sets the where expression to evaluate when this Criteria is searched for.
|
||||
|
||||
.. code-block:: php
|
||||
$expr = new Comparison('key', Comparison::EQ, 'value');
|
||||
|
||||
$criteria->where($expr);
|
||||
|
||||
andWhere
|
||||
--------
|
||||
|
||||
Appends the where expression to evaluate when this Criteria is searched for
|
||||
using an AND with previous expression.
|
||||
|
||||
.. code-block:: php
|
||||
$expr = new Comparison('key', Comparison::EQ, 'value');
|
||||
|
||||
$criteria->andWhere($expr);
|
||||
|
||||
orWhere
|
||||
-------
|
||||
|
||||
Appends the where expression to evaluate when this Criteria is searched for
|
||||
using an OR with previous expression.
|
||||
|
||||
.. code-block:: php
|
||||
$expr1 = new Comparison('key', Comparison::EQ, 'value1');
|
||||
$expr2 = new Comparison('key', Comparison::EQ, 'value2');
|
||||
|
||||
$criteria->where($expr1);
|
||||
$criteria->orWhere($expr2);
|
||||
|
||||
orderBy
|
||||
-------
|
||||
|
||||
Sets the ordering of the result of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\Common\Collections\Order;
|
||||
|
||||
$criteria->orderBy(['name' => Order::Ascending]);
|
||||
|
||||
setFirstResult
|
||||
--------------
|
||||
|
||||
Set the number of first result that this Criteria should return.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setFirstResult(0);
|
||||
|
||||
getFirstResult
|
||||
--------------
|
||||
|
||||
Gets the current first result option of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setFirstResult(10);
|
||||
|
||||
echo $criteria->getFirstResult(); // 10
|
||||
|
||||
setMaxResults
|
||||
-------------
|
||||
|
||||
Sets the max results that this Criteria should return.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setMaxResults(20);
|
||||
|
||||
getMaxResults
|
||||
-------------
|
||||
|
||||
Gets the current max results option of this Criteria.
|
||||
|
||||
.. code-block:: php
|
||||
$criteria->setMaxResults(20);
|
||||
|
||||
echo $criteria->getMaxResults(); // 20
|
||||
386
backend/vendor/doctrine/collections/docs/en/index.rst
vendored
Normal file
386
backend/vendor/doctrine/collections/docs/en/index.rst
vendored
Normal file
@@ -0,0 +1,386 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
Doctrine Collections is a library that contains classes for working with
|
||||
arrays of data. Here is an example using the simple
|
||||
``Doctrine\Common\Collections\ArrayCollection`` class:
|
||||
|
||||
.. code-block:: php
|
||||
<?php
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$filteredCollection = $collection->filter(static fn ($element): bool => $element > 1); // [2, 3]
|
||||
|
||||
Collection Methods
|
||||
------------------
|
||||
|
||||
Doctrine Collections provides an interface named ``Doctrine\Common\Collections\Collection``
|
||||
that resembles the nature of a regular PHP array. That is,
|
||||
it is essentially an **ordered map** that can also be used
|
||||
like a list.
|
||||
|
||||
A Collection has an internal iterator just like a PHP array. In addition,
|
||||
a Collection can be iterated with external iterators, which is preferable.
|
||||
To use an external iterator simply use the foreach language construct to
|
||||
iterate over the collection, which calls ``getIterator()`` internally, or
|
||||
explicitly retrieve an iterator though ``getIterator()`` which can then be
|
||||
used to iterate over the collection. You can not rely on the internal iterator
|
||||
of the collection being at a certain position unless you explicitly positioned it before.
|
||||
|
||||
Methods that do not alter the collection or have template types
|
||||
appearing in invariant or contravariant positions are not directly
|
||||
defined in ``Doctrine\Common\Collections\Collection``, but are inherited
|
||||
from the ``Doctrine\Common\Collections\ReadableCollection`` interface.
|
||||
|
||||
The methods available on the interface are:
|
||||
|
||||
add
|
||||
^^^
|
||||
|
||||
Adds an element at the end of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection->add('test');
|
||||
|
||||
clear
|
||||
^^^^^
|
||||
|
||||
Clears the collection, removing all elements.
|
||||
|
||||
.. code-block:: php
|
||||
$collection->clear();
|
||||
|
||||
contains
|
||||
^^^^^^^^
|
||||
|
||||
Checks whether an element is contained in the collection. This is an O(n) operation, where n is the size of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['test']);
|
||||
|
||||
$contains = $collection->contains('test'); // true
|
||||
|
||||
containsKey
|
||||
^^^^^^^^^^^
|
||||
|
||||
Checks whether the collection contains an element with the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['test' => true]);
|
||||
|
||||
$contains = $collection->containsKey('test'); // true
|
||||
|
||||
current
|
||||
^^^^^^^
|
||||
|
||||
Gets the element of the collection at the current iterator position.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$current = $collection->current(); // first
|
||||
|
||||
get
|
||||
^^^
|
||||
|
||||
Gets the element at the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection([
|
||||
'key' => 'value',
|
||||
]);
|
||||
|
||||
$value = $collection->get('key'); // value
|
||||
|
||||
getKeys
|
||||
^^^^^^^
|
||||
|
||||
Gets all keys/indices of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['a', 'b', 'c']);
|
||||
|
||||
$keys = $collection->getKeys(); // [0, 1, 2]
|
||||
|
||||
getValues
|
||||
^^^^^^^^^
|
||||
|
||||
Gets all values of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection([
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
'key3' => 'value3',
|
||||
]);
|
||||
|
||||
$values = $collection->getValues(); // ['value1', 'value2', 'value3']
|
||||
|
||||
isEmpty
|
||||
^^^^^^^
|
||||
|
||||
Checks whether the collection is empty (contains no elements).
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['a', 'b', 'c']);
|
||||
|
||||
$isEmpty = $collection->isEmpty(); // false
|
||||
|
||||
first
|
||||
^^^^^
|
||||
|
||||
Sets the internal iterator to the first element in the collection and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$first = $collection->first(); // first
|
||||
|
||||
exists
|
||||
^^^^^^
|
||||
|
||||
Tests for the existence of an element that satisfies the given predicate.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection(['first', 'second', 'third']);
|
||||
|
||||
$exists = $collection->exists(static fn ($key, $value): bool => $value === 'first'); // true
|
||||
|
||||
findFirst
|
||||
^^^^^^^^^
|
||||
|
||||
Returns the first element of this collection that satisfies the given predicate.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new Collection([1, 2, 3, 2, 1]);
|
||||
|
||||
$one = $collection->findFirst(static fn (int $key, int $value): bool => $value > 2 && $key > 1); // 3
|
||||
|
||||
filter
|
||||
^^^^^^
|
||||
|
||||
Returns all the elements of this collection for which your callback function returns `true`.
|
||||
The order and keys of the elements are preserved.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$filteredCollection = $collection->filter(static fn ($element): bool => $element > 1); // [2, 3]
|
||||
|
||||
forAll
|
||||
^^^^^^
|
||||
|
||||
Tests whether the given predicate holds for all elements of this collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$forAll = $collection->forAll(static fn ($key, $value): bool => $value > 1); // false
|
||||
|
||||
indexOf
|
||||
^^^^^^^
|
||||
|
||||
Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$indexOf = $collection->indexOf(3); // 2
|
||||
|
||||
key
|
||||
^^^
|
||||
|
||||
Gets the key/index of the element at the current iterator position.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->next();
|
||||
|
||||
$key = $collection->key(); // 1
|
||||
|
||||
last
|
||||
^^^^
|
||||
|
||||
Sets the internal iterator to the last element in the collection and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$last = $collection->last(); // 3
|
||||
|
||||
map
|
||||
^^^
|
||||
|
||||
Applies the given function to each element in the collection and returns a new collection with the elements returned by the function.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$mappedCollection = $collection->map(static fn (int $value): int => $value + 1); // [2, 3, 4]
|
||||
|
||||
reduce
|
||||
^^^^^^
|
||||
|
||||
Applies iteratively the given function to each element in the collection, so as to reduce the collection to a single value.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$reduce = $collection->reduce(static fn (int $accumulator, int $value): int => $accumulator + $value, 0); // 6
|
||||
|
||||
next
|
||||
^^^^
|
||||
|
||||
Moves the internal iterator position to the next element and returns this element.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$next = $collection->next(); // 2
|
||||
|
||||
partition
|
||||
^^^^^^^^^
|
||||
|
||||
Partitions this collection in two collections according to a predicate. Keys are preserved in the resulting collections.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$mappedCollection = $collection->partition(static fn ($key, $value): bool => $value > 1); // [[2, 3], [1]]
|
||||
|
||||
remove
|
||||
^^^^^^
|
||||
|
||||
Removes the element at the specified index from the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->remove(0); // [2, 3]
|
||||
|
||||
removeElement
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Removes the specified element from the collection, if it is found.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
|
||||
$collection->removeElement(3); // [1, 2]
|
||||
|
||||
set
|
||||
^^^
|
||||
|
||||
Sets an element in the collection at the specified key/index.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection();
|
||||
|
||||
$collection->set('name', 'jwage');
|
||||
|
||||
slice
|
||||
^^^^^
|
||||
|
||||
Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
|
||||
|
||||
$slice = $collection->slice(1, 2); // [1, 2]
|
||||
|
||||
toArray
|
||||
^^^^^^^
|
||||
|
||||
Gets a native PHP array representation of the collection.
|
||||
|
||||
.. code-block:: php
|
||||
$collection = new ArrayCollection([0, 1, 2, 3, 4, 5]);
|
||||
|
||||
$array = $collection->toArray(); // [0, 1, 2, 3, 4, 5]
|
||||
|
||||
Selectable Methods
|
||||
------------------
|
||||
|
||||
Some Doctrine Collections, like ``Doctrine\Common\Collections\ArrayCollection``,
|
||||
implement an interface named ``Doctrine\Common\Collections\Selectable``
|
||||
that offers the usage of a powerful expressions API, where conditions
|
||||
can be applied to a collection to get a result with matching elements
|
||||
only.
|
||||
|
||||
matching
|
||||
^^^^^^^^
|
||||
|
||||
Selects all elements from a selectable that match the expression and
|
||||
returns a new collection containing these elements and preserved keys.
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
|
||||
$collection = new ArrayCollection([
|
||||
'wage' => [
|
||||
'name' => 'jwage',
|
||||
],
|
||||
'roman' => [
|
||||
'name' => 'romanb',
|
||||
],
|
||||
]);
|
||||
|
||||
$expr = new Comparison('name', '=', 'jwage');
|
||||
|
||||
$criteria = new Criteria();
|
||||
|
||||
$criteria->where($expr);
|
||||
|
||||
$matchingCollection = $collection->matching($criteria); // [ 'wage' => [ 'name' => 'jwage' ]]
|
||||
|
||||
You can read more about expressions :ref:`here <expressions>`.
|
||||
|
||||
.. note::
|
||||
|
||||
Currently, expressions use strict comparison for the ``EQ`` (equal) and ``NEQ`` (not equal)
|
||||
checks. That makes them behave more naturally as long as only scalar values are involved.
|
||||
For example, ``'04'`` and ``4`` are *not* equal.
|
||||
|
||||
However, this can lead to surprising results when working with objects, especially objects
|
||||
representing values. ``DateTime`` and ``DateTimeImmutable`` are two widespread examples for
|
||||
objects that would typically rather be compared by their value than by identity.
|
||||
|
||||
Comparative operators like ``GT`` or ``LTE`` as well as ``IN`` and ``NIN`` do
|
||||
not exhibit this behavior.
|
||||
|
||||
Also, multi-dimensional sorting based on non-scalar values will only consider the
|
||||
next sort criteria for *identical* matches, which may not give the expected results
|
||||
when objects come into play. Keep this in mind, for example, when sorting by fields that
|
||||
contain ``DateTime`` or ``DateTimeImmutable`` objects.
|
||||
|
||||
.. note::
|
||||
|
||||
For collections that contain objects, the field name given to ``Comparison`` will
|
||||
lead to various access methods being tried in sequence. This behavior is deprecated
|
||||
as of v2.4.0. Set the ``$accessRawFieldValues`` parameter in the ``Criteria`` constructor
|
||||
to ``true`` to opt-in to the new behaviour of using direct (reflection-based) field access only.
|
||||
This will be the only option in the next major version.
|
||||
|
||||
Unless you opt in, refer to the ``ClosureExpressionVisitor::getObjectFieldValue()`` method
|
||||
for the exact order of accessors tried. Roughly speaking, for a field named ``field``,
|
||||
the following things will be tried in order:
|
||||
|
||||
1. ``getField()``, ``isField()`` and ``field()`` as getter methods
|
||||
2. When the object implements a ``__call`` magic method, invoke it
|
||||
by calling ``getField()``
|
||||
3. When the object implements ``ArrayAccess``, use that to access the
|
||||
``field`` offset
|
||||
4. When the object contains a ``::$field`` public property that is not
|
||||
``null``, access it directly
|
||||
5. Convert snake-case field names to camel case and retry the ``get``, ``is``
|
||||
and prefixless accessor methods
|
||||
6. Direct access to ``::$field``, which must be a public property, as a
|
||||
last resort.
|
||||
26
backend/vendor/doctrine/collections/docs/en/lazy-collections.rst
vendored
Normal file
26
backend/vendor/doctrine/collections/docs/en/lazy-collections.rst
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
Lazy Collections
|
||||
================
|
||||
|
||||
To create a lazy collection you can extend the
|
||||
``Doctrine\Common\Collections\AbstractLazyCollection`` class
|
||||
and define the ``doInitialize`` method. Here is an example where
|
||||
we lazily query the database for a collection of user records:
|
||||
|
||||
.. code-block:: php
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class UsersLazyCollection extends AbstractLazyCollection
|
||||
{
|
||||
/** @var Connection */
|
||||
private $connection;
|
||||
|
||||
public function __construct(Connection $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
protected function doInitialize() : void
|
||||
{
|
||||
$this->collection = $this->connection->fetchAll('SELECT * FROM users');
|
||||
}
|
||||
}
|
||||
29
backend/vendor/doctrine/collections/docs/en/serialization.rst
vendored
Normal file
29
backend/vendor/doctrine/collections/docs/en/serialization.rst
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
Serialization
|
||||
=============
|
||||
|
||||
Using (un-)serialize() on a collection is not a supported use-case
|
||||
and may break when changes on the collection's internals happen in the future.
|
||||
If a collection needs to be serialized, use ``toArray()`` and reconstruct
|
||||
the collection manually.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$collection = new ArrayCollection([1, 2, 3]);
|
||||
$serialized = serialize($collection->toArray());
|
||||
|
||||
A reconstruction is also necessary when the collection contains objects with
|
||||
infinite recursion of dependencies like in this ``json_serialize()`` example:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$foo = new Foo();
|
||||
$bar = new Bar();
|
||||
|
||||
$foo->setBar($bar);
|
||||
$bar->setFoo($foo);
|
||||
|
||||
$collection = new ArrayCollection([$foo]);
|
||||
$json = json_serialize($collection->toArray()); // recursion detected
|
||||
|
||||
Serializer libraries can be used to create the serialization-output to prevent
|
||||
errors.
|
||||
11
backend/vendor/doctrine/collections/docs/en/sidebar.rst
vendored
Normal file
11
backend/vendor/doctrine/collections/docs/en/sidebar.rst
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
:orphan:
|
||||
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
|
||||
index
|
||||
expressions
|
||||
expression-builder
|
||||
derived-collections
|
||||
lazy-collections
|
||||
serialization
|
||||
442
backend/vendor/doctrine/collections/src/AbstractLazyCollection.php
vendored
Normal file
442
backend/vendor/doctrine/collections/src/AbstractLazyCollection.php
vendored
Normal file
@@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use LogicException;
|
||||
use ReturnTypeWillChange;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Lazy collection that is backed by a concrete collection
|
||||
*
|
||||
* @phpstan-template TKey of array-key
|
||||
* @phpstan-template T
|
||||
* @template-implements Collection<TKey,T>
|
||||
* @template-implements Selectable<TKey,T>
|
||||
*/
|
||||
abstract class AbstractLazyCollection implements Collection, Selectable
|
||||
{
|
||||
/**
|
||||
* The backed collection to use
|
||||
*
|
||||
* @phpstan-var Collection<TKey,T>|null
|
||||
* @var Collection<mixed>|null
|
||||
*/
|
||||
protected Collection|null $collection;
|
||||
|
||||
protected bool $initialized = false;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function add(mixed $element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
$this->collection->add($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function contains(mixed $element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->contains($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove(string|int $key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->remove($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function removeElement(mixed $element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->removeElement($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function containsKey(string|int $key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->containsKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get(string|int $key)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKeys()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set(string|int $key, mixed $value)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->last();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->key();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->current();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->next();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function exists(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->exists($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findFirst(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->findFirst($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function filter(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->filter($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function forAll(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->forAll($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function map(Closure $func)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->map($func);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function reduce(Closure $func, mixed $initial = null)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->reduce($func, $initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function partition(Closure $p)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->partition($p);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @template TMaybeContained
|
||||
*/
|
||||
public function indexOf(mixed $element)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->indexOf($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function slice(int $offset, int|null $length = null)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->slice($offset, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return Traversable<int|string, mixed>
|
||||
* @phpstan-return Traversable<TKey,T>
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetExists(mixed $offset)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->offsetExists($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet(mixed $offset)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
return $this->collection->offsetGet($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @param TKey|null $offset
|
||||
* @param T $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet(mixed $offset, mixed $value)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->offsetSet($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetUnset(mixed $offset)
|
||||
{
|
||||
$this->initialize();
|
||||
$this->collection->offsetUnset($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the lazy collection already initialized?
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @phpstan-assert-if-true Collection<TKey,T> $this->collection
|
||||
*/
|
||||
public function isInitialized()
|
||||
{
|
||||
return $this->initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the collection
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @phpstan-assert Collection<TKey,T> $this->collection
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
if ($this->initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->doInitialize();
|
||||
$this->initialized = true;
|
||||
|
||||
if ($this->collection === null) {
|
||||
throw new LogicException('You must initialize the collection property in the doInitialize() method.');
|
||||
}
|
||||
|
||||
if ($this->collection instanceof Selectable) {
|
||||
return;
|
||||
}
|
||||
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/518',
|
||||
'Initializing %s with a collection that does not implement %s is deprecated and will throw an exception in 3.0.',
|
||||
self::class,
|
||||
Selectable::class,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Do the initialization logic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function doInitialize();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function matching(Criteria $criteria)
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
if (! $this->collection instanceof Selectable) {
|
||||
throw new LogicException('The backed collection must implement Selectable to use matching().');
|
||||
}
|
||||
|
||||
return $this->collection->matching($criteria);
|
||||
}
|
||||
}
|
||||
485
backend/vendor/doctrine/collections/src/ArrayCollection.php
vendored
Normal file
485
backend/vendor/doctrine/collections/src/ArrayCollection.php
vendored
Normal file
@@ -0,0 +1,485 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use ArrayIterator;
|
||||
use Closure;
|
||||
use Doctrine\Common\Collections\Expr\ClosureExpressionVisitor;
|
||||
use ReturnTypeWillChange;
|
||||
use Stringable;
|
||||
use Traversable;
|
||||
|
||||
use function array_all;
|
||||
use function array_any;
|
||||
use function array_filter;
|
||||
use function array_find;
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_reduce;
|
||||
use function array_reverse;
|
||||
use function array_search;
|
||||
use function array_slice;
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function current;
|
||||
use function end;
|
||||
use function in_array;
|
||||
use function key;
|
||||
use function next;
|
||||
use function reset;
|
||||
use function spl_object_hash;
|
||||
use function uasort;
|
||||
|
||||
use const ARRAY_FILTER_USE_BOTH;
|
||||
|
||||
/**
|
||||
* An ArrayCollection is a Collection implementation that wraps a regular PHP array.
|
||||
*
|
||||
* Warning: Using (un-)serialize() on a collection is not a supported use-case
|
||||
* and may break when we change the internals in the future. If you need to
|
||||
* serialize a collection use {@link toArray()} and reconstruct the collection
|
||||
* manually.
|
||||
*
|
||||
* @phpstan-template TKey of array-key
|
||||
* @phpstan-template T
|
||||
* @template-implements Collection<TKey,T>
|
||||
* @template-implements Selectable<TKey,T>
|
||||
* @phpstan-consistent-constructor
|
||||
*/
|
||||
class ArrayCollection implements Collection, Selectable, Stringable
|
||||
{
|
||||
/**
|
||||
* An array containing the entries of this collection.
|
||||
*
|
||||
* @phpstan-var array<TKey,T>
|
||||
* @var mixed[]
|
||||
*/
|
||||
private array $elements = [];
|
||||
|
||||
/**
|
||||
* Initializes a new ArrayCollection.
|
||||
*
|
||||
* @phpstan-param array<TKey,T> $elements
|
||||
*/
|
||||
public function __construct(array $elements = [])
|
||||
{
|
||||
$this->elements = $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return $this->elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
return reset($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance from the specified elements.
|
||||
*
|
||||
* This method is provided for derived classes to specify how a new
|
||||
* instance should be created when constructor semantics have changed.
|
||||
*
|
||||
* @param array $elements Elements.
|
||||
* @phpstan-param array<K,V> $elements
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<K,V>
|
||||
*
|
||||
* @phpstan-template K of array-key
|
||||
* @phpstan-template V
|
||||
*/
|
||||
protected function createFrom(array $elements)
|
||||
{
|
||||
return new static($elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function last()
|
||||
{
|
||||
return end($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return key($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
return next($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return current($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function remove(string|int $key)
|
||||
{
|
||||
if (! isset($this->elements[$key]) && ! array_key_exists($key, $this->elements)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$removed = $this->elements[$key];
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return $removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function removeElement(mixed $element)
|
||||
{
|
||||
$key = array_search($element, $this->elements, true);
|
||||
|
||||
if ($key === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unset($this->elements[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetExists(mixed $offset)
|
||||
{
|
||||
return $this->containsKey($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet(mixed $offset)
|
||||
{
|
||||
return $this->get($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* @param TKey|null $offset
|
||||
* @param T $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetSet(mixed $offset, mixed $value)
|
||||
{
|
||||
if ($offset === null) {
|
||||
$this->add($value);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @phpstan-var TKey $offset */
|
||||
$this->set($offset, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by interface ArrayAccess.
|
||||
*
|
||||
* @param TKey $offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetUnset(mixed $offset)
|
||||
{
|
||||
$this->remove($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function containsKey(string|int $key)
|
||||
{
|
||||
return isset($this->elements[$key]) || array_key_exists($key, $this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function contains(mixed $element)
|
||||
{
|
||||
return in_array($element, $this->elements, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function exists(Closure $p)
|
||||
{
|
||||
return array_any(
|
||||
$this->elements,
|
||||
static fn (mixed $element, mixed $key): bool => (bool) $p($key, $element),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param TMaybeContained $element
|
||||
*
|
||||
* @return int|string|false
|
||||
* @phpstan-return (TMaybeContained is T ? TKey|false : false)
|
||||
*
|
||||
* @template TMaybeContained
|
||||
*/
|
||||
public function indexOf($element)
|
||||
{
|
||||
return array_search($element, $this->elements, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function get(string|int $key)
|
||||
{
|
||||
return $this->elements[$key] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getKeys()
|
||||
{
|
||||
return array_keys($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getValues()
|
||||
{
|
||||
return array_values($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return int<0, max>
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function count()
|
||||
{
|
||||
return count($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set(string|int $key, mixed $value)
|
||||
{
|
||||
$this->elements[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* This breaks assumptions about the template type, but it would
|
||||
* be a backwards-incompatible change to remove this method
|
||||
*/
|
||||
public function add(mixed $element)
|
||||
{
|
||||
$this->elements[] = $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function isEmpty()
|
||||
{
|
||||
return empty($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return Traversable<int|string, mixed>
|
||||
* @phpstan-return Traversable<TKey, T>
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function getIterator()
|
||||
{
|
||||
return new ArrayIterator($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param Closure(T):U $func
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<TKey, U>
|
||||
*
|
||||
* @phpstan-template U
|
||||
*/
|
||||
public function map(Closure $func)
|
||||
{
|
||||
return $this->createFrom(array_map($func, $this->elements));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function reduce(Closure $func, $initial = null)
|
||||
{
|
||||
return array_reduce($this->elements, $func, $initial);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param Closure(T, TKey):bool $p
|
||||
*
|
||||
* @return static
|
||||
* @phpstan-return static<TKey,T>
|
||||
*/
|
||||
public function filter(Closure $p)
|
||||
{
|
||||
return $this->createFrom(array_filter($this->elements, $p, ARRAY_FILTER_USE_BOTH));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function findFirst(Closure $p)
|
||||
{
|
||||
return array_find(
|
||||
$this->elements,
|
||||
static fn (mixed $element, mixed $key): bool => (bool) $p($key, $element),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function forAll(Closure $p)
|
||||
{
|
||||
return array_all(
|
||||
$this->elements,
|
||||
static fn (mixed $element, mixed $key): bool => (bool) $p($key, $element),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function partition(Closure $p)
|
||||
{
|
||||
$matches = $noMatches = [];
|
||||
|
||||
foreach ($this->elements as $key => $element) {
|
||||
if ($p($key, $element)) {
|
||||
$matches[$key] = $element;
|
||||
} else {
|
||||
$noMatches[$key] = $element;
|
||||
}
|
||||
}
|
||||
|
||||
return [$this->createFrom($matches), $this->createFrom($noMatches)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object.
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function __toString()
|
||||
{
|
||||
return self::class . '@' . spl_object_hash($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->elements = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function slice(int $offset, int|null $length = null)
|
||||
{
|
||||
return array_slice($this->elements, $offset, $length, true);
|
||||
}
|
||||
|
||||
/** @phpstan-return Collection<TKey, T>&Selectable<TKey,T> */
|
||||
public function matching(Criteria $criteria)
|
||||
{
|
||||
$accessRawFieldValues = $criteria->isRawFieldValueAccessEnabled();
|
||||
|
||||
$expr = $criteria->getWhereExpression();
|
||||
$filtered = $this->elements;
|
||||
|
||||
if ($expr) {
|
||||
$visitor = new ClosureExpressionVisitor($accessRawFieldValues);
|
||||
$filter = $visitor->dispatch($expr);
|
||||
$filtered = array_filter($filtered, $filter);
|
||||
}
|
||||
|
||||
$orderings = $criteria->orderings();
|
||||
|
||||
if ($orderings) {
|
||||
$next = null;
|
||||
foreach (array_reverse($orderings) as $field => $ordering) {
|
||||
$next = ClosureExpressionVisitor::sortByField($field, $ordering === Order::Descending ? -1 : 1, $next, $accessRawFieldValues);
|
||||
}
|
||||
|
||||
uasort($filtered, $next);
|
||||
}
|
||||
|
||||
$offset = $criteria->getFirstResult();
|
||||
$length = $criteria->getMaxResults();
|
||||
|
||||
if ($offset !== null && $offset > 0 || $length !== null && $length > 0) {
|
||||
$filtered = array_slice($filtered, (int) $offset, $length, true);
|
||||
}
|
||||
|
||||
return $this->createFrom($filtered);
|
||||
}
|
||||
}
|
||||
117
backend/vendor/doctrine/collections/src/Collection.php
vendored
Normal file
117
backend/vendor/doctrine/collections/src/Collection.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use ArrayAccess;
|
||||
use Closure;
|
||||
|
||||
/**
|
||||
* The missing (SPL) Collection/Array/OrderedMap interface.
|
||||
*
|
||||
* A Collection resembles the nature of a regular PHP array. That is,
|
||||
* it is essentially an <b>ordered map</b> that can also be used
|
||||
* like a list.
|
||||
*
|
||||
* A Collection has an internal iterator just like a PHP array. In addition,
|
||||
* a Collection can be iterated with external iterators, which is preferable.
|
||||
* To use an external iterator simply use the foreach language construct to
|
||||
* iterate over the collection (which calls {@link getIterator()} internally) or
|
||||
* explicitly retrieve an iterator though {@link getIterator()} which can then be
|
||||
* used to iterate over the collection.
|
||||
* You can not rely on the internal iterator of the collection being at a certain
|
||||
* position unless you explicitly positioned it before. Prefer iteration with
|
||||
* external iterators.
|
||||
*
|
||||
* @phpstan-template TKey of array-key
|
||||
* @phpstan-template T
|
||||
* @template-extends ReadableCollection<TKey, T>
|
||||
* @template-extends ArrayAccess<TKey, T>
|
||||
*/
|
||||
interface Collection extends ReadableCollection, ArrayAccess
|
||||
{
|
||||
/**
|
||||
* Adds an element at the end of the collection.
|
||||
*
|
||||
* @param mixed $element The element to add.
|
||||
* @phpstan-param T $element
|
||||
*
|
||||
* @return void we will require a native return type declaration in 3.0
|
||||
*/
|
||||
public function add(mixed $element);
|
||||
|
||||
/**
|
||||
* Clears the collection, removing all elements.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear();
|
||||
|
||||
/**
|
||||
* Removes the element at the specified index from the collection.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to remove.
|
||||
* @phpstan-param TKey $key
|
||||
*
|
||||
* @return mixed The removed element or NULL, if the collection did not contain the element.
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function remove(string|int $key);
|
||||
|
||||
/**
|
||||
* Removes the specified element from the collection, if it is found.
|
||||
*
|
||||
* @param mixed $element The element to remove.
|
||||
* @phpstan-param T $element
|
||||
*
|
||||
* @return bool TRUE if this collection contained the specified element, FALSE otherwise.
|
||||
*/
|
||||
public function removeElement(mixed $element);
|
||||
|
||||
/**
|
||||
* Sets an element in the collection at the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to set.
|
||||
* @param mixed $value The element to set.
|
||||
* @phpstan-param TKey $key
|
||||
* @phpstan-param T $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set(string|int $key, mixed $value);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param Closure(T):U $func
|
||||
*
|
||||
* @return Collection<mixed>
|
||||
* @phpstan-return Collection<TKey, U>
|
||||
*
|
||||
* @phpstan-template U
|
||||
*/
|
||||
public function map(Closure $func);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param Closure(T, TKey):bool $p
|
||||
*
|
||||
* @return Collection<mixed> A collection with the results of the filter operation.
|
||||
* @phpstan-return Collection<TKey, T>
|
||||
*/
|
||||
public function filter(Closure $p);
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @phpstan-param Closure(TKey, T):bool $p
|
||||
*
|
||||
* @return Collection<mixed>[] An array with two elements. The first element contains the collection
|
||||
* of elements where the predicate returned TRUE, the second element
|
||||
* contains the collection of elements where the predicate returned FALSE.
|
||||
* @phpstan-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
|
||||
*/
|
||||
public function partition(Closure $p);
|
||||
}
|
||||
308
backend/vendor/doctrine/collections/src/Criteria.php
vendored
Normal file
308
backend/vendor/doctrine/collections/src/Criteria.php
vendored
Normal file
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Doctrine\Common\Collections\Expr\CompositeExpression;
|
||||
use Doctrine\Common\Collections\Expr\Expression;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function array_map;
|
||||
use function func_get_arg;
|
||||
use function func_num_args;
|
||||
use function strtoupper;
|
||||
|
||||
/**
|
||||
* Criteria for filtering Selectable collections.
|
||||
*
|
||||
* @phpstan-consistent-constructor
|
||||
* @final since 2.5
|
||||
*/
|
||||
class Criteria
|
||||
{
|
||||
/** @deprecated use Order::Ascending instead */
|
||||
final public const ASC = 'ASC';
|
||||
|
||||
/** @deprecated use Order::Descending instead */
|
||||
final public const DESC = 'DESC';
|
||||
|
||||
private static ExpressionBuilder|null $expressionBuilder = null;
|
||||
|
||||
/** @var array<string, Order> */
|
||||
private array $orderings = [];
|
||||
|
||||
private int|null $firstResult = null;
|
||||
private int|null $maxResults = null;
|
||||
|
||||
/**
|
||||
* Creates an instance of the class.
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create(/* bool $accessRawFieldValues = false */): self
|
||||
{
|
||||
$accessRawFieldValues = 0 < func_num_args() ? func_get_arg(0) : false;
|
||||
|
||||
return new static(firstResult: 0, accessRawFieldValues: $accessRawFieldValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expression builder.
|
||||
*
|
||||
* @return ExpressionBuilder
|
||||
*/
|
||||
public static function expr()
|
||||
{
|
||||
if (self::$expressionBuilder === null) {
|
||||
self::$expressionBuilder = new ExpressionBuilder();
|
||||
}
|
||||
|
||||
return self::$expressionBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new Criteria.
|
||||
*
|
||||
* @param int|null $firstResult
|
||||
* @param array<string, string|Order>|null $orderings
|
||||
*/
|
||||
public function __construct(
|
||||
private Expression|null $expression = null,
|
||||
array|null $orderings = null,
|
||||
int|Placeholder|null $firstResult = Placeholder::NotSpecified,
|
||||
int|null $maxResults = null,
|
||||
private bool $accessRawFieldValues = false,
|
||||
) {
|
||||
if (! $accessRawFieldValues) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/472',
|
||||
'Not enabling raw field value access for the Criteria matching API in %s is deprecated. Raw field access will be the only supported method in 3.0',
|
||||
self::class,
|
||||
);
|
||||
}
|
||||
|
||||
if ($firstResult === null) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/311',
|
||||
'Passing null as $firstResult to the constructor of %s is deprecated. Pass 0 instead or omit the argument.',
|
||||
self::class,
|
||||
);
|
||||
}
|
||||
|
||||
if ($firstResult === Placeholder::NotSpecified) {
|
||||
$firstResult = null;
|
||||
}
|
||||
|
||||
$this->setFirstResult($firstResult);
|
||||
$this->setMaxResults($maxResults);
|
||||
|
||||
if ($orderings === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->orderBy($orderings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the where expression to evaluate when this Criteria is searched for.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function where(Expression $expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the where expression to evaluate when this Criteria is searched for
|
||||
* using an AND with previous expression.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function andWhere(Expression $expression)
|
||||
{
|
||||
if ($this->expression === null) {
|
||||
return $this->where($expression);
|
||||
}
|
||||
|
||||
$this->expression = new CompositeExpression(
|
||||
CompositeExpression::TYPE_AND,
|
||||
[$this->expression, $expression],
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the where expression to evaluate when this Criteria is searched for
|
||||
* using an OR with previous expression.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function orWhere(Expression $expression)
|
||||
{
|
||||
if ($this->expression === null) {
|
||||
return $this->where($expression);
|
||||
}
|
||||
|
||||
$this->expression = new CompositeExpression(
|
||||
CompositeExpression::TYPE_OR,
|
||||
[$this->expression, $expression],
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the expression attached to this Criteria.
|
||||
*
|
||||
* @return Expression|null
|
||||
*/
|
||||
public function getWhereExpression()
|
||||
{
|
||||
return $this->expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current orderings of this Criteria.
|
||||
*
|
||||
* @deprecated use orderings() instead
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getOrderings()
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/389',
|
||||
'Calling %s() is deprecated. Use %s::orderings() instead.',
|
||||
__METHOD__,
|
||||
self::class,
|
||||
);
|
||||
|
||||
return array_map(
|
||||
static fn (Order $ordering): string => $ordering->value,
|
||||
$this->orderings,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current orderings of this Criteria.
|
||||
*
|
||||
* @return array<string, Order>
|
||||
*/
|
||||
public function orderings(): array
|
||||
{
|
||||
return $this->orderings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ordering of the result of this Criteria.
|
||||
*
|
||||
* Keys are field and values are the order, being a valid Order enum case.
|
||||
*
|
||||
* @see Order::Ascending
|
||||
* @see Order::Descending
|
||||
*
|
||||
* @param array<string, string|Order> $orderings
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function orderBy(array $orderings)
|
||||
{
|
||||
$method = __METHOD__;
|
||||
$this->orderings = array_map(
|
||||
static function (string|Order $ordering) use ($method): Order {
|
||||
if ($ordering instanceof Order) {
|
||||
return $ordering;
|
||||
}
|
||||
|
||||
static $triggered = false;
|
||||
|
||||
if (! $triggered) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/389',
|
||||
'Passing non-Order enum values to %s() is deprecated. Pass Order enum values instead.',
|
||||
$method,
|
||||
);
|
||||
}
|
||||
|
||||
$triggered = true;
|
||||
|
||||
return strtoupper($ordering) === Order::Ascending->value ? Order::Ascending : Order::Descending;
|
||||
},
|
||||
$orderings,
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current first result option of this Criteria.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getFirstResult()
|
||||
{
|
||||
return $this->firstResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the number of first result that this Criteria should return.
|
||||
*
|
||||
* @param int|null $firstResult The value to set.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setFirstResult(int|null $firstResult)
|
||||
{
|
||||
if ($firstResult === null) {
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/311',
|
||||
'Passing null to %s() is deprecated, pass 0 instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
}
|
||||
|
||||
$this->firstResult = $firstResult;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets maxResults.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxResults()
|
||||
{
|
||||
return $this->maxResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets maxResults.
|
||||
*
|
||||
* @param int|null $maxResults The value to set.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMaxResults(int|null $maxResults)
|
||||
{
|
||||
$this->maxResults = $maxResults;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function isRawFieldValueAccessEnabled(): bool
|
||||
{
|
||||
return $this->accessRawFieldValues;
|
||||
}
|
||||
}
|
||||
272
backend/vendor/doctrine/collections/src/Expr/ClosureExpressionVisitor.php
vendored
Normal file
272
backend/vendor/doctrine/collections/src/Expr/ClosureExpressionVisitor.php
vendored
Normal file
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
use ArrayAccess;
|
||||
use Closure;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use ReflectionClass;
|
||||
use RuntimeException;
|
||||
|
||||
use function array_all;
|
||||
use function array_any;
|
||||
use function explode;
|
||||
use function func_get_arg;
|
||||
use function func_num_args;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_scalar;
|
||||
use function iterator_to_array;
|
||||
use function method_exists;
|
||||
use function preg_match;
|
||||
use function preg_replace_callback;
|
||||
use function sprintf;
|
||||
use function str_contains;
|
||||
use function str_ends_with;
|
||||
use function str_starts_with;
|
||||
use function strtoupper;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
/**
|
||||
* Walks an expression graph and turns it into a PHP closure.
|
||||
*
|
||||
* This closure can be used with {@Collection#filter()} and is used internally
|
||||
* by {@ArrayCollection#select()}.
|
||||
*
|
||||
* @final since 2.5
|
||||
*/
|
||||
class ClosureExpressionVisitor extends ExpressionVisitor
|
||||
{
|
||||
public function __construct(
|
||||
private readonly bool $accessRawFieldValues = false,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Accesses the field of a given object. This field has to be public
|
||||
* directly or indirectly (through an accessor get*, is*, or a magic
|
||||
* method, __get, __call).
|
||||
*
|
||||
* @param object|mixed[] $object
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getObjectFieldValue(object|array $object, string $field, /* bool $accessRawFieldValues = false */)
|
||||
{
|
||||
$accessRawFieldValues = 3 <= func_num_args() ? func_get_arg(2) : false;
|
||||
|
||||
if (str_contains($field, '.')) {
|
||||
[$field, $subField] = explode('.', $field, 2);
|
||||
$object = self::getObjectFieldValue($object, $field, $accessRawFieldValues);
|
||||
|
||||
return self::getObjectFieldValue($object, $subField, $accessRawFieldValues);
|
||||
}
|
||||
|
||||
if (is_array($object)) {
|
||||
return $object[$field];
|
||||
}
|
||||
|
||||
if ($accessRawFieldValues) {
|
||||
return self::getNearestFieldValue($object, $field);
|
||||
}
|
||||
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/472',
|
||||
'Not enabling raw field value access for %s is deprecated. Raw field access will be the only supported method in 3.0',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
$accessors = ['get', 'is', ''];
|
||||
|
||||
foreach ($accessors as $accessor) {
|
||||
$accessor .= $field;
|
||||
|
||||
if (method_exists($object, $accessor)) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('/^is[A-Z]+/', $field) === 1 && method_exists($object, $field)) {
|
||||
return $object->$field();
|
||||
}
|
||||
|
||||
// __call should be triggered for get.
|
||||
$accessor = $accessors[0] . $field;
|
||||
|
||||
if (method_exists($object, '__call')) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
|
||||
if ($object instanceof ArrayAccess) {
|
||||
return $object[$field];
|
||||
}
|
||||
|
||||
if (isset($object->$field)) {
|
||||
return $object->$field;
|
||||
}
|
||||
|
||||
// camelcase field name to support different variable naming conventions
|
||||
$ccField = preg_replace_callback('/_(.?)/', static fn ($matches) => strtoupper((string) $matches[1]), $field);
|
||||
|
||||
foreach ($accessors as $accessor) {
|
||||
$accessor .= $ccField;
|
||||
|
||||
if (method_exists($object, $accessor)) {
|
||||
return $object->$accessor();
|
||||
}
|
||||
}
|
||||
|
||||
return $object->$field;
|
||||
}
|
||||
|
||||
private static function getNearestFieldValue(object $object, string $field): mixed
|
||||
{
|
||||
$reflectionClass = new ReflectionClass($object);
|
||||
|
||||
while ($reflectionClass && ! $reflectionClass->hasProperty($field)) {
|
||||
$reflectionClass = $reflectionClass->getParentClass();
|
||||
}
|
||||
|
||||
if ($reflectionClass === false) {
|
||||
throw new RuntimeException(sprintf('Field "%s" does not exist in class "%s"', $field, $object::class));
|
||||
}
|
||||
|
||||
$property = $reflectionClass->getProperty($field);
|
||||
|
||||
if (PHP_VERSION_ID >= 80400) {
|
||||
return $property->getRawValue($object);
|
||||
}
|
||||
|
||||
return $property->getValue($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for sorting arrays of objects based on multiple fields + orientations.
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
public static function sortByField(string $name, int $orientation = 1, Closure|null $next = null, /* bool $accessRawFieldValues = false */)
|
||||
{
|
||||
$accessRawFieldValues = 4 <= func_num_args() ? func_get_arg(3) : false;
|
||||
|
||||
if (! $accessRawFieldValues) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/collections',
|
||||
'https://github.com/doctrine/collections/pull/472',
|
||||
'Not enabling raw field value access for %s is deprecated. Raw field access will be the only supported method in 3.0',
|
||||
__METHOD__,
|
||||
);
|
||||
}
|
||||
|
||||
if (! $next) {
|
||||
$next = static fn (): int => 0;
|
||||
}
|
||||
|
||||
return static function ($a, $b) use ($name, $next, $orientation, $accessRawFieldValues): int {
|
||||
$aValue = ClosureExpressionVisitor::getObjectFieldValue($a, $name, $accessRawFieldValues);
|
||||
$bValue = ClosureExpressionVisitor::getObjectFieldValue($b, $name, $accessRawFieldValues);
|
||||
|
||||
if ($aValue === $bValue) {
|
||||
return $next($a, $b);
|
||||
}
|
||||
|
||||
return ($aValue > $bValue ? 1 : -1) * $orientation;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkComparison(Comparison $comparison)
|
||||
{
|
||||
$field = $comparison->getField();
|
||||
$value = $comparison->getValue()->getValue();
|
||||
|
||||
return match ($comparison->getOperator()) {
|
||||
Comparison::EQ => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) === $value,
|
||||
Comparison::NEQ => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) !== $value,
|
||||
Comparison::LT => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) < $value,
|
||||
Comparison::LTE => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) <= $value,
|
||||
Comparison::GT => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) > $value,
|
||||
Comparison::GTE => fn ($object): bool => self::getObjectFieldValue($object, $field, $this->accessRawFieldValues) >= $value,
|
||||
Comparison::IN => function ($object) use ($field, $value): bool {
|
||||
$fieldValue = ClosureExpressionVisitor::getObjectFieldValue($object, $field, $this->accessRawFieldValues);
|
||||
|
||||
return in_array($fieldValue, $value, is_scalar($fieldValue));
|
||||
},
|
||||
Comparison::NIN => function ($object) use ($field, $value): bool {
|
||||
$fieldValue = ClosureExpressionVisitor::getObjectFieldValue($object, $field, $this->accessRawFieldValues);
|
||||
|
||||
return ! in_array($fieldValue, $value, is_scalar($fieldValue));
|
||||
},
|
||||
Comparison::CONTAINS => fn ($object): bool => str_contains((string) self::getObjectFieldValue($object, $field, $this->accessRawFieldValues), (string) $value),
|
||||
Comparison::MEMBER_OF => function ($object) use ($field, $value): bool {
|
||||
$fieldValues = ClosureExpressionVisitor::getObjectFieldValue($object, $field, $this->accessRawFieldValues);
|
||||
|
||||
if (! is_array($fieldValues)) {
|
||||
$fieldValues = iterator_to_array($fieldValues);
|
||||
}
|
||||
|
||||
return in_array($value, $fieldValues, true);
|
||||
},
|
||||
Comparison::STARTS_WITH => fn ($object): bool => str_starts_with((string) self::getObjectFieldValue($object, $field, $this->accessRawFieldValues), (string) $value),
|
||||
Comparison::ENDS_WITH => fn ($object): bool => str_ends_with((string) self::getObjectFieldValue($object, $field, $this->accessRawFieldValues), (string) $value),
|
||||
default => throw new RuntimeException('Unknown comparison operator: ' . $comparison->getOperator()),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkValue(Value $value)
|
||||
{
|
||||
return $value->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function walkCompositeExpression(CompositeExpression $expr)
|
||||
{
|
||||
$expressionList = [];
|
||||
|
||||
foreach ($expr->getExpressionList() as $child) {
|
||||
$expressionList[] = $this->dispatch($child);
|
||||
}
|
||||
|
||||
return match ($expr->getType()) {
|
||||
CompositeExpression::TYPE_AND => $this->andExpressions($expressionList),
|
||||
CompositeExpression::TYPE_OR => $this->orExpressions($expressionList),
|
||||
CompositeExpression::TYPE_NOT => $this->notExpression($expressionList),
|
||||
default => throw new RuntimeException('Unknown composite ' . $expr->getType()),
|
||||
};
|
||||
}
|
||||
|
||||
/** @param callable[] $expressions */
|
||||
private function andExpressions(array $expressions): Closure
|
||||
{
|
||||
return static fn ($object): bool => array_all(
|
||||
$expressions,
|
||||
static fn (callable $expression): bool => (bool) $expression($object),
|
||||
);
|
||||
}
|
||||
|
||||
/** @param callable[] $expressions */
|
||||
private function orExpressions(array $expressions): Closure
|
||||
{
|
||||
return static fn ($object): bool => array_any(
|
||||
$expressions,
|
||||
static fn (callable $expression): bool => (bool) $expression($object),
|
||||
);
|
||||
}
|
||||
|
||||
/** @param callable[] $expressions */
|
||||
private function notExpression(array $expressions): Closure
|
||||
{
|
||||
return static fn ($object) => ! $expressions[0]($object);
|
||||
}
|
||||
}
|
||||
64
backend/vendor/doctrine/collections/src/Expr/Comparison.php
vendored
Normal file
64
backend/vendor/doctrine/collections/src/Expr/Comparison.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/**
|
||||
* Comparison of a field with a value by the given operator.
|
||||
*
|
||||
* @final since 2.5
|
||||
*/
|
||||
class Comparison implements Expression
|
||||
{
|
||||
final public const EQ = '=';
|
||||
final public const NEQ = '<>';
|
||||
final public const LT = '<';
|
||||
final public const LTE = '<=';
|
||||
final public const GT = '>';
|
||||
final public const GTE = '>=';
|
||||
final public const IS = '='; // no difference with EQ
|
||||
final public const IN = 'IN';
|
||||
final public const NIN = 'NIN';
|
||||
final public const CONTAINS = 'CONTAINS';
|
||||
final public const MEMBER_OF = 'MEMBER_OF';
|
||||
final public const STARTS_WITH = 'STARTS_WITH';
|
||||
final public const ENDS_WITH = 'ENDS_WITH';
|
||||
|
||||
private readonly Value $value;
|
||||
|
||||
public function __construct(private readonly string $field, private readonly string $op, mixed $value)
|
||||
{
|
||||
if (! ($value instanceof Value)) {
|
||||
$value = new Value($value);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function getField()
|
||||
{
|
||||
return $this->field;
|
||||
}
|
||||
|
||||
/** @return Value */
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function getOperator()
|
||||
{
|
||||
return $this->op;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkComparison($this);
|
||||
}
|
||||
}
|
||||
72
backend/vendor/doctrine/collections/src/Expr/CompositeExpression.php
vendored
Normal file
72
backend/vendor/doctrine/collections/src/Expr/CompositeExpression.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Expression of Expressions combined by AND or OR operation.
|
||||
*
|
||||
* @final since 2.5
|
||||
*/
|
||||
class CompositeExpression implements Expression
|
||||
{
|
||||
final public const TYPE_AND = 'AND';
|
||||
final public const TYPE_OR = 'OR';
|
||||
final public const TYPE_NOT = 'NOT';
|
||||
|
||||
/** @var list<Expression> */
|
||||
private array $expressions = [];
|
||||
|
||||
/**
|
||||
* @param Expression[] $expressions
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct(private readonly string $type, array $expressions)
|
||||
{
|
||||
foreach ($expressions as $expr) {
|
||||
if ($expr instanceof Value) {
|
||||
throw new RuntimeException('Values are not supported expressions as children of and/or expressions.');
|
||||
}
|
||||
|
||||
if (! ($expr instanceof Expression)) {
|
||||
throw new RuntimeException('No expression given to CompositeExpression.');
|
||||
}
|
||||
|
||||
$this->expressions[] = $expr;
|
||||
}
|
||||
|
||||
if ($type === self::TYPE_NOT && count($this->expressions) !== 1) {
|
||||
throw new RuntimeException('Not expression only allows one expression as child.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of expressions nested in this composite.
|
||||
*
|
||||
* @return list<Expression>
|
||||
*/
|
||||
public function getExpressionList()
|
||||
{
|
||||
return $this->expressions;
|
||||
}
|
||||
|
||||
/** @return string */
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkCompositeExpression($this);
|
||||
}
|
||||
}
|
||||
14
backend/vendor/doctrine/collections/src/Expr/Expression.php
vendored
Normal file
14
backend/vendor/doctrine/collections/src/Expr/Expression.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/**
|
||||
* Expression for the {@link Selectable} interface.
|
||||
*/
|
||||
interface Expression
|
||||
{
|
||||
/** @return mixed */
|
||||
public function visit(ExpressionVisitor $visitor);
|
||||
}
|
||||
43
backend/vendor/doctrine/collections/src/Expr/ExpressionVisitor.php
vendored
Normal file
43
backend/vendor/doctrine/collections/src/Expr/ExpressionVisitor.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/**
|
||||
* An Expression visitor walks a graph of expressions and turns them into a
|
||||
* query for the underlying implementation.
|
||||
*/
|
||||
abstract class ExpressionVisitor
|
||||
{
|
||||
/**
|
||||
* Converts a comparison expression into the target query language output.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkComparison(Comparison $comparison);
|
||||
|
||||
/**
|
||||
* Converts a value expression into the target query language part.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkValue(Value $value);
|
||||
|
||||
/**
|
||||
* Converts a composite expression into the target query language output.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
abstract public function walkCompositeExpression(CompositeExpression $expr);
|
||||
|
||||
/**
|
||||
* Dispatches walking an expression to the appropriate handler.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function dispatch(Expression $expr)
|
||||
{
|
||||
return $expr->visit($this);
|
||||
}
|
||||
}
|
||||
27
backend/vendor/doctrine/collections/src/Expr/Value.php
vendored
Normal file
27
backend/vendor/doctrine/collections/src/Expr/Value.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections\Expr;
|
||||
|
||||
/** @final since 2.5 */
|
||||
class Value implements Expression
|
||||
{
|
||||
public function __construct(private readonly mixed $value)
|
||||
{
|
||||
}
|
||||
|
||||
/** @return mixed */
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function visit(ExpressionVisitor $visitor)
|
||||
{
|
||||
return $visitor->walkValue($this);
|
||||
}
|
||||
}
|
||||
130
backend/vendor/doctrine/collections/src/ExpressionBuilder.php
vendored
Normal file
130
backend/vendor/doctrine/collections/src/ExpressionBuilder.php
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Doctrine\Common\Collections\Expr\Comparison;
|
||||
use Doctrine\Common\Collections\Expr\CompositeExpression;
|
||||
use Doctrine\Common\Collections\Expr\Expression;
|
||||
use Doctrine\Common\Collections\Expr\Value;
|
||||
|
||||
/**
|
||||
* Builder for Expressions in the {@link Selectable} interface.
|
||||
*
|
||||
* Important Notice for interoperable code: You have to use scalar
|
||||
* values only for comparisons, otherwise the behavior of the comparison
|
||||
* may be different between implementations (Array vs ORM vs ODM).
|
||||
*
|
||||
* @final since 2.5
|
||||
*/
|
||||
class ExpressionBuilder
|
||||
{
|
||||
/** @return CompositeExpression */
|
||||
public function andX(Expression ...$expressions)
|
||||
{
|
||||
return new CompositeExpression(CompositeExpression::TYPE_AND, $expressions);
|
||||
}
|
||||
|
||||
/** @return CompositeExpression */
|
||||
public function orX(Expression ...$expressions)
|
||||
{
|
||||
return new CompositeExpression(CompositeExpression::TYPE_OR, $expressions);
|
||||
}
|
||||
|
||||
public function not(Expression $expression): CompositeExpression
|
||||
{
|
||||
return new CompositeExpression(CompositeExpression::TYPE_NOT, [$expression]);
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function eq(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::EQ, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function gt(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::GT, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function lt(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::LT, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function gte(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::GTE, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function lte(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::LTE, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function neq(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::NEQ, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function isNull(string $field)
|
||||
{
|
||||
return new Comparison($field, Comparison::EQ, new Value(null));
|
||||
}
|
||||
|
||||
public function isNotNull(string $field): Comparison
|
||||
{
|
||||
return new Comparison($field, Comparison::NEQ, new Value(null));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $values
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function in(string $field, array $values)
|
||||
{
|
||||
return new Comparison($field, Comparison::IN, new Value($values));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $values
|
||||
*
|
||||
* @return Comparison
|
||||
*/
|
||||
public function notIn(string $field, array $values)
|
||||
{
|
||||
return new Comparison($field, Comparison::NIN, new Value($values));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function contains(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::CONTAINS, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function memberOf(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::MEMBER_OF, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function startsWith(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::STARTS_WITH, new Value($value));
|
||||
}
|
||||
|
||||
/** @return Comparison */
|
||||
public function endsWith(string $field, mixed $value)
|
||||
{
|
||||
return new Comparison($field, Comparison::ENDS_WITH, new Value($value));
|
||||
}
|
||||
}
|
||||
11
backend/vendor/doctrine/collections/src/Order.php
vendored
Normal file
11
backend/vendor/doctrine/collections/src/Order.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
enum Order: string
|
||||
{
|
||||
case Ascending = 'ASC';
|
||||
case Descending = 'DESC';
|
||||
}
|
||||
11
backend/vendor/doctrine/collections/src/Placeholder.php
vendored
Normal file
11
backend/vendor/doctrine/collections/src/Placeholder.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
/** @internal */
|
||||
enum Placeholder
|
||||
{
|
||||
case NotSpecified;
|
||||
}
|
||||
242
backend/vendor/doctrine/collections/src/ReadableCollection.php
vendored
Normal file
242
backend/vendor/doctrine/collections/src/ReadableCollection.php
vendored
Normal file
@@ -0,0 +1,242 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
use Closure;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
|
||||
/**
|
||||
* @phpstan-template TKey of array-key
|
||||
* @template-covariant T
|
||||
* @template-extends IteratorAggregate<TKey, T>
|
||||
*/
|
||||
interface ReadableCollection extends Countable, IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Checks whether an element is contained in the collection.
|
||||
* This is an O(n) operation, where n is the size of the collection.
|
||||
*
|
||||
* @param mixed $element The element to search for.
|
||||
* @phpstan-param TMaybeContained $element
|
||||
*
|
||||
* @return bool TRUE if the collection contains the element, FALSE otherwise.
|
||||
* @phpstan-return (TMaybeContained is T ? bool : false)
|
||||
*
|
||||
* @template TMaybeContained
|
||||
*/
|
||||
public function contains(mixed $element);
|
||||
|
||||
/**
|
||||
* Checks whether the collection is empty (contains no elements).
|
||||
*
|
||||
* @return bool TRUE if the collection is empty, FALSE otherwise.
|
||||
*/
|
||||
public function isEmpty();
|
||||
|
||||
/**
|
||||
* Checks whether the collection contains an element with the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index to check for.
|
||||
* @phpstan-param TKey $key
|
||||
*
|
||||
* @return bool TRUE if the collection contains an element with the specified key/index,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
public function containsKey(string|int $key);
|
||||
|
||||
/**
|
||||
* Gets the element at the specified key/index.
|
||||
*
|
||||
* @param string|int $key The key/index of the element to retrieve.
|
||||
* @phpstan-param TKey $key
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function get(string|int $key);
|
||||
|
||||
/**
|
||||
* Gets all keys/indices of the collection.
|
||||
*
|
||||
* @return int[]|string[] The keys/indices of the collection, in the order of the corresponding
|
||||
* elements in the collection.
|
||||
* @phpstan-return list<TKey>
|
||||
*/
|
||||
public function getKeys();
|
||||
|
||||
/**
|
||||
* Gets all values of the collection.
|
||||
*
|
||||
* @return mixed[] The values of all elements in the collection, in the
|
||||
* order they appear in the collection.
|
||||
* @phpstan-return list<T>
|
||||
*/
|
||||
public function getValues();
|
||||
|
||||
/**
|
||||
* Gets a native PHP array representation of the collection.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @phpstan-return array<TKey,T>
|
||||
*/
|
||||
public function toArray();
|
||||
|
||||
/**
|
||||
* Sets the internal iterator to the first element in the collection and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function first();
|
||||
|
||||
/**
|
||||
* Sets the internal iterator to the last element in the collection and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function last();
|
||||
|
||||
/**
|
||||
* Gets the key/index of the element at the current iterator position.
|
||||
*
|
||||
* @return int|string|null
|
||||
* @phpstan-return TKey|null
|
||||
*/
|
||||
public function key();
|
||||
|
||||
/**
|
||||
* Gets the element of the collection at the current iterator position.
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function current();
|
||||
|
||||
/**
|
||||
* Moves the internal iterator position to the next element and returns this element.
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return T|false
|
||||
*/
|
||||
public function next();
|
||||
|
||||
/**
|
||||
* Extracts a slice of $length elements starting at position $offset from the Collection.
|
||||
*
|
||||
* If $length is null it returns all elements from $offset to the end of the Collection.
|
||||
* Keys have to be preserved by this method. Calling this method will only return the
|
||||
* selected slice and NOT change the elements contained in the collection slice is called on.
|
||||
*
|
||||
* @param int $offset The offset to start from.
|
||||
* @param int|null $length The maximum number of elements to return, or null for no limit.
|
||||
*
|
||||
* @return mixed[]
|
||||
* @phpstan-return array<TKey,T>
|
||||
*/
|
||||
public function slice(int $offset, int|null $length = null);
|
||||
|
||||
/**
|
||||
* Tests for the existence of an element that satisfies the given predicate.
|
||||
*
|
||||
* @param Closure $p The predicate.
|
||||
* @phpstan-param Closure(TKey, T):bool $p
|
||||
*
|
||||
* @return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise.
|
||||
*/
|
||||
public function exists(Closure $p);
|
||||
|
||||
/**
|
||||
* Returns all the elements of this collection that satisfy the predicate p.
|
||||
* The order of the elements is preserved.
|
||||
*
|
||||
* @param Closure $p The predicate used for filtering.
|
||||
* @phpstan-param Closure(T, TKey):bool $p
|
||||
*
|
||||
* @return ReadableCollection<mixed> A collection with the results of the filter operation.
|
||||
* @phpstan-return ReadableCollection<TKey, T>
|
||||
*/
|
||||
public function filter(Closure $p);
|
||||
|
||||
/**
|
||||
* Applies the given function to each element in the collection and returns
|
||||
* a new collection with the elements returned by the function.
|
||||
*
|
||||
* @phpstan-param Closure(T):U $func
|
||||
*
|
||||
* @return ReadableCollection<mixed>
|
||||
* @phpstan-return ReadableCollection<TKey, U>
|
||||
*
|
||||
* @phpstan-template U
|
||||
*/
|
||||
public function map(Closure $func);
|
||||
|
||||
/**
|
||||
* Partitions this collection in two collections according to a predicate.
|
||||
* Keys are preserved in the resulting collections.
|
||||
*
|
||||
* @param Closure $p The predicate on which to partition.
|
||||
* @phpstan-param Closure(TKey, T):bool $p
|
||||
*
|
||||
* @return ReadableCollection<mixed>[] An array with two elements. The first element contains the collection
|
||||
* of elements where the predicate returned TRUE, the second element
|
||||
* contains the collection of elements where the predicate returned FALSE.
|
||||
* @phpstan-return array{0: ReadableCollection<TKey, T>, 1: ReadableCollection<TKey, T>}
|
||||
*/
|
||||
public function partition(Closure $p);
|
||||
|
||||
/**
|
||||
* Tests whether the given predicate p holds for all elements of this collection.
|
||||
*
|
||||
* @param Closure $p The predicate.
|
||||
* @phpstan-param Closure(TKey, T):bool $p
|
||||
*
|
||||
* @return bool TRUE, if the predicate yields TRUE for all elements, FALSE otherwise.
|
||||
*/
|
||||
public function forAll(Closure $p);
|
||||
|
||||
/**
|
||||
* Gets the index/key of a given element. The comparison of two elements is strict,
|
||||
* that means not only the value but also the type must match.
|
||||
* For objects this means reference equality.
|
||||
*
|
||||
* @param mixed $element The element to search for.
|
||||
* @phpstan-param TMaybeContained $element
|
||||
*
|
||||
* @return int|string|bool The key/index of the element or FALSE if the element was not found.
|
||||
* @phpstan-return (TMaybeContained is T ? TKey|false : false)
|
||||
*
|
||||
* @template TMaybeContained
|
||||
*/
|
||||
public function indexOf(mixed $element);
|
||||
|
||||
/**
|
||||
* Returns the first element of this collection that satisfies the predicate p.
|
||||
*
|
||||
* @param Closure $p The predicate.
|
||||
* @phpstan-param Closure(TKey, T):bool $p
|
||||
*
|
||||
* @return mixed The first element respecting the predicate,
|
||||
* null if no element respects the predicate.
|
||||
* @phpstan-return T|null
|
||||
*/
|
||||
public function findFirst(Closure $p);
|
||||
|
||||
/**
|
||||
* Applies iteratively the given function to each element in the collection,
|
||||
* so as to reduce the collection to a single value.
|
||||
*
|
||||
* @phpstan-param Closure(TReturn|TInitial, T):TReturn $func
|
||||
* @phpstan-param TInitial $initial
|
||||
*
|
||||
* @return mixed
|
||||
* @phpstan-return TReturn|TInitial
|
||||
*
|
||||
* @phpstan-template TReturn
|
||||
* @phpstan-template TInitial
|
||||
*/
|
||||
public function reduce(Closure $func, mixed $initial = null);
|
||||
}
|
||||
32
backend/vendor/doctrine/collections/src/Selectable.php
vendored
Normal file
32
backend/vendor/doctrine/collections/src/Selectable.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Collections;
|
||||
|
||||
/**
|
||||
* Interface for collections that allow efficient filtering with an expression API.
|
||||
*
|
||||
* Goal of this interface is a backend independent method to fetch elements
|
||||
* from a collections. {@link Expression} is crafted in a way that you can
|
||||
* implement queries from both in-memory and database-backed collections.
|
||||
*
|
||||
* For database backed collections this allows very efficient access by
|
||||
* utilizing the query APIs, for example SQL in the ORM. Applications using
|
||||
* this API can implement efficient database access without having to ask the
|
||||
* EntityManager or Repositories.
|
||||
*
|
||||
* @phpstan-template TKey as array-key
|
||||
* @phpstan-template-covariant T
|
||||
*/
|
||||
interface Selectable
|
||||
{
|
||||
/**
|
||||
* Selects all elements from a selectable that match the expression and
|
||||
* returns a new collection containing these elements and preserved keys.
|
||||
*
|
||||
* @return ReadableCollection<mixed>&Selectable<mixed>
|
||||
* @phpstan-return ReadableCollection<TKey,T>&Selectable<TKey,T>
|
||||
*/
|
||||
public function matching(Criteria $criteria);
|
||||
}
|
||||
19
backend/vendor/doctrine/dbal/LICENSE
vendored
Normal file
19
backend/vendor/doctrine/dbal/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2018 Doctrine Project
|
||||
|
||||
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.
|
||||
71
backend/vendor/doctrine/dbal/composer.json
vendored
Normal file
71
backend/vendor/doctrine/dbal/composer.json
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "doctrine/dbal",
|
||||
"type": "library",
|
||||
"description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.",
|
||||
"keywords": [
|
||||
"abstraction",
|
||||
"database",
|
||||
"dbal",
|
||||
"db2",
|
||||
"mariadb",
|
||||
"mssql",
|
||||
"mysql",
|
||||
"pgsql",
|
||||
"postgresql",
|
||||
"oci8",
|
||||
"oracle",
|
||||
"pdo",
|
||||
"queryobject",
|
||||
"sasql",
|
||||
"sql",
|
||||
"sqlite",
|
||||
"sqlserver",
|
||||
"sqlsrv"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/dbal.html",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
|
||||
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
|
||||
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
|
||||
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "^8.2",
|
||||
"doctrine/deprecations": "^1.1.5",
|
||||
"psr/cache": "^1|^2|^3",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "14.0.0",
|
||||
"fig/log-test": "^1",
|
||||
"jetbrains/phpstorm-stubs": "2023.2",
|
||||
"phpstan/phpstan": "2.1.30",
|
||||
"phpstan/phpstan-phpunit": "2.0.7",
|
||||
"phpstan/phpstan-strict-rules": "^2",
|
||||
"phpunit/phpunit": "11.5.50",
|
||||
"slevomat/coding-standard": "8.27.1",
|
||||
"squizlabs/php_codesniffer": "4.0.1",
|
||||
"symfony/cache": "^6.3.8|^7.0|^8.0",
|
||||
"symfony/console": "^5.4|^6.3|^7.0|^8.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "For helpful console commands such as SQL execution and import of files."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"composer/package-versions-deprecated": true
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Doctrine\\DBAL\\": "src" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Doctrine\\DBAL\\Tests\\": "tests" }
|
||||
},
|
||||
"scripts": {
|
||||
"docs": "composer --working-dir docs update && ./docs/vendor/bin/build-docs.sh @additional_args"
|
||||
}
|
||||
}
|
||||
39
backend/vendor/doctrine/dbal/src/ArrayParameterType.php
vendored
Normal file
39
backend/vendor/doctrine/dbal/src/ArrayParameterType.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
enum ArrayParameterType
|
||||
{
|
||||
/**
|
||||
* Represents an array of ints to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
case INTEGER;
|
||||
|
||||
/**
|
||||
* Represents an array of strings to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
case STRING;
|
||||
|
||||
/**
|
||||
* Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
case ASCII;
|
||||
|
||||
/**
|
||||
* Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
case BINARY;
|
||||
|
||||
/** @internal */
|
||||
public static function toElementParameterType(self $type): ParameterType
|
||||
{
|
||||
return match ($type) {
|
||||
self::INTEGER => ParameterType::INTEGER,
|
||||
self::STRING => ParameterType::STRING,
|
||||
self::ASCII => ParameterType::ASCII,
|
||||
self::BINARY => ParameterType::BINARY,
|
||||
};
|
||||
}
|
||||
}
|
||||
12
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception.php
vendored
Normal file
12
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters;
|
||||
|
||||
use Throwable;
|
||||
|
||||
/** @internal */
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
}
|
||||
20
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingNamedParameter.php
vendored
Normal file
20
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingNamedParameter.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters\Exception;
|
||||
|
||||
use Doctrine\DBAL\ArrayParameters\Exception;
|
||||
use LogicException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
class MissingNamedParameter extends LogicException implements Exception
|
||||
{
|
||||
public static function new(string $name): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('Named parameter "%s" does not have a bound value.', $name),
|
||||
);
|
||||
}
|
||||
}
|
||||
21
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingPositionalParameter.php
vendored
Normal file
21
backend/vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingPositionalParameter.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters\Exception;
|
||||
|
||||
use Doctrine\DBAL\ArrayParameters\Exception;
|
||||
use LogicException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @internal */
|
||||
class MissingPositionalParameter extends LogicException implements Exception
|
||||
{
|
||||
public static function new(int $index): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('Positional parameter at index %d does not have a bound value.', $index),
|
||||
);
|
||||
}
|
||||
}
|
||||
136
backend/vendor/doctrine/dbal/src/Cache/ArrayResult.php
vendored
Normal file
136
backend/vendor/doctrine/dbal/src/Cache/ArrayResult.php
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Exception\InvalidColumnIndex;
|
||||
|
||||
use function array_combine;
|
||||
use function array_keys;
|
||||
use function array_map;
|
||||
use function array_values;
|
||||
use function count;
|
||||
|
||||
/** @internal The class is internal to the caching layer implementation. */
|
||||
final class ArrayResult implements Result
|
||||
{
|
||||
private int $num = 0;
|
||||
|
||||
/**
|
||||
* @param list<string> $columnNames The names of the result columns. Must be non-empty.
|
||||
* @param list<list<mixed>> $rows The rows of the result. Each row must have the same number of columns
|
||||
* as the number of column names.
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly array $columnNames,
|
||||
private array $rows,
|
||||
) {
|
||||
}
|
||||
|
||||
public function fetchNumeric(): array|false
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
public function fetchAssociative(): array|false
|
||||
{
|
||||
$row = $this->fetch();
|
||||
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_combine($this->columnNames, $row);
|
||||
}
|
||||
|
||||
public function fetchOne(): mixed
|
||||
{
|
||||
$row = $this->fetch();
|
||||
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return FetchUtils::fetchAllNumeric($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return FetchUtils::fetchAllAssociative($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return FetchUtils::fetchFirstColumn($this);
|
||||
}
|
||||
|
||||
public function rowCount(): int
|
||||
{
|
||||
return count($this->rows);
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
return count($this->columnNames);
|
||||
}
|
||||
|
||||
public function getColumnName(int $index): string
|
||||
{
|
||||
return $this->columnNames[$index] ?? throw InvalidColumnIndex::new($index);
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
$this->rows = [];
|
||||
}
|
||||
|
||||
/** @return array{list<string>, list<list<mixed>>} */
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [$this->columnNames, $this->rows];
|
||||
}
|
||||
|
||||
/** @param mixed[] $data */
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
// Handle objects serialized with DBAL 4.1 and earlier.
|
||||
if (isset($data["\0" . self::class . "\0data"])) {
|
||||
/** @var list<array<string, mixed>> $legacyData */
|
||||
$legacyData = $data["\0" . self::class . "\0data"];
|
||||
|
||||
$this->columnNames = array_keys($legacyData[0] ?? []);
|
||||
$this->rows = array_map(array_values(...), $legacyData);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
[$this->columnNames, $this->rows] = $data;
|
||||
}
|
||||
|
||||
/** @return list<mixed>|false */
|
||||
private function fetch(): array|false
|
||||
{
|
||||
if (! isset($this->rows[$this->num])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->rows[$this->num++];
|
||||
}
|
||||
}
|
||||
11
backend/vendor/doctrine/dbal/src/Cache/CacheException.php
vendored
Normal file
11
backend/vendor/doctrine/dbal/src/Cache/CacheException.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
|
||||
class CacheException extends \Exception implements Exception
|
||||
{
|
||||
}
|
||||
15
backend/vendor/doctrine/dbal/src/Cache/Exception/NoCacheKey.php
vendored
Normal file
15
backend/vendor/doctrine/dbal/src/Cache/Exception/NoCacheKey.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Cache\Exception;
|
||||
|
||||
use Doctrine\DBAL\Cache\CacheException;
|
||||
|
||||
final class NoCacheKey extends CacheException
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
return new self('No cache key was set.');
|
||||
}
|
||||
}
|
||||
15
backend/vendor/doctrine/dbal/src/Cache/Exception/NoResultDriverConfigured.php
vendored
Normal file
15
backend/vendor/doctrine/dbal/src/Cache/Exception/NoResultDriverConfigured.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Cache\Exception;
|
||||
|
||||
use Doctrine\DBAL\Cache\CacheException;
|
||||
|
||||
final class NoResultDriverConfigured extends CacheException
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
return new self('Trying to cache a query but no result driver is configured.');
|
||||
}
|
||||
}
|
||||
92
backend/vendor/doctrine/dbal/src/Cache/QueryCacheProfile.php
vendored
Normal file
92
backend/vendor/doctrine/dbal/src/Cache/QueryCacheProfile.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Cache\Exception\NoCacheKey;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
use function hash;
|
||||
use function serialize;
|
||||
use function sha1;
|
||||
|
||||
/**
|
||||
* Query Cache Profile handles the data relevant for query caching.
|
||||
*
|
||||
* It is a value object, setter methods return NEW instances.
|
||||
*
|
||||
* @phpstan-import-type WrapperParameterType from Connection
|
||||
* @final
|
||||
*/
|
||||
class QueryCacheProfile
|
||||
{
|
||||
public function __construct(
|
||||
private readonly int $lifetime = 0,
|
||||
private readonly ?string $cacheKey = null,
|
||||
private readonly ?CacheItemPoolInterface $resultCache = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getResultCache(): ?CacheItemPoolInterface
|
||||
{
|
||||
return $this->resultCache;
|
||||
}
|
||||
|
||||
public function getLifetime(): int
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
/** @throws CacheException */
|
||||
public function getCacheKey(): string
|
||||
{
|
||||
if ($this->cacheKey === null) {
|
||||
throw NoCacheKey::new();
|
||||
}
|
||||
|
||||
return $this->cacheKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the real cache key from query, params, types and connection parameters.
|
||||
*
|
||||
* @param list<mixed>|array<string, mixed> $params
|
||||
* @param array<string, mixed> $connectionParams
|
||||
* @phpstan-param array<int, WrapperParameterType>|array<string, WrapperParameterType> $types
|
||||
*
|
||||
* @return array{string, string}
|
||||
*/
|
||||
public function generateCacheKeys(string $sql, array $params, array $types, array $connectionParams = []): array
|
||||
{
|
||||
if (isset($connectionParams['password'])) {
|
||||
unset($connectionParams['password']);
|
||||
}
|
||||
|
||||
$realCacheKey = 'query=' . $sql .
|
||||
'¶ms=' . serialize($params) .
|
||||
'&types=' . serialize($types) .
|
||||
'&connectionParams=' . hash('sha256', serialize($connectionParams));
|
||||
|
||||
// should the key be automatically generated using the inputs or is the cache key set?
|
||||
$cacheKey = $this->cacheKey ?? sha1($realCacheKey);
|
||||
|
||||
return [$cacheKey, $realCacheKey];
|
||||
}
|
||||
|
||||
public function setResultCache(CacheItemPoolInterface $cache): QueryCacheProfile
|
||||
{
|
||||
return new QueryCacheProfile($this->lifetime, $this->cacheKey, $cache);
|
||||
}
|
||||
|
||||
public function setCacheKey(?string $cacheKey): self
|
||||
{
|
||||
return new QueryCacheProfile($this->lifetime, $cacheKey, $this->resultCache);
|
||||
}
|
||||
|
||||
public function setLifetime(int $lifetime): self
|
||||
{
|
||||
return new QueryCacheProfile($lifetime, $this->cacheKey, $this->resultCache);
|
||||
}
|
||||
}
|
||||
21
backend/vendor/doctrine/dbal/src/ColumnCase.php
vendored
Normal file
21
backend/vendor/doctrine/dbal/src/ColumnCase.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
/**
|
||||
* Contains portable column case conversions.
|
||||
*/
|
||||
enum ColumnCase
|
||||
{
|
||||
/**
|
||||
* Convert column names to upper case.
|
||||
*/
|
||||
case UPPER;
|
||||
|
||||
/**
|
||||
* Convert column names to lower case.
|
||||
*/
|
||||
case LOWER;
|
||||
}
|
||||
151
backend/vendor/doctrine/dbal/src/Configuration.php
vendored
Normal file
151
backend/vendor/doctrine/dbal/src/Configuration.php
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\DBAL\Driver\Middleware;
|
||||
use Doctrine\DBAL\Exception\InvalidArgumentException;
|
||||
use Doctrine\DBAL\Schema\SchemaManagerFactory;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
/**
|
||||
* Configuration container for the Doctrine DBAL.
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
/** @var Middleware[] */
|
||||
private array $middlewares = [];
|
||||
|
||||
/**
|
||||
* The cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
private ?CacheItemPoolInterface $resultCache = null;
|
||||
|
||||
/**
|
||||
* The callable to use to filter schema assets.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
protected $schemaAssetsFilter;
|
||||
|
||||
/**
|
||||
* The default auto-commit mode for connections.
|
||||
*/
|
||||
protected bool $autoCommit = true;
|
||||
|
||||
private ?SchemaManagerFactory $schemaManagerFactory = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->schemaAssetsFilter = static function (): bool {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
public function getResultCache(): ?CacheItemPoolInterface
|
||||
{
|
||||
return $this->resultCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
public function setResultCache(CacheItemPoolInterface $cache): void
|
||||
{
|
||||
$this->resultCache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callable to use to filter schema assets.
|
||||
*/
|
||||
public function setSchemaAssetsFilter(callable $schemaAssetsFilter): void
|
||||
{
|
||||
$this->schemaAssetsFilter = $schemaAssetsFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the callable to use to filter schema assets.
|
||||
*/
|
||||
public function getSchemaAssetsFilter(): callable
|
||||
{
|
||||
return $this->schemaAssetsFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default auto-commit mode for connections.
|
||||
*
|
||||
* If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual
|
||||
* transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either
|
||||
* the method commit or the method rollback. By default, new connections are in auto-commit mode.
|
||||
*
|
||||
* @see getAutoCommit
|
||||
*
|
||||
* @param bool $autoCommit True to enable auto-commit mode; false to disable it
|
||||
*/
|
||||
public function setAutoCommit(bool $autoCommit): void
|
||||
{
|
||||
$this->autoCommit = $autoCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default auto-commit mode for connections.
|
||||
*
|
||||
* @see setAutoCommit
|
||||
*
|
||||
* @return bool True if auto-commit mode is enabled by default for connections, false otherwise.
|
||||
*/
|
||||
public function getAutoCommit(): bool
|
||||
{
|
||||
return $this->autoCommit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Middleware[] $middlewares
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMiddlewares(array $middlewares): self
|
||||
{
|
||||
$this->middlewares = $middlewares;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/** @return Middleware[] */
|
||||
public function getMiddlewares(): array
|
||||
{
|
||||
return $this->middlewares;
|
||||
}
|
||||
|
||||
public function getSchemaManagerFactory(): ?SchemaManagerFactory
|
||||
{
|
||||
return $this->schemaManagerFactory;
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function setSchemaManagerFactory(SchemaManagerFactory $schemaManagerFactory): self
|
||||
{
|
||||
$this->schemaManagerFactory = $schemaManagerFactory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisableTypeComments(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return $this */
|
||||
public function setDisableTypeComments(bool $disableTypeComments): self
|
||||
{
|
||||
if (! $disableTypeComments) {
|
||||
throw new InvalidArgumentException('Column comments cannot be enabled anymore.');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
1468
backend/vendor/doctrine/dbal/src/Connection.php
vendored
Normal file
1468
backend/vendor/doctrine/dbal/src/Connection.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
20
backend/vendor/doctrine/dbal/src/Connection/StaticServerVersionProvider.php
vendored
Normal file
20
backend/vendor/doctrine/dbal/src/Connection/StaticServerVersionProvider.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Connection;
|
||||
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/** @final */
|
||||
class StaticServerVersionProvider implements ServerVersionProvider
|
||||
{
|
||||
public function __construct(private readonly string $version)
|
||||
{
|
||||
}
|
||||
|
||||
public function getServerVersion(): string
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
9
backend/vendor/doctrine/dbal/src/ConnectionException.php
vendored
Normal file
9
backend/vendor/doctrine/dbal/src/ConnectionException.php
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
class ConnectionException extends \Exception implements Exception
|
||||
{
|
||||
}
|
||||
332
backend/vendor/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php
vendored
Normal file
332
backend/vendor/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php
vendored
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Connections;
|
||||
|
||||
use Doctrine\DBAL\Configuration;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Driver\Exception as DriverException;
|
||||
use Doctrine\DBAL\DriverManager;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Statement;
|
||||
use InvalidArgumentException;
|
||||
use SensitiveParameter;
|
||||
|
||||
use function array_rand;
|
||||
use function assert;
|
||||
use function count;
|
||||
|
||||
/**
|
||||
* Primary-Replica Connection
|
||||
*
|
||||
* Connection can be used with primary-replica setups.
|
||||
*
|
||||
* Important for the understanding of this connection should be how and when
|
||||
* it picks the replica or primary.
|
||||
*
|
||||
* 1. Replica if primary was never picked before and ONLY if 'getWrappedConnection'
|
||||
* or 'executeQuery' is used.
|
||||
* 2. Primary picked when 'executeStatement', 'insert', 'delete', 'update', 'createSavepoint',
|
||||
* 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit' or 'prepare' is called.
|
||||
* 3. If Primary was picked once during the lifetime of the connection it will always get picked afterwards.
|
||||
* 4. One replica connection is randomly picked ONCE during a request.
|
||||
*
|
||||
* ATTENTION: You can write to the replica with this connection if you execute a write query without
|
||||
* opening up a transaction. For example:
|
||||
*
|
||||
* $conn = DriverManager::getConnection(...);
|
||||
* $conn->executeQuery("DELETE FROM table");
|
||||
*
|
||||
* Be aware that Connection#executeQuery is a method specifically for READ
|
||||
* operations only.
|
||||
*
|
||||
* Use Connection#executeStatement for any SQL statement that changes/updates
|
||||
* state in the database (UPDATE, INSERT, DELETE or DDL statements).
|
||||
*
|
||||
* This connection is limited to replica operations using the
|
||||
* Connection#executeQuery operation only, because it wouldn't be compatible
|
||||
* with the ORM or SchemaManager code otherwise. Both use all the other
|
||||
* operations in a context where writes could happen to a replica, which makes
|
||||
* this restricted approach necessary.
|
||||
*
|
||||
* You can manually connect to the primary at any time by calling:
|
||||
*
|
||||
* $conn->ensureConnectedToPrimary();
|
||||
*
|
||||
* Instantiation through the DriverManager looks like:
|
||||
*
|
||||
* @phpstan-import-type Params from DriverManager
|
||||
* @phpstan-import-type OverrideParams from DriverManager
|
||||
* @example
|
||||
*
|
||||
* $conn = DriverManager::getConnection(array(
|
||||
* 'wrapperClass' => 'Doctrine\DBAL\Connections\PrimaryReadReplicaConnection',
|
||||
* 'driver' => 'pdo_mysql',
|
||||
* 'primary' => array('user' => '', 'password' => '', 'host' => '', 'dbname' => ''),
|
||||
* 'replica' => array(
|
||||
* array('user' => 'replica1', 'password' => '', 'host' => '', 'dbname' => ''),
|
||||
* array('user' => 'replica2', 'password' => '', 'host' => '', 'dbname' => ''),
|
||||
* )
|
||||
* ));
|
||||
*
|
||||
* You can also pass 'driverOptions' and any other documented option to each of this drivers
|
||||
* to pass additional information.
|
||||
*/
|
||||
class PrimaryReadReplicaConnection extends Connection
|
||||
{
|
||||
/**
|
||||
* Primary and Replica connection (one of the randomly picked replicas).
|
||||
*
|
||||
* @var array<string, DriverConnection|null>
|
||||
*/
|
||||
protected array $connections = ['primary' => null, 'replica' => null];
|
||||
|
||||
/**
|
||||
* You can keep the replica connection and then switch back to it
|
||||
* during the request if you know what you are doing.
|
||||
*/
|
||||
protected bool $keepReplica = false;
|
||||
|
||||
/**
|
||||
* Creates Primary Replica Connection.
|
||||
*
|
||||
* @internal The connection can be only instantiated by the driver manager.
|
||||
*
|
||||
* @param array<string, mixed> $params
|
||||
* @phpstan-param Params $params
|
||||
*/
|
||||
public function __construct(array $params, Driver $driver, ?Configuration $config = null)
|
||||
{
|
||||
if (! isset($params['replica'], $params['primary'])) {
|
||||
throw new InvalidArgumentException('primary or replica configuration missing');
|
||||
}
|
||||
|
||||
if (count($params['replica']) === 0) {
|
||||
throw new InvalidArgumentException('You have to configure at least one replica.');
|
||||
}
|
||||
|
||||
if (isset($params['driver'])) {
|
||||
$params['primary']['driver'] = $params['driver'];
|
||||
|
||||
foreach ($params['replica'] as $replicaKey => $replica) {
|
||||
$params['replica'][$replicaKey]['driver'] = $params['driver'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->keepReplica = ! empty($params['keepReplica']);
|
||||
|
||||
parent::__construct($params, $driver, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the connection is currently towards the primary or not.
|
||||
*/
|
||||
public function isConnectedToPrimary(): bool
|
||||
{
|
||||
return $this->_conn !== null && $this->_conn === $this->connections['primary'];
|
||||
}
|
||||
|
||||
public function connect(?string $connectionName = null): DriverConnection
|
||||
{
|
||||
if ($connectionName !== null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Passing a connection name as first argument is not supported anymore.'
|
||||
. ' Use ensureConnectedToPrimary()/ensureConnectedToReplica() instead.',
|
||||
);
|
||||
}
|
||||
|
||||
return $this->performConnect();
|
||||
}
|
||||
|
||||
/** @throws Exception */
|
||||
protected function performConnect(?string $connectionName = null): DriverConnection
|
||||
{
|
||||
$requestedConnectionChange = ($connectionName !== null);
|
||||
$connectionName ??= 'replica';
|
||||
|
||||
if ($connectionName !== 'replica' && $connectionName !== 'primary') {
|
||||
throw new InvalidArgumentException('Invalid option to connect(), only primary or replica allowed.');
|
||||
}
|
||||
|
||||
// If we have a connection open, and this is not an explicit connection
|
||||
// change request, then abort right here, because we are already done.
|
||||
// This prevents writes to the replica in case of "keepReplica" option enabled.
|
||||
if ($this->_conn !== null && ! $requestedConnectionChange) {
|
||||
return $this->_conn;
|
||||
}
|
||||
|
||||
$forcePrimaryAsReplica = false;
|
||||
|
||||
if ($this->getTransactionNestingLevel() > 0) {
|
||||
$connectionName = 'primary';
|
||||
$forcePrimaryAsReplica = true;
|
||||
}
|
||||
|
||||
if (isset($this->connections[$connectionName])) {
|
||||
$this->_conn = $this->connections[$connectionName];
|
||||
|
||||
if ($forcePrimaryAsReplica && ! $this->keepReplica) {
|
||||
$this->connections['replica'] = $this->_conn;
|
||||
}
|
||||
|
||||
return $this->_conn;
|
||||
}
|
||||
|
||||
if ($connectionName === 'primary') {
|
||||
$this->connections['primary'] = $this->_conn = $this->connectTo($connectionName);
|
||||
|
||||
// Set replica connection to primary to avoid invalid reads
|
||||
if (! $this->keepReplica) {
|
||||
$this->connections['replica'] = $this->connections['primary'];
|
||||
}
|
||||
} else {
|
||||
$this->connections['replica'] = $this->_conn = $this->connectTo($connectionName);
|
||||
}
|
||||
|
||||
return $this->_conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the primary node of the database cluster.
|
||||
*
|
||||
* All following statements after this will be executed against the primary node.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function ensureConnectedToPrimary(): void
|
||||
{
|
||||
$this->performConnect('primary');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a replica node of the database cluster.
|
||||
*
|
||||
* All following statements after this will be executed against the replica node,
|
||||
* unless the keepReplica option is set to false and a primary connection
|
||||
* was already opened.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function ensureConnectedToReplica(): void
|
||||
{
|
||||
$this->performConnect('replica');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a specific connection.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function connectTo(string $connectionName): DriverConnection
|
||||
{
|
||||
$params = $this->getParams();
|
||||
assert(isset($params['primary']));
|
||||
|
||||
if ($connectionName === 'primary') {
|
||||
$connectionParams = $params['primary'];
|
||||
} else {
|
||||
assert(isset($params['replica']));
|
||||
$connectionParams = $this->chooseReplicaConnectionParameters($params['primary'], $params['replica']);
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->driver->connect($connectionParams);
|
||||
} catch (DriverException $e) {
|
||||
throw $this->convertException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OverrideParams $primary
|
||||
* @param array<OverrideParams> $replicas
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
* @phpstan-return OverrideParams
|
||||
*/
|
||||
protected function chooseReplicaConnectionParameters(
|
||||
#[SensitiveParameter]
|
||||
array $primary,
|
||||
#[SensitiveParameter]
|
||||
array $replicas,
|
||||
): array {
|
||||
$params = $replicas[array_rand($replicas)];
|
||||
|
||||
if (! isset($params['charset']) && isset($primary['charset'])) {
|
||||
$params['charset'] = $primary['charset'];
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function executeStatement(string $sql, array $params = [], array $types = []): int|string
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::executeStatement($sql, $params, $types);
|
||||
}
|
||||
|
||||
public function beginTransaction(): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::beginTransaction();
|
||||
}
|
||||
|
||||
public function commit(): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::commit();
|
||||
}
|
||||
|
||||
public function rollBack(): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::rollBack();
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
{
|
||||
unset($this->connections['primary'], $this->connections['replica']);
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->_conn = null;
|
||||
$this->connections = ['primary' => null, 'replica' => null];
|
||||
}
|
||||
|
||||
public function createSavepoint(string $savepoint): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::createSavepoint($savepoint);
|
||||
}
|
||||
|
||||
public function releaseSavepoint(string $savepoint): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::releaseSavepoint($savepoint);
|
||||
}
|
||||
|
||||
public function rollbackSavepoint(string $savepoint): void
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::rollbackSavepoint($savepoint);
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::prepare($sql);
|
||||
}
|
||||
}
|
||||
51
backend/vendor/doctrine/dbal/src/Driver.php
vendored
Normal file
51
backend/vendor/doctrine/dbal/src/Driver.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\Exception\PlatformException;
|
||||
use SensitiveParameter;
|
||||
|
||||
/**
|
||||
* Driver interface.
|
||||
* Interface that all DBAL drivers must implement.
|
||||
*
|
||||
* @phpstan-import-type Params from DriverManager
|
||||
*/
|
||||
interface Driver
|
||||
{
|
||||
/**
|
||||
* Attempts to create a connection with the database.
|
||||
*
|
||||
* @param array<string, mixed> $params All connection parameters.
|
||||
* @phpstan-param Params $params All connection parameters.
|
||||
*
|
||||
* @return DriverConnection The database connection.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): DriverConnection;
|
||||
|
||||
/**
|
||||
* Gets the DatabasePlatform instance that provides all the metadata about
|
||||
* the platform this driver connects to.
|
||||
*
|
||||
* @return AbstractPlatform The database platform.
|
||||
*
|
||||
* @throws PlatformException
|
||||
*/
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform;
|
||||
|
||||
/**
|
||||
* Gets the ExceptionConverter that can be used to convert driver-level exceptions into DBAL exceptions.
|
||||
*/
|
||||
public function getExceptionConverter(): ExceptionConverter;
|
||||
}
|
||||
25
backend/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php
vendored
Normal file
25
backend/vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API;
|
||||
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
interface ExceptionConverter
|
||||
{
|
||||
/**
|
||||
* Converts a given driver-level exception into a DBAL-level driver exception.
|
||||
*
|
||||
* Implementors should use the vendor-specific error code and SQLSTATE of the exception
|
||||
* and instantiate the most appropriate specialized {@see DriverException} subclass.
|
||||
*
|
||||
* @param Exception $exception The driver exception to convert.
|
||||
* @param Query|null $query The SQL query that triggered the exception, if any.
|
||||
*
|
||||
* @return DriverException An instance of {@see DriverException} or one of its subclasses.
|
||||
*/
|
||||
public function convert(Exception $exception, ?Query $query): DriverException;
|
||||
}
|
||||
47
backend/vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
vendored
Normal file
47
backend/vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @link https://www.ibm.com/docs/en/db2/11.5?topic=messages-sql
|
||||
*/
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
return match ($exception->getCode()) {
|
||||
-104 => new SyntaxErrorException($exception, $query),
|
||||
-203 => new NonUniqueFieldNameException($exception, $query),
|
||||
-204 => new TableNotFoundException($exception, $query),
|
||||
-206 => new InvalidFieldNameException($exception, $query),
|
||||
-407 => new NotNullConstraintViolationException($exception, $query),
|
||||
-530,
|
||||
-531,
|
||||
-532,
|
||||
-20356 => new ForeignKeyConstraintViolationException($exception, $query),
|
||||
-601 => new TableExistsException($exception, $query),
|
||||
-803 => new UniqueConstraintViolationException($exception, $query),
|
||||
-1336,
|
||||
-30082 => new ConnectionException($exception, $query),
|
||||
default => new DriverException($exception, $query),
|
||||
};
|
||||
}
|
||||
}
|
||||
105
backend/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
vendored
Normal file
105
backend/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\MySQL;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\ConnectionLost;
|
||||
use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
|
||||
use Doctrine\DBAL\Exception\DeadlockException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
use function str_contains;
|
||||
|
||||
/** @internal */
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
/**
|
||||
* @link https://dev.mysql.com/doc/mysql-errors/8.0/en/client-error-reference.html
|
||||
* @link https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html
|
||||
*/
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
if (
|
||||
$exception->getCode() === 1524
|
||||
&& str_contains($exception->getMessage(), 'Plugin \'mysql_native_password\' is not loaded')
|
||||
) {
|
||||
// Workaround for MySQL 8.4 if we request an unknown user.
|
||||
// https://bugs.mysql.com/bug.php?id=114876
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
return match ($exception->getCode()) {
|
||||
1008 => new DatabaseDoesNotExist($exception, $query),
|
||||
1213 => new DeadlockException($exception, $query),
|
||||
1205 => new LockWaitTimeoutException($exception, $query),
|
||||
1050 => new TableExistsException($exception, $query),
|
||||
1051,
|
||||
1146 => new TableNotFoundException($exception, $query),
|
||||
1216,
|
||||
1217,
|
||||
1451,
|
||||
1452,
|
||||
1701 => new ForeignKeyConstraintViolationException($exception, $query),
|
||||
1062,
|
||||
1557,
|
||||
1569,
|
||||
1586 => new UniqueConstraintViolationException($exception, $query),
|
||||
1054,
|
||||
1166,
|
||||
1611 => new InvalidFieldNameException($exception, $query),
|
||||
1052,
|
||||
1060,
|
||||
1110 => new NonUniqueFieldNameException($exception, $query),
|
||||
1064,
|
||||
1149,
|
||||
1287,
|
||||
1341,
|
||||
1342,
|
||||
1343,
|
||||
1344,
|
||||
1382,
|
||||
1479,
|
||||
1541,
|
||||
1554,
|
||||
1626 => new SyntaxErrorException($exception, $query),
|
||||
1044,
|
||||
1045,
|
||||
1046,
|
||||
1049,
|
||||
1095,
|
||||
1142,
|
||||
1143,
|
||||
1227,
|
||||
1370,
|
||||
1429,
|
||||
2002,
|
||||
2005,
|
||||
2054 => new ConnectionException($exception, $query),
|
||||
2006,
|
||||
4031 => new ConnectionLost($exception, $query),
|
||||
1048,
|
||||
1121,
|
||||
1138,
|
||||
1171,
|
||||
1252,
|
||||
1263,
|
||||
1364,
|
||||
1566 => new NotNullConstraintViolationException($exception, $query),
|
||||
default => new DriverException($exception, $query),
|
||||
};
|
||||
}
|
||||
}
|
||||
80
backend/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
vendored
Normal file
80
backend/vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\OCI;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Driver\OCI8\Exception\Error;
|
||||
use Doctrine\DBAL\Driver\PDO\Exception as DriverPDOException;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
|
||||
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\TransactionRolledBack;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
use function assert;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function str_replace;
|
||||
|
||||
/** @internal */
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
/** @link http://www.dba-oracle.com/t_error_code_list.htm */
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
return match ($exception->getCode()) {
|
||||
1,
|
||||
2299,
|
||||
38911 => new UniqueConstraintViolationException($exception, $query),
|
||||
904 => new InvalidFieldNameException($exception, $query),
|
||||
918,
|
||||
960 => new NonUniqueFieldNameException($exception, $query),
|
||||
923 => new SyntaxErrorException($exception, $query),
|
||||
942 => new TableNotFoundException($exception, $query),
|
||||
955 => new TableExistsException($exception, $query),
|
||||
1017,
|
||||
12545 => new ConnectionException($exception, $query),
|
||||
1400 => new NotNullConstraintViolationException($exception, $query),
|
||||
1918 => new DatabaseDoesNotExist($exception, $query),
|
||||
2091 => (function () use ($exception, $query) {
|
||||
//SQLSTATE[HY000]: General error: 2091 OCITransCommit: ORA-02091: transaction rolled back
|
||||
//ORA-00001: unique constraint (DOCTRINE.GH3423_UNIQUE) violated
|
||||
$lines = explode("\n", $exception->getMessage(), 2);
|
||||
assert(count($lines) >= 2);
|
||||
|
||||
[, $causeError] = $lines;
|
||||
|
||||
[$causeCode] = explode(': ', $causeError, 2);
|
||||
$code = (int) str_replace('ORA-', '', $causeCode);
|
||||
|
||||
$sqlState = $exception->getSQLState();
|
||||
if ($exception instanceof DriverPDOException) {
|
||||
$why = $this->convert(new DriverPDOException($causeError, $sqlState, $code, $exception), $query);
|
||||
} else {
|
||||
$why = $this->convert(new Error($causeError, $sqlState, $code, $exception), $query);
|
||||
}
|
||||
|
||||
return new TransactionRolledBack($why, $query);
|
||||
})(),
|
||||
2289,
|
||||
2443,
|
||||
4080 => new DatabaseObjectNotFoundException($exception, $query),
|
||||
2266,
|
||||
2291,
|
||||
2292 => new ForeignKeyConstraintViolationException($exception, $query),
|
||||
default => new DriverException($exception, $query),
|
||||
};
|
||||
}
|
||||
}
|
||||
87
backend/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php
vendored
Normal file
87
backend/vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\PostgreSQL;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\ConnectionLost;
|
||||
use Doctrine\DBAL\Exception\DatabaseDoesNotExist;
|
||||
use Doctrine\DBAL\Exception\DeadlockException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\SchemaDoesNotExist;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
use function str_contains;
|
||||
|
||||
/** @internal */
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
/** @link http://www.postgresql.org/docs/9.4/static/errcodes-appendix.html */
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
switch ($exception->getSQLState()) {
|
||||
case '40001':
|
||||
case '40P01':
|
||||
return new DeadlockException($exception, $query);
|
||||
|
||||
case '0A000':
|
||||
// Foreign key constraint violations during a TRUNCATE operation
|
||||
// are considered "feature not supported" in PostgreSQL.
|
||||
if (str_contains($exception->getMessage(), 'truncate')) {
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case '23502':
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
|
||||
case '23503':
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
|
||||
case '23505':
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
|
||||
case '3D000':
|
||||
return new DatabaseDoesNotExist($exception, $query);
|
||||
|
||||
case '3F000':
|
||||
return new SchemaDoesNotExist($exception, $query);
|
||||
|
||||
case '42601':
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
|
||||
case '42702':
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
|
||||
case '42703':
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
|
||||
case '42P01':
|
||||
return new TableNotFoundException($exception, $query);
|
||||
|
||||
case '42P07':
|
||||
return new TableExistsException($exception, $query);
|
||||
|
||||
case '08006':
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'terminating connection')) {
|
||||
return new ConnectionLost($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
49
backend/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
vendored
Normal file
49
backend/vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\SQLSrv;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\DatabaseObjectNotFoundException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @link https://docs.microsoft.com/en-us/sql/relational-databases/errors-events/database-engine-events-and-errors
|
||||
*/
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
return match ($exception->getCode()) {
|
||||
102 => new SyntaxErrorException($exception, $query),
|
||||
207 => new InvalidFieldNameException($exception, $query),
|
||||
208 => new TableNotFoundException($exception, $query),
|
||||
209 => new NonUniqueFieldNameException($exception, $query),
|
||||
515 => new NotNullConstraintViolationException($exception, $query),
|
||||
547,
|
||||
4712 => new ForeignKeyConstraintViolationException($exception, $query),
|
||||
2601,
|
||||
2627 => new UniqueConstraintViolationException($exception, $query),
|
||||
2714 => new TableExistsException($exception, $query),
|
||||
3701,
|
||||
15151 => new DatabaseObjectNotFoundException($exception, $query),
|
||||
11001,
|
||||
18456 => new ConnectionException($exception, $query),
|
||||
default => new DriverException($exception, $query),
|
||||
};
|
||||
}
|
||||
}
|
||||
85
backend/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php
vendored
Normal file
85
backend/vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\SQLite;
|
||||
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Exception\ConnectionException;
|
||||
use Doctrine\DBAL\Exception\DriverException;
|
||||
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\InvalidFieldNameException;
|
||||
use Doctrine\DBAL\Exception\LockWaitTimeoutException;
|
||||
use Doctrine\DBAL\Exception\NonUniqueFieldNameException;
|
||||
use Doctrine\DBAL\Exception\NotNullConstraintViolationException;
|
||||
use Doctrine\DBAL\Exception\ReadOnlyException;
|
||||
use Doctrine\DBAL\Exception\SyntaxErrorException;
|
||||
use Doctrine\DBAL\Exception\TableExistsException;
|
||||
use Doctrine\DBAL\Exception\TableNotFoundException;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
use function str_contains;
|
||||
|
||||
/** @internal */
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
/** @link http://www.sqlite.org/c3ref/c_abort.html */
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
if (str_contains($exception->getMessage(), 'database is locked')) {
|
||||
return new LockWaitTimeoutException($exception, $query);
|
||||
}
|
||||
|
||||
if (
|
||||
str_contains($exception->getMessage(), 'must be unique') ||
|
||||
str_contains($exception->getMessage(), 'is not unique') ||
|
||||
str_contains($exception->getMessage(), 'are not unique') ||
|
||||
str_contains($exception->getMessage(), 'UNIQUE constraint failed')
|
||||
) {
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
if (
|
||||
str_contains($exception->getMessage(), 'may not be NULL') ||
|
||||
str_contains($exception->getMessage(), 'NOT NULL constraint failed')
|
||||
) {
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'no such table:')) {
|
||||
return new TableNotFoundException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'already exists')) {
|
||||
return new TableExistsException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'has no column named')) {
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'ambiguous column name')) {
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'syntax error')) {
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'attempt to write a readonly database')) {
|
||||
return new ReadOnlyException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'unable to open database file')) {
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
if (str_contains($exception->getMessage(), 'FOREIGN KEY constraint failed')) {
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
27
backend/vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php
vendored
Normal file
27
backend/vendor/doctrine/dbal/src/Driver/AbstractDB2Driver.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\IBMDB2\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\DB2Platform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for Db2 based drivers.
|
||||
*/
|
||||
abstract class AbstractDB2Driver implements Driver
|
||||
{
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): DB2Platform
|
||||
{
|
||||
return new DB2Platform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
}
|
||||
34
backend/vendor/doctrine/dbal/src/Driver/AbstractException.php
vendored
Normal file
34
backend/vendor/doctrine/dbal/src/Driver/AbstractException.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Exception as BaseException;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see DriverException} interface.
|
||||
*/
|
||||
abstract class AbstractException extends BaseException implements Exception
|
||||
{
|
||||
/**
|
||||
* @param string $message The driver error message.
|
||||
* @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any.
|
||||
* @param int $code The driver specific error code if any.
|
||||
* @param Throwable|null $previous The previous throwable used for the exception chaining.
|
||||
*/
|
||||
public function __construct(
|
||||
string $message,
|
||||
private readonly ?string $sqlState = null,
|
||||
int $code = 0,
|
||||
?Throwable $previous = null,
|
||||
) {
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function getSQLState(): ?string
|
||||
{
|
||||
return $this->sqlState;
|
||||
}
|
||||
}
|
||||
114
backend/vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php
vendored
Normal file
114
backend/vendor/doctrine/dbal/src/Driver/AbstractMySQLDriver.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
|
||||
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
|
||||
use Doctrine\DBAL\Platforms\MariaDB1010Platform;
|
||||
use Doctrine\DBAL\Platforms\MariaDB1052Platform;
|
||||
use Doctrine\DBAL\Platforms\MariaDB1060Platform;
|
||||
use Doctrine\DBAL\Platforms\MariaDB110700Platform;
|
||||
use Doctrine\DBAL\Platforms\MariaDBPlatform;
|
||||
use Doctrine\DBAL\Platforms\MySQL80Platform;
|
||||
use Doctrine\DBAL\Platforms\MySQL84Platform;
|
||||
use Doctrine\DBAL\Platforms\MySQLPlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function preg_match;
|
||||
use function stripos;
|
||||
use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for MySQL based drivers.
|
||||
*/
|
||||
abstract class AbstractMySQLDriver implements Driver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws InvalidPlatformVersion
|
||||
*/
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractMySQLPlatform
|
||||
{
|
||||
$version = $versionProvider->getServerVersion();
|
||||
if (stripos($version, 'mariadb') !== false) {
|
||||
$mariaDbVersion = $this->getMariaDbMysqlVersionNumber($version);
|
||||
if (version_compare($mariaDbVersion, '11.7.0', '>=')) {
|
||||
return new MariaDB110700Platform();
|
||||
}
|
||||
|
||||
if (version_compare($mariaDbVersion, '10.10.0', '>=')) {
|
||||
return new MariaDB1010Platform();
|
||||
}
|
||||
|
||||
if (version_compare($mariaDbVersion, '10.6.0', '>=')) {
|
||||
return new MariaDB1060Platform();
|
||||
}
|
||||
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/6343',
|
||||
'Support for MariaDB < 10.6.0 is deprecated and will be removed in DBAL 5',
|
||||
);
|
||||
|
||||
if (version_compare($mariaDbVersion, '10.5.2', '>=')) {
|
||||
return new MariaDB1052Platform();
|
||||
}
|
||||
|
||||
return new MariaDBPlatform();
|
||||
}
|
||||
|
||||
if (version_compare($version, '8.4.0', '>=')) {
|
||||
return new MySQL84Platform();
|
||||
}
|
||||
|
||||
if (version_compare($version, '8.0.0', '>=')) {
|
||||
return new MySQL80Platform();
|
||||
}
|
||||
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/6343',
|
||||
'Support for MySQL < 8 is deprecated and will be removed in DBAL 5',
|
||||
);
|
||||
|
||||
return new MySQLPlatform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect MariaDB server version, including hack for some mariadb distributions
|
||||
* that starts with the prefix '5.5.5-'
|
||||
*
|
||||
* @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial'
|
||||
*
|
||||
* @throws InvalidPlatformVersion
|
||||
*/
|
||||
private function getMariaDbMysqlVersionNumber(string $versionString): string
|
||||
{
|
||||
if (
|
||||
preg_match(
|
||||
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
|
||||
$versionString,
|
||||
$versionParts,
|
||||
) !== 1
|
||||
) {
|
||||
throw InvalidPlatformVersion::new(
|
||||
$versionString,
|
||||
'^(?:5\.5\.5-)?(mariadb-)?<major_version>.<minor_version>.<patch_version>',
|
||||
);
|
||||
}
|
||||
|
||||
return $versionParts['major'] . '.' . $versionParts['minor'] . '.' . $versionParts['patch'];
|
||||
}
|
||||
}
|
||||
38
backend/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php
vendored
Normal file
38
backend/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\OCI\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\OraclePlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for Oracle based drivers.
|
||||
*/
|
||||
abstract class AbstractOracleDriver implements Driver
|
||||
{
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): OraclePlatform
|
||||
{
|
||||
return new OraclePlatform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an appropriate Easy Connect String for the given parameters.
|
||||
*
|
||||
* @param array<string, mixed> $params The connection parameters to return the Easy Connect String for.
|
||||
*/
|
||||
protected function getEasyConnectString(array $params): string
|
||||
{
|
||||
return (string) EasyConnectString::fromConnectionParameters($params);
|
||||
}
|
||||
}
|
||||
123
backend/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php
vendored
Normal file
123
backend/vendor/doctrine/dbal/src/Driver/AbstractOracleDriver/EasyConnectString.php
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\AbstractOracleDriver;
|
||||
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Represents an Oracle Easy Connect string
|
||||
*
|
||||
* @link https://docs.oracle.com/database/121/NETAG/naming.htm
|
||||
*/
|
||||
final class EasyConnectString
|
||||
{
|
||||
private function __construct(private readonly string $string)
|
||||
{
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from an array representation
|
||||
*
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
public static function fromArray(array $params): self
|
||||
{
|
||||
return new self(self::renderParams($params));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from the given DBAL connection parameters.
|
||||
*
|
||||
* @param mixed[] $params
|
||||
*/
|
||||
public static function fromConnectionParameters(array $params): self
|
||||
{
|
||||
if (isset($params['connectstring'])) {
|
||||
return new self($params['connectstring']);
|
||||
}
|
||||
|
||||
if (! isset($params['host'])) {
|
||||
return new self($params['dbname'] ?? '');
|
||||
}
|
||||
|
||||
$connectData = [];
|
||||
|
||||
if (isset($params['service'])) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/7042',
|
||||
'Using the "service" parameter to indicate that the value of the "dbname" parameter is the'
|
||||
. ' service name is deprecated. Use the "servicename" parameter instead.',
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($params['servicename']) || isset($params['dbname'])) {
|
||||
$serviceKey = 'SID';
|
||||
|
||||
if (isset($params['service']) || isset($params['servicename'])) {
|
||||
$serviceKey = 'SERVICE_NAME';
|
||||
}
|
||||
|
||||
$serviceName = $params['servicename'] ?? $params['dbname'];
|
||||
|
||||
$connectData[$serviceKey] = $serviceName;
|
||||
}
|
||||
|
||||
if (isset($params['instancename'])) {
|
||||
$connectData['INSTANCE_NAME'] = $params['instancename'];
|
||||
}
|
||||
|
||||
if (! empty($params['pooled'])) {
|
||||
$connectData['SERVER'] = 'POOLED';
|
||||
}
|
||||
|
||||
return self::fromArray([
|
||||
'DESCRIPTION' => [
|
||||
'ADDRESS' => [
|
||||
'PROTOCOL' => $params['driverOptions']['protocol'] ?? 'TCP',
|
||||
'HOST' => $params['host'],
|
||||
'PORT' => $params['port'] ?? 1521,
|
||||
],
|
||||
'CONNECT_DATA' => $connectData,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/** @param mixed[] $params */
|
||||
private static function renderParams(array $params): string
|
||||
{
|
||||
$chunks = [];
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$string = self::renderValue($value);
|
||||
|
||||
if ($string === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$chunks[] = sprintf('(%s=%s)', $key, $string);
|
||||
}
|
||||
|
||||
return implode('', $chunks);
|
||||
}
|
||||
|
||||
private static function renderValue(mixed $value): string
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return self::renderParams($value);
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
}
|
||||
}
|
||||
57
backend/vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php
vendored
Normal file
57
backend/vendor/doctrine/dbal/src/Driver/AbstractPostgreSQLDriver.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\Exception\InvalidPlatformVersion;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQL120Platform;
|
||||
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function preg_match;
|
||||
use function version_compare;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for PostgreSQL based drivers.
|
||||
*/
|
||||
abstract class AbstractPostgreSQLDriver implements Driver
|
||||
{
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): PostgreSQLPlatform
|
||||
{
|
||||
$version = $versionProvider->getServerVersion();
|
||||
|
||||
if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts) !== 1) {
|
||||
throw InvalidPlatformVersion::new(
|
||||
$version,
|
||||
'<major_version>.<minor_version>.<patch_version>',
|
||||
);
|
||||
}
|
||||
|
||||
$majorVersion = $versionParts['major'];
|
||||
$minorVersion = $versionParts['minor'] ?? 0;
|
||||
$patchVersion = $versionParts['patch'] ?? 0;
|
||||
$version = $majorVersion . '.' . $minorVersion . '.' . $patchVersion;
|
||||
|
||||
if (version_compare($version, '12.0', '>=')) {
|
||||
return new PostgreSQL120Platform();
|
||||
}
|
||||
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/6495',
|
||||
'Support for Postgres < 12 is deprecated and will be removed in DBAL 5',
|
||||
);
|
||||
|
||||
return new PostgreSQLPlatform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
}
|
||||
27
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver.php
vendored
Normal file
27
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\SQLSrv\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\SQLServerPlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for Microsoft SQL Server based drivers.
|
||||
*/
|
||||
abstract class AbstractSQLServerDriver implements Driver
|
||||
{
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): SQLServerPlatform
|
||||
{
|
||||
return new SQLServerPlatform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
}
|
||||
16
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php
vendored
Normal file
16
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/** @internal */
|
||||
final class PortWithoutHost extends AbstractException
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
return new self('Connection port specified without the host');
|
||||
}
|
||||
}
|
||||
27
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver.php
vendored
Normal file
27
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter as ExceptionConverterInterface;
|
||||
use Doctrine\DBAL\Driver\API\SQLite\ExceptionConverter;
|
||||
use Doctrine\DBAL\Platforms\SQLitePlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/**
|
||||
* Abstract base implementation of the {@see Driver} interface for SQLite based drivers.
|
||||
*/
|
||||
abstract class AbstractSQLiteDriver implements Driver
|
||||
{
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): SQLitePlatform
|
||||
{
|
||||
return new SQLitePlatform();
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverterInterface
|
||||
{
|
||||
return new ExceptionConverter();
|
||||
}
|
||||
}
|
||||
33
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver/Middleware/EnableForeignKeys.php
vendored
Normal file
33
backend/vendor/doctrine/dbal/src/Driver/AbstractSQLiteDriver/Middleware/EnableForeignKeys.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\AbstractSQLiteDriver\Middleware;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\Driver\Middleware;
|
||||
use Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware;
|
||||
use SensitiveParameter;
|
||||
|
||||
final class EnableForeignKeys implements Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver
|
||||
{
|
||||
return new class ($driver) extends AbstractDriverMiddleware {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): Connection {
|
||||
$connection = parent::connect($params);
|
||||
|
||||
$connection->exec('PRAGMA foreign_keys=ON');
|
||||
|
||||
return $connection;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
93
backend/vendor/doctrine/dbal/src/Driver/Connection.php
vendored
Normal file
93
backend/vendor/doctrine/dbal/src/Driver/Connection.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
|
||||
/**
|
||||
* Connection interface.
|
||||
* Driver connections must implement this interface.
|
||||
*/
|
||||
interface Connection extends ServerVersionProvider
|
||||
{
|
||||
/**
|
||||
* Prepares a statement for execution and returns a Statement object.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function prepare(string $sql): Statement;
|
||||
|
||||
/**
|
||||
* Executes an SQL statement, returning a result set as a Statement object.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function query(string $sql): Result;
|
||||
|
||||
/**
|
||||
* Quotes a string for use in a query.
|
||||
*
|
||||
* The usage of this method is discouraged. Use prepared statements
|
||||
* or {@see AbstractPlatform::quoteStringLiteral()} instead.
|
||||
*/
|
||||
public function quote(string $value): string;
|
||||
|
||||
/**
|
||||
* Executes an SQL statement and return the number of affected rows.
|
||||
* If the number of affected rows is greater than the maximum int value (PHP_INT_MAX),
|
||||
* the number of affected rows may be returned as a string.
|
||||
*
|
||||
* @return int|numeric-string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function exec(string $sql): int|string;
|
||||
|
||||
/**
|
||||
* Returns the ID of the last inserted row.
|
||||
*
|
||||
* This method returns an integer or a string representing the value of the auto-increment column
|
||||
* from the last row inserted into the database, if any, or throws an exception if a value cannot be returned,
|
||||
* in particular when:
|
||||
*
|
||||
* - the driver does not support identity columns;
|
||||
* - the last statement dit not return an identity (caution: see note below).
|
||||
*
|
||||
* Note: if the last statement was not an INSERT to an autoincrement column, this method MAY return an ID from a
|
||||
* previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always call this method right after
|
||||
* executing an INSERT statement.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function lastInsertId(): int|string;
|
||||
|
||||
/**
|
||||
* Initiates a transaction.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function beginTransaction(): void;
|
||||
|
||||
/**
|
||||
* Commits a transaction.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function commit(): void;
|
||||
|
||||
/**
|
||||
* Rolls back the current transaction, as initiated by beginTransaction().
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function rollBack(): void;
|
||||
|
||||
/**
|
||||
* Provides access to the native database connection.
|
||||
*
|
||||
* @return resource|object
|
||||
*/
|
||||
public function getNativeConnection();
|
||||
}
|
||||
23
backend/vendor/doctrine/dbal/src/Driver/Exception.php
vendored
Normal file
23
backend/vendor/doctrine/dbal/src/Driver/Exception.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Contract for a driver exception.
|
||||
*
|
||||
* Driver exceptions provide the SQLSTATE of the driver
|
||||
* and the driver specific error code at the time the error occurred.
|
||||
*/
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
/**
|
||||
* Returns the SQLSTATE the driver was in at the time the error occurred.
|
||||
*
|
||||
* Returns null if the driver does not provide a SQLSTATE for the error occurred.
|
||||
*/
|
||||
public function getSQLState(): ?string;
|
||||
}
|
||||
17
backend/vendor/doctrine/dbal/src/Driver/Exception/IdentityColumnsNotSupported.php
vendored
Normal file
17
backend/vendor/doctrine/dbal/src/Driver/Exception/IdentityColumnsNotSupported.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use Throwable;
|
||||
|
||||
/** @internal */
|
||||
final class IdentityColumnsNotSupported extends AbstractException
|
||||
{
|
||||
public static function new(?Throwable $previous = null): self
|
||||
{
|
||||
return new self('The driver does not support identity columns.', null, 0, $previous);
|
||||
}
|
||||
}
|
||||
17
backend/vendor/doctrine/dbal/src/Driver/Exception/NoIdentityValue.php
vendored
Normal file
17
backend/vendor/doctrine/dbal/src/Driver/Exception/NoIdentityValue.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use Throwable;
|
||||
|
||||
/** @internal */
|
||||
final class NoIdentityValue extends AbstractException
|
||||
{
|
||||
public static function new(?Throwable $previous = null): self
|
||||
{
|
||||
return new self('No identity value was generated by the last statement.', null, 0, $previous);
|
||||
}
|
||||
}
|
||||
69
backend/vendor/doctrine/dbal/src/Driver/FetchUtils.php
vendored
Normal file
69
backend/vendor/doctrine/dbal/src/Driver/FetchUtils.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
/** @internal */
|
||||
final class FetchUtils
|
||||
{
|
||||
/** @throws Exception */
|
||||
public static function fetchOne(Result $result): mixed
|
||||
{
|
||||
$row = $result->fetchNumeric();
|
||||
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<list<mixed>>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function fetchAllNumeric(Result $result): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
while (($row = $result->fetchNumeric()) !== false) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string,mixed>>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function fetchAllAssociative(Result $result): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
while (($row = $result->fetchAssociative()) !== false) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function fetchFirstColumn(Result $result): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
while (($row = $result->fetchOne()) !== false) {
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
}
|
||||
131
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php
vendored
Normal file
131
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Connection.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
|
||||
use Doctrine\DBAL\Driver\Exception\NoIdentityValue;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionError;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
|
||||
use stdClass;
|
||||
|
||||
use function assert;
|
||||
use function db2_autocommit;
|
||||
use function db2_commit;
|
||||
use function db2_escape_string;
|
||||
use function db2_exec;
|
||||
use function db2_last_insert_id;
|
||||
use function db2_num_rows;
|
||||
use function db2_prepare;
|
||||
use function db2_rollback;
|
||||
use function db2_server_info;
|
||||
use function error_get_last;
|
||||
|
||||
use const DB2_AUTOCOMMIT_OFF;
|
||||
use const DB2_AUTOCOMMIT_ON;
|
||||
|
||||
final class Connection implements ConnectionInterface
|
||||
{
|
||||
/**
|
||||
* @internal The connection can be only instantiated by its driver.
|
||||
*
|
||||
* @param resource $connection
|
||||
*/
|
||||
public function __construct(private readonly mixed $connection)
|
||||
{
|
||||
}
|
||||
|
||||
public function getServerVersion(): string
|
||||
{
|
||||
$serverInfo = db2_server_info($this->connection);
|
||||
assert($serverInfo instanceof stdClass);
|
||||
|
||||
return $serverInfo->DBMS_VER;
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
$stmt = @db2_prepare($this->connection, $sql);
|
||||
|
||||
if ($stmt === false) {
|
||||
throw PrepareFailed::new(error_get_last());
|
||||
}
|
||||
|
||||
return new Statement($stmt);
|
||||
}
|
||||
|
||||
public function query(string $sql): Result
|
||||
{
|
||||
return $this->prepare($sql)->execute();
|
||||
}
|
||||
|
||||
public function quote(string $value): string
|
||||
{
|
||||
return "'" . db2_escape_string($value) . "'";
|
||||
}
|
||||
|
||||
public function exec(string $sql): int|string
|
||||
{
|
||||
$stmt = @db2_exec($this->connection, $sql);
|
||||
|
||||
if ($stmt === false) {
|
||||
throw StatementError::new();
|
||||
}
|
||||
|
||||
$numRows = db2_num_rows($stmt);
|
||||
|
||||
if ($numRows === false) {
|
||||
throw StatementError::new();
|
||||
}
|
||||
|
||||
return $numRows;
|
||||
}
|
||||
|
||||
public function lastInsertId(): string
|
||||
{
|
||||
$lastInsertId = db2_last_insert_id($this->connection);
|
||||
|
||||
if ($lastInsertId === null) {
|
||||
throw NoIdentityValue::new();
|
||||
}
|
||||
|
||||
return $lastInsertId;
|
||||
}
|
||||
|
||||
public function beginTransaction(): void
|
||||
{
|
||||
if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_OFF) !== true) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
public function commit(): void
|
||||
{
|
||||
if (! db2_commit($this->connection)) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
|
||||
if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_ON) !== true) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
public function rollBack(): void
|
||||
{
|
||||
if (! db2_rollback($this->connection)) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
|
||||
if (db2_autocommit($this->connection, DB2_AUTOCOMMIT_ON) !== true) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
}
|
||||
|
||||
/** @return resource */
|
||||
public function getNativeConnection()
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
}
|
||||
80
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php
vendored
Normal file
80
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/DataSourceName.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use SensitiveParameter;
|
||||
|
||||
use function implode;
|
||||
use function sprintf;
|
||||
use function str_contains;
|
||||
|
||||
/**
|
||||
* Db2 DSN
|
||||
*/
|
||||
final class DataSourceName
|
||||
{
|
||||
private function __construct(
|
||||
#[SensitiveParameter]
|
||||
private readonly string $string,
|
||||
) {
|
||||
}
|
||||
|
||||
public function toString(): string
|
||||
{
|
||||
return $this->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from an array representation
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
*/
|
||||
public static function fromArray(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): self {
|
||||
$chunks = [];
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$chunks[] = sprintf('%s=%s', $key, $value);
|
||||
}
|
||||
|
||||
return new self(implode(';', $chunks));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object from the given DBAL connection parameters.
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
*/
|
||||
public static function fromConnectionParameters(#[SensitiveParameter]
|
||||
array $params,): self
|
||||
{
|
||||
if (isset($params['dbname']) && str_contains($params['dbname'], '=')) {
|
||||
return new self($params['dbname']);
|
||||
}
|
||||
|
||||
$dsnParams = [];
|
||||
|
||||
foreach (
|
||||
[
|
||||
'host' => 'HOSTNAME',
|
||||
'port' => 'PORT',
|
||||
'protocol' => 'PROTOCOL',
|
||||
'dbname' => 'DATABASE',
|
||||
'user' => 'UID',
|
||||
'password' => 'PWD',
|
||||
] as $dbalParam => $dsnParam
|
||||
) {
|
||||
if (! isset($params[$dbalParam])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$dsnParams[$dsnParam] = $params[$dbalParam];
|
||||
}
|
||||
|
||||
return self::fromArray($dsnParams);
|
||||
}
|
||||
}
|
||||
41
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php
vendored
Normal file
41
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Driver.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractDB2Driver;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed;
|
||||
use SensitiveParameter;
|
||||
|
||||
use function db2_connect;
|
||||
use function db2_pconnect;
|
||||
|
||||
final class Driver extends AbstractDB2Driver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): Connection {
|
||||
$dataSourceName = DataSourceName::fromConnectionParameters($params)->toString();
|
||||
|
||||
$username = $params['user'] ?? '';
|
||||
$password = $params['password'] ?? '';
|
||||
$driverOptions = $params['driverOptions'] ?? [];
|
||||
|
||||
if (! empty($params['persistent'])) {
|
||||
$connection = db2_pconnect($dataSourceName, $username, $password, $driverOptions);
|
||||
} else {
|
||||
$connection = db2_connect($dataSourceName, $username, $password, $driverOptions);
|
||||
}
|
||||
|
||||
if ($connection === false) {
|
||||
throw ConnectionFailed::new();
|
||||
}
|
||||
|
||||
return new Connection($connection);
|
||||
}
|
||||
}
|
||||
23
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
vendored
Normal file
23
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/** @internal */
|
||||
final class CannotCopyStreamToStream extends AbstractException
|
||||
{
|
||||
/** @phpstan-param array{message: string, ...}|null $error */
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
$message = 'Could not copy source stream to temporary file';
|
||||
|
||||
if ($error !== null) {
|
||||
$message .= ': ' . $error['message'];
|
||||
}
|
||||
|
||||
return new self($message);
|
||||
}
|
||||
}
|
||||
23
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
vendored
Normal file
23
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/** @internal */
|
||||
final class CannotCreateTemporaryFile extends AbstractException
|
||||
{
|
||||
/** @phpstan-param array{message: string, ...}|null $error */
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
$message = 'Could not create temporary file';
|
||||
|
||||
if ($error !== null) {
|
||||
$message .= ': ' . $error['message'];
|
||||
}
|
||||
|
||||
return new self($message);
|
||||
}
|
||||
}
|
||||
25
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionError.php
vendored
Normal file
25
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionError.php
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_conn_error;
|
||||
use function db2_conn_errormsg;
|
||||
|
||||
/** @internal */
|
||||
final class ConnectionError extends AbstractException
|
||||
{
|
||||
/** @param resource $connection */
|
||||
public static function new($connection): self
|
||||
{
|
||||
$message = db2_conn_errormsg($connection);
|
||||
$sqlState = db2_conn_error($connection);
|
||||
|
||||
return Factory::create($message, static function (int $code) use ($message, $sqlState): self {
|
||||
return new self($message, $sqlState, $code);
|
||||
});
|
||||
}
|
||||
}
|
||||
24
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionFailed.php
vendored
Normal file
24
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/ConnectionFailed.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_conn_error;
|
||||
use function db2_conn_errormsg;
|
||||
|
||||
/** @internal */
|
||||
final class ConnectionFailed extends AbstractException
|
||||
{
|
||||
public static function new(): self
|
||||
{
|
||||
$message = db2_conn_errormsg();
|
||||
$sqlState = db2_conn_error();
|
||||
|
||||
return Factory::create($message, static function (int $code) use ($message, $sqlState): self {
|
||||
return new self($message, $sqlState, $code);
|
||||
});
|
||||
}
|
||||
}
|
||||
31
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/Factory.php
vendored
Normal file
31
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/Factory.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function preg_match;
|
||||
|
||||
/** @internal */
|
||||
final class Factory
|
||||
{
|
||||
/**
|
||||
* @param callable(int): T $constructor
|
||||
*
|
||||
* @return T
|
||||
*
|
||||
* @template T of AbstractException
|
||||
*/
|
||||
public static function create(string $message, callable $constructor): AbstractException
|
||||
{
|
||||
$code = 0;
|
||||
|
||||
if (preg_match('/ SQL(\d+)N /', $message, $matches) === 1) {
|
||||
$code = -(int) $matches[1];
|
||||
}
|
||||
|
||||
return $constructor($code);
|
||||
}
|
||||
}
|
||||
21
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/PrepareFailed.php
vendored
Normal file
21
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/PrepareFailed.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/** @internal */
|
||||
final class PrepareFailed extends AbstractException
|
||||
{
|
||||
/** @phpstan-param array{message: string, ...}|null $error */
|
||||
public static function new(?array $error): self
|
||||
{
|
||||
if ($error === null) {
|
||||
return new self('Unknown error');
|
||||
}
|
||||
|
||||
return new self($error['message']);
|
||||
}
|
||||
}
|
||||
30
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/StatementError.php
vendored
Normal file
30
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Exception/StatementError.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function db2_stmt_error;
|
||||
use function db2_stmt_errormsg;
|
||||
|
||||
/** @internal */
|
||||
final class StatementError extends AbstractException
|
||||
{
|
||||
/** @param resource|null $statement */
|
||||
public static function new($statement = null): self
|
||||
{
|
||||
if ($statement !== null) {
|
||||
$message = db2_stmt_errormsg($statement);
|
||||
$sqlState = db2_stmt_error($statement);
|
||||
} else {
|
||||
$message = db2_stmt_errormsg();
|
||||
$sqlState = db2_stmt_error();
|
||||
}
|
||||
|
||||
return Factory::create($message, static function (int $code) use ($message, $sqlState): self {
|
||||
return new self($message, $sqlState, $code);
|
||||
});
|
||||
}
|
||||
}
|
||||
119
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Result.php
vendored
Normal file
119
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Result.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
|
||||
use Doctrine\DBAL\Driver\Result as ResultInterface;
|
||||
use Doctrine\DBAL\Exception\InvalidColumnIndex;
|
||||
|
||||
use function db2_fetch_array;
|
||||
use function db2_fetch_assoc;
|
||||
use function db2_field_name;
|
||||
use function db2_free_result;
|
||||
use function db2_num_fields;
|
||||
use function db2_num_rows;
|
||||
use function db2_stmt_error;
|
||||
|
||||
final class Result implements ResultInterface
|
||||
{
|
||||
/**
|
||||
* @internal The result can be only instantiated by its driver connection or statement.
|
||||
*
|
||||
* @param resource $statement
|
||||
*/
|
||||
public function __construct(private readonly mixed $statement)
|
||||
{
|
||||
}
|
||||
|
||||
public function fetchNumeric(): array|false
|
||||
{
|
||||
$row = @db2_fetch_array($this->statement);
|
||||
|
||||
if ($row === false && db2_stmt_error($this->statement) !== '02000') {
|
||||
throw StatementError::new($this->statement);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function fetchAssociative(): array|false
|
||||
{
|
||||
$row = @db2_fetch_assoc($this->statement);
|
||||
|
||||
if ($row === false && db2_stmt_error($this->statement) !== '02000') {
|
||||
throw StatementError::new($this->statement);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function fetchOne(): mixed
|
||||
{
|
||||
return FetchUtils::fetchOne($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return FetchUtils::fetchAllNumeric($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return FetchUtils::fetchAllAssociative($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return FetchUtils::fetchFirstColumn($this);
|
||||
}
|
||||
|
||||
public function rowCount(): int
|
||||
{
|
||||
$numRows = @db2_num_rows($this->statement);
|
||||
|
||||
if ($numRows === false) {
|
||||
throw StatementError::new($this->statement);
|
||||
}
|
||||
|
||||
return $numRows;
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
$count = db2_num_fields($this->statement);
|
||||
|
||||
if ($count !== false) {
|
||||
return $count;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getColumnName(int $index): string
|
||||
{
|
||||
$name = db2_field_name($this->statement, $index);
|
||||
|
||||
if ($name === false) {
|
||||
throw InvalidColumnIndex::new($index);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
db2_free_result($this->statement);
|
||||
}
|
||||
}
|
||||
157
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php
vendored
Normal file
157
backend/vendor/doctrine/dbal/src/Driver/IBMDB2/Statement.php
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\IBMDB2;
|
||||
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile;
|
||||
use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError;
|
||||
use Doctrine\DBAL\Driver\Statement as StatementInterface;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
use function assert;
|
||||
use function db2_bind_param;
|
||||
use function db2_execute;
|
||||
use function error_get_last;
|
||||
use function fclose;
|
||||
use function is_int;
|
||||
use function is_resource;
|
||||
use function stream_copy_to_stream;
|
||||
use function stream_get_meta_data;
|
||||
use function tmpfile;
|
||||
|
||||
use const DB2_BINARY;
|
||||
use const DB2_CHAR;
|
||||
use const DB2_LONG;
|
||||
use const DB2_PARAM_FILE;
|
||||
use const DB2_PARAM_IN;
|
||||
|
||||
final class Statement implements StatementInterface
|
||||
{
|
||||
/** @var mixed[] */
|
||||
private array $parameters = [];
|
||||
|
||||
/**
|
||||
* Map of LOB parameter positions to the tuples containing reference to the variable bound to the driver statement
|
||||
* and the temporary file handle bound to the underlying statement
|
||||
*
|
||||
* @var array<int,string|resource|null>
|
||||
*/
|
||||
private array $lobs = [];
|
||||
|
||||
/**
|
||||
* @internal The statement can be only instantiated by its driver connection.
|
||||
*
|
||||
* @param resource $stmt
|
||||
*/
|
||||
public function __construct(private readonly mixed $stmt)
|
||||
{
|
||||
}
|
||||
|
||||
public function bindValue(int|string $param, mixed $value, ParameterType $type): void
|
||||
{
|
||||
assert(is_int($param));
|
||||
|
||||
switch ($type) {
|
||||
case ParameterType::INTEGER:
|
||||
$this->bind($param, $value, DB2_PARAM_IN, DB2_LONG);
|
||||
break;
|
||||
|
||||
case ParameterType::LARGE_OBJECT:
|
||||
$this->lobs[$param] = &$value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->bind($param, $value, DB2_PARAM_IN, DB2_CHAR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** @throws Exception */
|
||||
private function bind(int $position, mixed &$variable, int $parameterType, int $dataType): void
|
||||
{
|
||||
$this->parameters[$position] =& $variable;
|
||||
|
||||
if (! db2_bind_param($this->stmt, $position, '', $parameterType, $dataType)) {
|
||||
throw StatementError::new($this->stmt);
|
||||
}
|
||||
}
|
||||
|
||||
public function execute(): Result
|
||||
{
|
||||
$handles = $this->bindLobs();
|
||||
|
||||
$result = @db2_execute($this->stmt, $this->parameters);
|
||||
|
||||
foreach ($handles as $handle) {
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
$this->lobs = [];
|
||||
|
||||
if ($result === false) {
|
||||
throw StatementError::new($this->stmt);
|
||||
}
|
||||
|
||||
return new Result($this->stmt);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<resource>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function bindLobs(): array
|
||||
{
|
||||
$handles = [];
|
||||
|
||||
foreach ($this->lobs as $param => $value) {
|
||||
if (is_resource($value)) {
|
||||
$handle = $handles[] = $this->createTemporaryFile();
|
||||
$path = stream_get_meta_data($handle)['uri'] ?? null;
|
||||
assert($path !== null);
|
||||
|
||||
$this->copyStreamToStream($value, $handle);
|
||||
|
||||
$this->bind($param, $path, DB2_PARAM_FILE, DB2_BINARY);
|
||||
} else {
|
||||
$this->bind($param, $value, DB2_PARAM_IN, DB2_CHAR);
|
||||
}
|
||||
|
||||
unset($value);
|
||||
}
|
||||
|
||||
return $handles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function createTemporaryFile()
|
||||
{
|
||||
$handle = @tmpfile();
|
||||
|
||||
if ($handle === false) {
|
||||
throw CannotCreateTemporaryFile::new(error_get_last());
|
||||
}
|
||||
|
||||
return $handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param resource $source
|
||||
* @param resource $target
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function copyStreamToStream($source, $target): void
|
||||
{
|
||||
if (@stream_copy_to_stream($source, $target) === false) {
|
||||
throw CannotCopyStreamToStream::new(error_get_last());
|
||||
}
|
||||
}
|
||||
}
|
||||
12
backend/vendor/doctrine/dbal/src/Driver/Middleware.php
vendored
Normal file
12
backend/vendor/doctrine/dbal/src/Driver/Middleware.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
|
||||
interface Middleware
|
||||
{
|
||||
public function wrap(Driver $driver): Driver;
|
||||
}
|
||||
69
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php
vendored
Normal file
69
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractConnectionMiddleware.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Middleware;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
|
||||
abstract class AbstractConnectionMiddleware implements Connection
|
||||
{
|
||||
public function __construct(private readonly Connection $wrappedConnection)
|
||||
{
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
return $this->wrappedConnection->prepare($sql);
|
||||
}
|
||||
|
||||
public function query(string $sql): Result
|
||||
{
|
||||
return $this->wrappedConnection->query($sql);
|
||||
}
|
||||
|
||||
public function quote(string $value): string
|
||||
{
|
||||
return $this->wrappedConnection->quote($value);
|
||||
}
|
||||
|
||||
public function exec(string $sql): int|string
|
||||
{
|
||||
return $this->wrappedConnection->exec($sql);
|
||||
}
|
||||
|
||||
public function lastInsertId(): int|string
|
||||
{
|
||||
return $this->wrappedConnection->lastInsertId();
|
||||
}
|
||||
|
||||
public function beginTransaction(): void
|
||||
{
|
||||
$this->wrappedConnection->beginTransaction();
|
||||
}
|
||||
|
||||
public function commit(): void
|
||||
{
|
||||
$this->wrappedConnection->commit();
|
||||
}
|
||||
|
||||
public function rollBack(): void
|
||||
{
|
||||
$this->wrappedConnection->rollBack();
|
||||
}
|
||||
|
||||
public function getServerVersion(): string
|
||||
{
|
||||
return $this->wrappedConnection->getServerVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getNativeConnection()
|
||||
{
|
||||
return $this->wrappedConnection->getNativeConnection();
|
||||
}
|
||||
}
|
||||
39
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php
vendored
Normal file
39
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Middleware;
|
||||
|
||||
use Doctrine\DBAL\Driver;
|
||||
use Doctrine\DBAL\Driver\API\ExceptionConverter;
|
||||
use Doctrine\DBAL\Driver\Connection as DriverConnection;
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\ServerVersionProvider;
|
||||
use SensitiveParameter;
|
||||
|
||||
abstract class AbstractDriverMiddleware implements Driver
|
||||
{
|
||||
public function __construct(private readonly Driver $wrappedDriver)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): DriverConnection {
|
||||
return $this->wrappedDriver->connect($params);
|
||||
}
|
||||
|
||||
public function getDatabasePlatform(ServerVersionProvider $versionProvider): AbstractPlatform
|
||||
{
|
||||
return $this->wrappedDriver->getDatabasePlatform($versionProvider);
|
||||
}
|
||||
|
||||
public function getExceptionConverter(): ExceptionConverter
|
||||
{
|
||||
return $this->wrappedDriver->getExceptionConverter();
|
||||
}
|
||||
}
|
||||
85
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php
vendored
Normal file
85
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractResultMiddleware.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Middleware;
|
||||
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use LogicException;
|
||||
|
||||
use function get_debug_type;
|
||||
use function method_exists;
|
||||
use function sprintf;
|
||||
|
||||
abstract class AbstractResultMiddleware implements Result
|
||||
{
|
||||
public function __construct(private readonly Result $wrappedResult)
|
||||
{
|
||||
}
|
||||
|
||||
public function fetchNumeric(): array|false
|
||||
{
|
||||
return $this->wrappedResult->fetchNumeric();
|
||||
}
|
||||
|
||||
public function fetchAssociative(): array|false
|
||||
{
|
||||
return $this->wrappedResult->fetchAssociative();
|
||||
}
|
||||
|
||||
public function fetchOne(): mixed
|
||||
{
|
||||
return $this->wrappedResult->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return $this->wrappedResult->fetchAllNumeric();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return $this->wrappedResult->fetchAllAssociative();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return $this->wrappedResult->fetchFirstColumn();
|
||||
}
|
||||
|
||||
public function rowCount(): int|string
|
||||
{
|
||||
return $this->wrappedResult->rowCount();
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
return $this->wrappedResult->columnCount();
|
||||
}
|
||||
|
||||
public function getColumnName(int $index): string
|
||||
{
|
||||
if (! method_exists($this->wrappedResult, 'getColumnName')) {
|
||||
throw new LogicException(sprintf(
|
||||
'The driver result %s does not support accessing the column name.',
|
||||
get_debug_type($this->wrappedResult),
|
||||
));
|
||||
}
|
||||
|
||||
return $this->wrappedResult->getColumnName($index);
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
$this->wrappedResult->free();
|
||||
}
|
||||
}
|
||||
26
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php
vendored
Normal file
26
backend/vendor/doctrine/dbal/src/Driver/Middleware/AbstractStatementMiddleware.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Middleware;
|
||||
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
|
||||
abstract class AbstractStatementMiddleware implements Statement
|
||||
{
|
||||
public function __construct(private readonly Statement $wrappedStatement)
|
||||
{
|
||||
}
|
||||
|
||||
public function bindValue(int|string $param, mixed $value, ParameterType $type): void
|
||||
{
|
||||
$this->wrappedStatement->bindValue($param, $value, $type);
|
||||
}
|
||||
|
||||
public function execute(): Result
|
||||
{
|
||||
return $this->wrappedStatement->execute();
|
||||
}
|
||||
}
|
||||
118
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php
vendored
Normal file
118
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Connection.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
|
||||
final class Connection implements ConnectionInterface
|
||||
{
|
||||
/**
|
||||
* Name of the option to set connection flags
|
||||
*/
|
||||
public const OPTION_FLAGS = 'flags';
|
||||
|
||||
/** @internal The connection can be only instantiated by its driver. */
|
||||
public function __construct(private readonly mysqli $connection)
|
||||
{
|
||||
}
|
||||
|
||||
public function getServerVersion(): string
|
||||
{
|
||||
return $this->connection->get_server_info();
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
try {
|
||||
$stmt = $this->connection->prepare($sql);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionError::upcast($e);
|
||||
}
|
||||
|
||||
if ($stmt === false) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
|
||||
return new Statement($stmt);
|
||||
}
|
||||
|
||||
public function query(string $sql): Result
|
||||
{
|
||||
return $this->prepare($sql)->execute();
|
||||
}
|
||||
|
||||
public function quote(string $value): string
|
||||
{
|
||||
return "'" . $this->connection->escape_string($value) . "'";
|
||||
}
|
||||
|
||||
public function exec(string $sql): int|string
|
||||
{
|
||||
try {
|
||||
$result = $this->connection->query($sql);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionError::upcast($e);
|
||||
}
|
||||
|
||||
if ($result === false) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
|
||||
return $this->connection->affected_rows;
|
||||
}
|
||||
|
||||
public function lastInsertId(): int|string
|
||||
{
|
||||
$lastInsertId = $this->connection->insert_id;
|
||||
|
||||
if ($lastInsertId === 0) {
|
||||
throw Exception\NoIdentityValue::new();
|
||||
}
|
||||
|
||||
return $this->connection->insert_id;
|
||||
}
|
||||
|
||||
public function beginTransaction(): void
|
||||
{
|
||||
try {
|
||||
if (! $this->connection->begin_transaction()) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionError::upcast($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function commit(): void
|
||||
{
|
||||
try {
|
||||
if (! $this->connection->commit()) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionError::upcast($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function rollBack(): void
|
||||
{
|
||||
try {
|
||||
if (! $this->connection->rollback()) {
|
||||
throw ConnectionError::new($this->connection);
|
||||
}
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionError::upcast($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function getNativeConnection(): mysqli
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
}
|
||||
117
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php
vendored
Normal file
117
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Driver.php
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionFailed;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\HostRequired;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer\Charset;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer\Options;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer\Secure;
|
||||
use Generator;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
use SensitiveParameter;
|
||||
|
||||
final class Driver extends AbstractMySQLDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): Connection {
|
||||
if (! empty($params['persistent'])) {
|
||||
if (! isset($params['host'])) {
|
||||
throw HostRequired::forPersistentConnection();
|
||||
}
|
||||
|
||||
$host = 'p:' . $params['host'];
|
||||
} else {
|
||||
$host = $params['host'] ?? '';
|
||||
}
|
||||
|
||||
$connection = new mysqli();
|
||||
|
||||
foreach ($this->compilePreInitializers($params) as $initializer) {
|
||||
$initializer->initialize($connection);
|
||||
}
|
||||
|
||||
try {
|
||||
$success = @$connection->real_connect(
|
||||
$host,
|
||||
$params['user'] ?? '',
|
||||
$params['password'] ?? '',
|
||||
$params['dbname'] ?? '',
|
||||
$params['port'] ?? 0,
|
||||
$params['unix_socket'] ?? '',
|
||||
$params['driverOptions'][Connection::OPTION_FLAGS] ?? 0,
|
||||
);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw ConnectionFailed::upcast($e);
|
||||
}
|
||||
|
||||
if (! $success) {
|
||||
throw ConnectionFailed::new($connection);
|
||||
}
|
||||
|
||||
foreach ($this->compilePostInitializers($params) as $initializer) {
|
||||
$initializer->initialize($connection);
|
||||
}
|
||||
|
||||
return new Connection($connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
*
|
||||
* @return Generator<int, Initializer>
|
||||
*/
|
||||
private function compilePreInitializers(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): Generator {
|
||||
unset($params['driverOptions'][Connection::OPTION_FLAGS]);
|
||||
|
||||
if (isset($params['driverOptions']) && $params['driverOptions'] !== []) {
|
||||
yield new Options($params['driverOptions']);
|
||||
}
|
||||
|
||||
if (
|
||||
! isset($params['ssl_key']) &&
|
||||
! isset($params['ssl_cert']) &&
|
||||
! isset($params['ssl_ca']) &&
|
||||
! isset($params['ssl_capath']) &&
|
||||
! isset($params['ssl_cipher'])
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield new Secure(
|
||||
$params['ssl_key'] ?? '',
|
||||
$params['ssl_cert'] ?? '',
|
||||
$params['ssl_ca'] ?? '',
|
||||
$params['ssl_capath'] ?? '',
|
||||
$params['ssl_cipher'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $params
|
||||
*
|
||||
* @return Generator<int, Initializer>
|
||||
*/
|
||||
private function compilePostInitializers(
|
||||
#[SensitiveParameter]
|
||||
array $params,
|
||||
): Generator {
|
||||
if (! isset($params['charset'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield new Charset($params['charset']);
|
||||
}
|
||||
}
|
||||
26
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php
vendored
Normal file
26
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionError.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
use ReflectionProperty;
|
||||
|
||||
/** @internal */
|
||||
final class ConnectionError extends AbstractException
|
||||
{
|
||||
public static function new(mysqli $connection): self
|
||||
{
|
||||
return new self($connection->error, $connection->sqlstate, $connection->errno);
|
||||
}
|
||||
|
||||
public static function upcast(mysqli_sql_exception $exception): self
|
||||
{
|
||||
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
|
||||
|
||||
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
31
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php
vendored
Normal file
31
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/ConnectionFailed.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function assert;
|
||||
|
||||
/** @internal */
|
||||
final class ConnectionFailed extends AbstractException
|
||||
{
|
||||
public static function new(mysqli $connection): self
|
||||
{
|
||||
$error = $connection->connect_error;
|
||||
assert($error !== null);
|
||||
|
||||
return new self($error, 'HY000', $connection->connect_errno);
|
||||
}
|
||||
|
||||
public static function upcast(mysqli_sql_exception $exception): self
|
||||
{
|
||||
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
|
||||
|
||||
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
18
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php
vendored
Normal file
18
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/FailedReadingStreamOffset.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @internal */
|
||||
final class FailedReadingStreamOffset extends AbstractException
|
||||
{
|
||||
public static function new(int $parameter): self
|
||||
{
|
||||
return new self(sprintf('Failed reading the stream resource for parameter #%d.', $parameter));
|
||||
}
|
||||
}
|
||||
16
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/HostRequired.php
vendored
Normal file
16
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/HostRequired.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/** @internal */
|
||||
final class HostRequired extends AbstractException
|
||||
{
|
||||
public static function forPersistentConnection(): self
|
||||
{
|
||||
return new self('The "host" parameter is required for a persistent connection');
|
||||
}
|
||||
}
|
||||
37
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php
vendored
Normal file
37
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidCharset.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @internal */
|
||||
final class InvalidCharset extends AbstractException
|
||||
{
|
||||
public static function fromCharset(mysqli $connection, string $charset): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('Failed to set charset "%s": %s', $charset, $connection->error),
|
||||
$connection->sqlstate,
|
||||
$connection->errno,
|
||||
);
|
||||
}
|
||||
|
||||
public static function upcast(mysqli_sql_exception $exception, string $charset): self
|
||||
{
|
||||
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
|
||||
|
||||
return new self(
|
||||
sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()),
|
||||
$p->getValue($exception),
|
||||
$exception->getCode(),
|
||||
$exception,
|
||||
);
|
||||
}
|
||||
}
|
||||
20
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php
vendored
Normal file
20
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/InvalidOption.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @internal */
|
||||
final class InvalidOption extends AbstractException
|
||||
{
|
||||
public static function fromOption(int $option, mixed $value): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('Failed to set option %d with value "%s"', $option, $value),
|
||||
);
|
||||
}
|
||||
}
|
||||
20
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/NonStreamResourceUsedAsLargeObject.php
vendored
Normal file
20
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/NonStreamResourceUsedAsLargeObject.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @internal */
|
||||
final class NonStreamResourceUsedAsLargeObject extends AbstractException
|
||||
{
|
||||
public static function new(int $parameter): self
|
||||
{
|
||||
return new self(
|
||||
sprintf('The resource passed as a LARGE_OBJECT parameter #%d must be of type "stream"', $parameter),
|
||||
);
|
||||
}
|
||||
}
|
||||
26
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php
vendored
Normal file
26
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Exception/StatementError.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Exception;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
use mysqli_sql_exception;
|
||||
use mysqli_stmt;
|
||||
use ReflectionProperty;
|
||||
|
||||
/** @internal */
|
||||
final class StatementError extends AbstractException
|
||||
{
|
||||
public static function new(mysqli_stmt $statement): self
|
||||
{
|
||||
return new self($statement->error, $statement->sqlstate, $statement->errno);
|
||||
}
|
||||
|
||||
public static function upcast(mysqli_sql_exception $exception): self
|
||||
{
|
||||
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
|
||||
|
||||
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
14
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php
vendored
Normal file
14
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use mysqli;
|
||||
|
||||
interface Initializer
|
||||
{
|
||||
/** @throws Exception */
|
||||
public function initialize(mysqli $connection): void;
|
||||
}
|
||||
32
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Charset.php
vendored
Normal file
32
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Charset.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\InvalidCharset;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
use mysqli;
|
||||
use mysqli_sql_exception;
|
||||
|
||||
final class Charset implements Initializer
|
||||
{
|
||||
public function __construct(private readonly string $charset)
|
||||
{
|
||||
}
|
||||
|
||||
public function initialize(mysqli $connection): void
|
||||
{
|
||||
try {
|
||||
$success = $connection->set_charset($this->charset);
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw InvalidCharset::upcast($e, $this->charset);
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw InvalidCharset::fromCharset($connection, $this->charset);
|
||||
}
|
||||
}
|
||||
28
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php
vendored
Normal file
28
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Options.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\InvalidOption;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
use mysqli;
|
||||
|
||||
use function mysqli_options;
|
||||
|
||||
final class Options implements Initializer
|
||||
{
|
||||
/** @param array<int,mixed> $options */
|
||||
public function __construct(private readonly array $options)
|
||||
{
|
||||
}
|
||||
|
||||
public function initialize(mysqli $connection): void
|
||||
{
|
||||
foreach ($this->options as $option => $value) {
|
||||
if (! mysqli_options($connection, $option, $value)) {
|
||||
throw InvalidOption::fromOption($option, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php
vendored
Normal file
27
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Initializer/Secure.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
|
||||
use Doctrine\DBAL\Driver\Mysqli\Initializer;
|
||||
use mysqli;
|
||||
use SensitiveParameter;
|
||||
|
||||
final class Secure implements Initializer
|
||||
{
|
||||
public function __construct(
|
||||
#[SensitiveParameter]
|
||||
private readonly string $key,
|
||||
private readonly string $cert,
|
||||
private readonly string $ca,
|
||||
private readonly string $capath,
|
||||
private readonly string $cipher,
|
||||
) {
|
||||
}
|
||||
|
||||
public function initialize(mysqli $connection): void
|
||||
{
|
||||
$connection->ssl_set($this->key, $this->cert, $this->ca, $this->capath, $this->cipher);
|
||||
}
|
||||
}
|
||||
177
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Result.php
vendored
Normal file
177
backend/vendor/doctrine/dbal/src/Driver/Mysqli/Result.php
vendored
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\DBAL\Driver\Mysqli;
|
||||
|
||||
use Doctrine\DBAL\Driver\Exception;
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError;
|
||||
use Doctrine\DBAL\Driver\Result as ResultInterface;
|
||||
use Doctrine\DBAL\Exception\InvalidColumnIndex;
|
||||
use mysqli_sql_exception;
|
||||
use mysqli_stmt;
|
||||
|
||||
use function array_column;
|
||||
use function array_combine;
|
||||
use function array_fill;
|
||||
use function count;
|
||||
|
||||
final class Result implements ResultInterface
|
||||
{
|
||||
/**
|
||||
* Whether the statement result has columns. The property should be used only after the result metadata
|
||||
* has been fetched ({@see $metadataFetched}). Otherwise, the property value is undetermined.
|
||||
*/
|
||||
private readonly bool $hasColumns;
|
||||
|
||||
/**
|
||||
* Mapping of statement result column indexes to their names. The property should be used only
|
||||
* if the statement result has columns ({@see $hasColumns}). Otherwise, the property value is undetermined.
|
||||
*
|
||||
* @var array<int,string>
|
||||
*/
|
||||
private readonly array $columnNames;
|
||||
|
||||
/** @var mixed[] */
|
||||
private array $boundValues = [];
|
||||
|
||||
/**
|
||||
* @internal The result can be only instantiated by its driver connection or statement.
|
||||
*
|
||||
* @param Statement|null $statementReference Maintains a reference to the Statement that generated this result. This
|
||||
* ensures that the lifetime of the Statement is managed in conjunction
|
||||
* with its associated results, so they are destroyed together at the
|
||||
* appropriate time, see {@see Statement::__destruct()}.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly mysqli_stmt $statement,
|
||||
private ?Statement $statementReference = null, // @phpstan-ignore property.onlyWritten
|
||||
) {
|
||||
$meta = $statement->result_metadata();
|
||||
$this->hasColumns = $meta !== false;
|
||||
$this->columnNames = $meta !== false ? array_column($meta->fetch_fields(), 'name') : [];
|
||||
|
||||
if ($meta === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
$meta->free();
|
||||
|
||||
// Store result of every execution which has it. Otherwise it will be impossible
|
||||
// to execute a new statement in case if the previous one has non-fetched rows
|
||||
// @link http://dev.mysql.com/doc/refman/5.7/en/commands-out-of-sync.html
|
||||
$this->statement->store_result();
|
||||
|
||||
// Bind row values _after_ storing the result. Otherwise, if mysqli is compiled with libmysql,
|
||||
// it will have to allocate as much memory as it may be needed for the given column type
|
||||
// (e.g. for a LONGBLOB column it's 4 gigabytes)
|
||||
// @link https://bugs.php.net/bug.php?id=51386#1270673122
|
||||
//
|
||||
// Make sure that the values are bound after each execution. Otherwise, if free() has been
|
||||
// previously called on the result, the values are unbound making the statement unusable.
|
||||
//
|
||||
// It's also important that row values are bound after _each_ call to store_result(). Otherwise,
|
||||
// if mysqli is compiled with libmysql, subsequently fetched string values will get truncated
|
||||
// to the length of the ones fetched during the previous execution.
|
||||
$this->boundValues = array_fill(0, count($this->columnNames), null);
|
||||
|
||||
// The following is necessary as PHP cannot handle references to properties properly
|
||||
$refs = &$this->boundValues;
|
||||
|
||||
if (! $this->statement->bind_result(...$refs)) {
|
||||
throw StatementError::new($this->statement);
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchNumeric(): array|false
|
||||
{
|
||||
try {
|
||||
$ret = $this->statement->fetch();
|
||||
} catch (mysqli_sql_exception $e) {
|
||||
throw StatementError::upcast($e);
|
||||
}
|
||||
|
||||
if ($ret === false) {
|
||||
throw StatementError::new($this->statement);
|
||||
}
|
||||
|
||||
if ($ret === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ($this->boundValues as $v) {
|
||||
$values[] = $v;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function fetchAssociative(): array|false
|
||||
{
|
||||
$values = $this->fetchNumeric();
|
||||
|
||||
if ($values === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_combine($this->columnNames, $values);
|
||||
}
|
||||
|
||||
public function fetchOne(): mixed
|
||||
{
|
||||
return FetchUtils::fetchOne($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return FetchUtils::fetchAllNumeric($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return FetchUtils::fetchAllAssociative($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return FetchUtils::fetchFirstColumn($this);
|
||||
}
|
||||
|
||||
public function rowCount(): int|string
|
||||
{
|
||||
if ($this->hasColumns) {
|
||||
return $this->statement->num_rows;
|
||||
}
|
||||
|
||||
return $this->statement->affected_rows;
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
return $this->statement->field_count;
|
||||
}
|
||||
|
||||
public function getColumnName(int $index): string
|
||||
{
|
||||
return $this->columnNames[$index] ?? throw InvalidColumnIndex::new($index);
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
$this->statement->free_result();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user