Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
19
vendor/doctrine/annotations/LICENSE
vendored
Normal file
19
vendor/doctrine/annotations/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.
|
||||
24
vendor/doctrine/annotations/README.md
vendored
Normal file
24
vendor/doctrine/annotations/README.md
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
⚠️ PHP 8 introduced
|
||||
[attributes](https://www.php.net/manual/en/language.attributes.overview.php),
|
||||
which are a native replacement for annotations. As such, this library is
|
||||
considered feature complete, and should receive exclusively bugfixes and
|
||||
security fixes.
|
||||
|
||||
# Doctrine Annotations
|
||||
|
||||
[](https://github.com/doctrine/persistence/actions)
|
||||
[](https://www.versioneye.com/package/php--doctrine--annotations)
|
||||
[](https://www.versioneye.com/php/doctrine:annotations/references)
|
||||
[](https://packagist.org/packages/doctrine/annotations)
|
||||
[](https://packagist.org/packages/doctrine/annotations)
|
||||
|
||||
Docblock Annotations Parser library (extracted from [Doctrine Common](https://github.com/doctrine/common)).
|
||||
|
||||
## Documentation
|
||||
|
||||
See the [doctrine-project website](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html).
|
||||
|
||||
## Contributing
|
||||
|
||||
When making a pull request, make sure your changes follow the
|
||||
[Coding Standard Guidelines](https://www.doctrine-project.org/projects/doctrine-coding-standard/en/current/reference/index.html#introduction).
|
||||
72
vendor/doctrine/annotations/composer.json
vendored
Normal file
72
vendor/doctrine/annotations/composer.json
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
"description": "Docblock Annotations Parser",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"annotations",
|
||||
"docblock",
|
||||
"parser"
|
||||
],
|
||||
"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/annotations.html",
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"ext-tokenizer": "*",
|
||||
"doctrine/lexer": "^1 || ^2",
|
||||
"psr/cache": "^1 || ^2 || ^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/cache": "^1.11 || ^2.0",
|
||||
"doctrine/coding-standard": "^9 || ^10",
|
||||
"phpstan/phpstan": "~1.4.10 || ^1.8.0",
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6",
|
||||
"vimeo/psalm": "^4.10"
|
||||
},
|
||||
"suggest": {
|
||||
"php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Performance\\Common\\Annotations\\": "tests/Doctrine/Performance/Common/Annotations",
|
||||
"Doctrine\\Tests\\Common\\Annotations\\": "tests/Doctrine/Tests/Common/Annotations"
|
||||
},
|
||||
"files": [
|
||||
"tests/Doctrine/Tests/Common/Annotations/Fixtures/functions.php",
|
||||
"tests/Doctrine/Tests/Common/Annotations/Fixtures/SingleClassLOC1000.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
},
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
252
vendor/doctrine/annotations/docs/en/annotations.rst
vendored
Normal file
252
vendor/doctrine/annotations/docs/en/annotations.rst
vendored
Normal file
@@ -0,0 +1,252 @@
|
||||
Handling Annotations
|
||||
====================
|
||||
|
||||
There are several different approaches to handling annotations in PHP.
|
||||
Doctrine Annotations maps docblock annotations to PHP classes. Because
|
||||
not all docblock annotations are used for metadata purposes a filter is
|
||||
applied to ignore or skip classes that are not Doctrine annotations.
|
||||
|
||||
Take a look at the following code snippet:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyProject\Entities;
|
||||
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Symfony\Component\Validator\Constraints AS Assert;
|
||||
|
||||
/**
|
||||
* @author Benjamin Eberlei
|
||||
* @ORM\Entity
|
||||
* @MyProject\Annotations\Foobarable
|
||||
*/
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* @ORM\Id @ORM\Column @ORM\GeneratedValue
|
||||
* @dummy
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
* @Assert\NotEmpty
|
||||
* @Assert\Email
|
||||
* @var string
|
||||
*/
|
||||
private $email;
|
||||
}
|
||||
|
||||
In this snippet you can see a variety of different docblock annotations:
|
||||
|
||||
- Documentation annotations such as ``@var`` and ``@author``. These
|
||||
annotations are ignored and never considered for throwing an
|
||||
exception due to wrongly used annotations.
|
||||
- Annotations imported through use statements. The statement ``use
|
||||
Doctrine\ORM\Mapping AS ORM`` makes all classes under that namespace
|
||||
available as ``@ORM\ClassName``. Same goes for the import of
|
||||
``@Assert``.
|
||||
- The ``@dummy`` annotation. It is not a documentation annotation and
|
||||
not ignored. For Doctrine Annotations it is not entirely clear how
|
||||
to handle this annotation. Depending on the configuration an exception
|
||||
(unknown annotation) will be thrown when parsing this annotation.
|
||||
- The fully qualified annotation ``@MyProject\Annotations\Foobarable``.
|
||||
This is transformed directly into the given class name.
|
||||
|
||||
How are these annotations loaded? From looking at the code you could
|
||||
guess that the ORM Mapping, Assert Validation and the fully qualified
|
||||
annotation can just be loaded using
|
||||
the defined PHP autoloaders. This is not the case however: For error
|
||||
handling reasons every check for class existence inside the
|
||||
``AnnotationReader`` sets the second parameter $autoload
|
||||
of ``class_exists($name, $autoload)`` to false. To work flawlessly the
|
||||
``AnnotationReader`` requires silent autoloaders which many autoloaders are
|
||||
not. Silent autoloading is NOT part of the `PSR-0 specification
|
||||
<https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md>`_
|
||||
for autoloading.
|
||||
|
||||
This is why Doctrine Annotations uses its own autoloading mechanism
|
||||
through a global registry. If you are wondering about the annotation
|
||||
registry being global, there is no other way to solve the architectural
|
||||
problems of autoloading annotation classes in a straightforward fashion.
|
||||
Additionally if you think about PHP autoloading then you recognize it is
|
||||
a global as well.
|
||||
|
||||
To anticipate the configuration section, making the above PHP class work
|
||||
with Doctrine Annotations requires this setup:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
|
||||
AnnotationRegistry::registerFile("/path/to/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php");
|
||||
AnnotationRegistry::registerAutoloadNamespace("Symfony\Component\Validator\Constraint", "/path/to/symfony/src");
|
||||
AnnotationRegistry::registerAutoloadNamespace("MyProject\Annotations", "/path/to/myproject/src");
|
||||
|
||||
$reader = new AnnotationReader();
|
||||
AnnotationReader::addGlobalIgnoredName('dummy');
|
||||
|
||||
The second block with the annotation registry calls registers all the
|
||||
three different annotation namespaces that are used.
|
||||
Doctrine Annotations saves all its annotations in a single file, that is
|
||||
why ``AnnotationRegistry#registerFile`` is used in contrast to
|
||||
``AnnotationRegistry#registerAutoloadNamespace`` which creates a PSR-0
|
||||
compatible loading mechanism for class to file names.
|
||||
|
||||
In the third block, we create the actual ``AnnotationReader`` instance.
|
||||
Note that we also add ``dummy`` to the global list of ignored
|
||||
annotations for which we do not throw exceptions. Setting this is
|
||||
necessary in our example case, otherwise ``@dummy`` would trigger an
|
||||
exception to be thrown during the parsing of the docblock of
|
||||
``MyProject\Entities\User#id``.
|
||||
|
||||
Setup and Configuration
|
||||
-----------------------
|
||||
|
||||
To use the annotations library is simple, you just need to create a new
|
||||
``AnnotationReader`` instance:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
|
||||
|
||||
This creates a simple annotation reader with no caching other than in
|
||||
memory (in php arrays). Since parsing docblocks can be expensive you
|
||||
should cache this process by using a caching reader.
|
||||
|
||||
To cache annotations, you can create a ``Doctrine\Common\Annotations\PsrCachedReader``.
|
||||
This reader decorates the original reader and stores all annotations in a PSR-6
|
||||
cache:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\PsrCachedReader;
|
||||
|
||||
$cache = ... // instantiate a PSR-6 Cache pool
|
||||
|
||||
$reader = new PsrCachedReader(
|
||||
new AnnotationReader(),
|
||||
$cache,
|
||||
$debug = true
|
||||
);
|
||||
|
||||
The ``debug`` flag is used here as well to invalidate the cache files
|
||||
when the PHP class with annotations changed and should be used during
|
||||
development.
|
||||
|
||||
.. warning ::
|
||||
|
||||
The ``AnnotationReader`` works and caches under the
|
||||
assumption that all annotations of a doc-block are processed at
|
||||
once. That means that annotation classes that do not exist and
|
||||
aren't loaded and cannot be autoloaded (using the
|
||||
AnnotationRegistry) would never be visible and not accessible if a
|
||||
cache is used unless the cache is cleared and the annotations
|
||||
requested again, this time with all annotations defined.
|
||||
|
||||
By default the annotation reader returns a list of annotations with
|
||||
numeric indexes. If you want your annotations to be indexed by their
|
||||
class name you can wrap the reader in an ``IndexedReader``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\IndexedReader;
|
||||
|
||||
$reader = new IndexedReader(new AnnotationReader());
|
||||
|
||||
.. warning::
|
||||
|
||||
You should never wrap the indexed reader inside a cached reader,
|
||||
only the other way around. This way you can re-use the cache with
|
||||
indexed or numeric keys, otherwise your code may experience failures
|
||||
due to caching in a numerical or indexed format.
|
||||
|
||||
Registering Annotations
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
As explained in the introduction, Doctrine Annotations uses its own
|
||||
autoloading mechanism to determine if a given annotation has a
|
||||
corresponding PHP class that can be autoloaded. For annotation
|
||||
autoloading you have to configure the
|
||||
``Doctrine\Common\Annotations\AnnotationRegistry``. There are three
|
||||
different mechanisms to configure annotation autoloading:
|
||||
|
||||
- Calling ``AnnotationRegistry#registerFile($file)`` to register a file
|
||||
that contains one or more annotation classes.
|
||||
- Calling ``AnnotationRegistry#registerNamespace($namespace, $dirs =
|
||||
null)`` to register that the given namespace contains annotations and
|
||||
that their base directory is located at the given $dirs or in the
|
||||
include path if ``NULL`` is passed. The given directories should *NOT*
|
||||
be the directory where classes of the namespace are in, but the base
|
||||
directory of the root namespace. The AnnotationRegistry uses a
|
||||
namespace to directory separator approach to resolve the correct path.
|
||||
- Calling ``AnnotationRegistry#registerLoader($callable)`` to register
|
||||
an autoloader callback. The callback accepts the class as first and
|
||||
only parameter and has to return ``true`` if the corresponding file
|
||||
was found and included.
|
||||
|
||||
.. note::
|
||||
|
||||
Loaders have to fail silently, if a class is not found even if it
|
||||
matches for example the namespace prefix of that loader. Never is a
|
||||
loader to throw a warning or exception if the loading failed
|
||||
otherwise parsing doc block annotations will become a huge pain.
|
||||
|
||||
A sample loader callback could look like:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Symfony\Component\ClassLoader\UniversalClassLoader;
|
||||
|
||||
AnnotationRegistry::registerLoader(function($class) {
|
||||
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
|
||||
|
||||
if (file_exists("/my/base/path/" . $file)) {
|
||||
// file_exists() makes sure that the loader fails silently
|
||||
require "/my/base/path/" . $file;
|
||||
}
|
||||
});
|
||||
|
||||
$loader = new UniversalClassLoader();
|
||||
AnnotationRegistry::registerLoader(array($loader, "loadClass"));
|
||||
|
||||
|
||||
Ignoring missing exceptions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
By default an exception is thrown from the ``AnnotationReader`` if an
|
||||
annotation was found that:
|
||||
|
||||
- is not part of the list of ignored "documentation annotations";
|
||||
- was not imported through a use statement;
|
||||
- is not a fully qualified class that exists.
|
||||
|
||||
You can disable this behavior for specific names if your docblocks do
|
||||
not follow strict requirements:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
|
||||
AnnotationReader::addGlobalIgnoredName('foo');
|
||||
|
||||
PHP Imports
|
||||
~~~~~~~~~~~
|
||||
|
||||
By default the annotation reader parses the use-statement of a php file
|
||||
to gain access to the import rules and register them for the annotation
|
||||
processing. Only if you are using PHP Imports can you validate the
|
||||
correct usage of annotations and throw exceptions if you misspelled an
|
||||
annotation. This mechanism is enabled by default.
|
||||
|
||||
To ease the upgrade path, we still allow you to disable this mechanism.
|
||||
Note however that we will remove this in future versions:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
|
||||
$reader->setEnabledPhpImports(false);
|
||||
443
vendor/doctrine/annotations/docs/en/custom.rst
vendored
Normal file
443
vendor/doctrine/annotations/docs/en/custom.rst
vendored
Normal file
@@ -0,0 +1,443 @@
|
||||
Custom Annotation Classes
|
||||
=========================
|
||||
|
||||
If you want to define your own annotations, you just have to group them
|
||||
in a namespace and register this namespace in the ``AnnotationRegistry``.
|
||||
Annotation classes have to contain a class-level docblock with the text
|
||||
``@Annotation``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/** @Annotation */
|
||||
class Bar
|
||||
{
|
||||
// some code
|
||||
}
|
||||
|
||||
Inject annotation values
|
||||
------------------------
|
||||
|
||||
The annotation parser checks if the annotation constructor has arguments,
|
||||
if so then it will pass the value array, otherwise it will try to inject
|
||||
values into public properties directly:
|
||||
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*
|
||||
* Some Annotation using a constructor
|
||||
*/
|
||||
class Bar
|
||||
{
|
||||
private $foo;
|
||||
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->foo = $values['foo'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*
|
||||
* Some Annotation without a constructor
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
public $bar;
|
||||
}
|
||||
|
||||
Optional: Constructors with Named Parameters
|
||||
--------------------------------------------
|
||||
|
||||
Starting with Annotations v1.11 a new annotation instantiation strategy
|
||||
is available that aims at compatibility of Annotation classes with the PHP 8
|
||||
attribute feature. You need to declare a constructor with regular parameter
|
||||
names that match the named arguments in the annotation syntax.
|
||||
|
||||
To enable this feature, you can tag your annotation class with
|
||||
``@NamedArgumentConstructor`` (available from v1.12) or implement the
|
||||
``Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation`` interface
|
||||
(available from v1.11 and deprecated as of v1.12).
|
||||
When using the ``@NamedArgumentConstructor`` tag, the first argument of the
|
||||
constructor is considered as the default one.
|
||||
|
||||
|
||||
Usage with the ``@NamedArgumentConstructor`` tag
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @NamedArgumentConstructor
|
||||
*/
|
||||
class Bar implements NamedArgumentConstructorAnnotation
|
||||
{
|
||||
private $foo;
|
||||
|
||||
public function __construct(string $foo)
|
||||
{
|
||||
$this->foo = $foo;
|
||||
}
|
||||
}
|
||||
|
||||
/** Usable with @Bar(foo="baz") */
|
||||
/** Usable with @Bar("baz") */
|
||||
|
||||
In combination with PHP 8's constructor property promotion feature
|
||||
you can simplify this to:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @NamedArgumentConstructor
|
||||
*/
|
||||
class Bar implements NamedArgumentConstructorAnnotation
|
||||
{
|
||||
public function __construct(private string $foo) {}
|
||||
}
|
||||
|
||||
|
||||
Usage with the
|
||||
``Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation``
|
||||
interface (v1.11, deprecated as of v1.12):
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;
|
||||
|
||||
/** @Annotation */
|
||||
class Bar implements NamedArgumentConstructorAnnotation
|
||||
{
|
||||
private $foo;
|
||||
|
||||
public function __construct(private string $foo) {}
|
||||
}
|
||||
|
||||
/** Usable with @Bar(foo="baz") */
|
||||
|
||||
Annotation Target
|
||||
-----------------
|
||||
|
||||
``@Target`` indicates the kinds of class elements to which an annotation
|
||||
type is applicable. Then you could define one or more targets:
|
||||
|
||||
- ``CLASS`` Allowed in class docblocks
|
||||
- ``PROPERTY`` Allowed in property docblocks
|
||||
- ``METHOD`` Allowed in the method docblocks
|
||||
- ``FUNCTION`` Allowed in function dockblocks
|
||||
- ``ALL`` Allowed in class, property, method and function docblocks
|
||||
- ``ANNOTATION`` Allowed inside other annotations
|
||||
|
||||
If the annotations is not allowed in the current context, an
|
||||
``AnnotationException`` is thrown.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD","PROPERTY"})
|
||||
*/
|
||||
class Bar
|
||||
{
|
||||
// some code
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
// some code
|
||||
}
|
||||
|
||||
Attribute types
|
||||
---------------
|
||||
|
||||
The annotation parser checks the given parameters using the phpdoc
|
||||
annotation ``@var``, The data type could be validated using the ``@var``
|
||||
annotation on the annotation properties or using the ``@Attributes`` and
|
||||
``@Attribute`` annotations.
|
||||
|
||||
If the data type does not match you get an ``AnnotationException``
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Annotations;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD","PROPERTY"})
|
||||
*/
|
||||
class Bar
|
||||
{
|
||||
/** @var mixed */
|
||||
public $mixed;
|
||||
|
||||
/** @var boolean */
|
||||
public $boolean;
|
||||
|
||||
/** @var bool */
|
||||
public $bool;
|
||||
|
||||
/** @var float */
|
||||
public $float;
|
||||
|
||||
/** @var string */
|
||||
public $string;
|
||||
|
||||
/** @var integer */
|
||||
public $integer;
|
||||
|
||||
/** @var array */
|
||||
public $array;
|
||||
|
||||
/** @var SomeAnnotationClass */
|
||||
public $annotation;
|
||||
|
||||
/** @var array<integer> */
|
||||
public $arrayOfIntegers;
|
||||
|
||||
/** @var array<SomeAnnotationClass> */
|
||||
public $arrayOfAnnotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"METHOD","PROPERTY"})
|
||||
* @Attributes({
|
||||
* @Attribute("stringProperty", type = "string"),
|
||||
* @Attribute("annotProperty", type = "SomeAnnotationClass"),
|
||||
* })
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
public function __construct(array $values)
|
||||
{
|
||||
$this->stringProperty = $values['stringProperty'];
|
||||
$this->annotProperty = $values['annotProperty'];
|
||||
}
|
||||
|
||||
// some code
|
||||
}
|
||||
|
||||
Annotation Required
|
||||
-------------------
|
||||
|
||||
``@Required`` indicates that the field must be specified when the
|
||||
annotation is used. If it is not used you get an ``AnnotationException``
|
||||
stating that this value can not be null.
|
||||
|
||||
Declaring a required field:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
class Foo
|
||||
{
|
||||
/** @Required */
|
||||
public $requiredField;
|
||||
}
|
||||
|
||||
Usage:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
/** @Foo(requiredField="value") */
|
||||
public $direction; // Valid
|
||||
|
||||
/** @Foo */
|
||||
public $direction; // Required field missing, throws an AnnotationException
|
||||
|
||||
|
||||
Enumerated values
|
||||
-----------------
|
||||
|
||||
- An annotation property marked with ``@Enum`` is a field that accepts a
|
||||
fixed set of scalar values.
|
||||
- You should use ``@Enum`` fields any time you need to represent fixed
|
||||
values.
|
||||
- The annotation parser checks the given value and throws an
|
||||
``AnnotationException`` if the value does not match.
|
||||
|
||||
|
||||
Declaring an enumerated property:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target("ALL")
|
||||
*/
|
||||
class Direction
|
||||
{
|
||||
/**
|
||||
* @Enum({"NORTH", "SOUTH", "EAST", "WEST"})
|
||||
*/
|
||||
public $value;
|
||||
}
|
||||
|
||||
Annotation usage:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
/** @Direction("NORTH") */
|
||||
public $direction; // Valid value
|
||||
|
||||
/** @Direction("NORTHEAST") */
|
||||
public $direction; // Invalid value, throws an AnnotationException
|
||||
|
||||
|
||||
Constants
|
||||
---------
|
||||
|
||||
The use of constants and class constants is available on the annotations
|
||||
parser.
|
||||
|
||||
The following usages are allowed:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Entity;
|
||||
|
||||
use MyCompany\Annotations\Foo;
|
||||
use MyCompany\Annotations\Bar;
|
||||
use MyCompany\Entity\SomeClass;
|
||||
|
||||
/**
|
||||
* @Foo(PHP_EOL)
|
||||
* @Bar(Bar::FOO)
|
||||
* @Foo({SomeClass::FOO, SomeClass::BAR})
|
||||
* @Bar({SomeClass::FOO_KEY = SomeClass::BAR_VALUE})
|
||||
*/
|
||||
class User
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Be careful with constants and the cache !
|
||||
|
||||
.. note::
|
||||
|
||||
The cached reader will not re-evaluate each time an annotation is
|
||||
loaded from cache. When a constant is changed the cache must be
|
||||
cleaned.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Using the library API is simple. Using the annotations described in the
|
||||
previous section, you can now annotate other classes with your
|
||||
annotations:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace MyCompany\Entity;
|
||||
|
||||
use MyCompany\Annotations\Foo;
|
||||
use MyCompany\Annotations\Bar;
|
||||
|
||||
/**
|
||||
* @Foo(bar="foo")
|
||||
* @Bar(foo="bar")
|
||||
*/
|
||||
class User
|
||||
{
|
||||
}
|
||||
|
||||
Now we can write a script to get the annotations above:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$reflClass = new ReflectionClass('MyCompany\Entity\User');
|
||||
$classAnnotations = $reader->getClassAnnotations($reflClass);
|
||||
|
||||
foreach ($classAnnotations AS $annot) {
|
||||
if ($annot instanceof \MyCompany\Annotations\Foo) {
|
||||
echo $annot->bar; // prints "foo";
|
||||
} else if ($annot instanceof \MyCompany\Annotations\Bar) {
|
||||
echo $annot->foo; // prints "bar";
|
||||
}
|
||||
}
|
||||
|
||||
You have a complete API for retrieving annotation class instances from a
|
||||
class, property or method docblock:
|
||||
|
||||
|
||||
Reader API
|
||||
~~~~~~~~~~
|
||||
|
||||
Access all annotations of a class
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getClassAnnotations(\ReflectionClass $class);
|
||||
|
||||
Access one annotation of a class
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getClassAnnotation(\ReflectionClass $class, $annotationName);
|
||||
|
||||
Access all annotations of a method
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getMethodAnnotations(\ReflectionMethod $method);
|
||||
|
||||
Access one annotation of a method
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getMethodAnnotation(\ReflectionMethod $method, $annotationName);
|
||||
|
||||
Access all annotations of a property
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getPropertyAnnotations(\ReflectionProperty $property);
|
||||
|
||||
Access one annotation of a property
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName);
|
||||
|
||||
Access all annotations of a function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getFunctionAnnotations(\ReflectionFunction $property);
|
||||
|
||||
Access one annotation of a function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function getFunctionAnnotation(\ReflectionFunction $property, $annotationName);
|
||||
110
vendor/doctrine/annotations/docs/en/index.rst
vendored
Normal file
110
vendor/doctrine/annotations/docs/en/index.rst
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
Deprecation notice
|
||||
==================
|
||||
|
||||
PHP 8 introduced `attributes
|
||||
<https://www.php.net/manual/en/language.attributes.overview.php>`_,
|
||||
which are a native replacement for annotations. As such, this library is
|
||||
considered feature complete, and should receive exclusively bugfixes and
|
||||
security fixes.
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
Doctrine Annotations allows to implement custom annotation
|
||||
functionality for PHP classes and functions.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class Foo
|
||||
{
|
||||
/**
|
||||
* @MyAnnotation(myProperty="value")
|
||||
*/
|
||||
private $bar;
|
||||
}
|
||||
|
||||
Annotations aren't implemented in PHP itself which is why this component
|
||||
offers a way to use the PHP doc-blocks as a place for the well known
|
||||
annotation syntax using the ``@`` char.
|
||||
|
||||
Annotations in Doctrine are used for the ORM configuration to build the
|
||||
class mapping, but it can be used in other projects for other purposes
|
||||
too.
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
You can install the Annotation component with composer:
|
||||
|
||||
.. code-block::
|
||||
|
||||
$ composer require doctrine/annotations
|
||||
|
||||
Create an annotation class
|
||||
==========================
|
||||
|
||||
An annotation class is a representation of the later used annotation
|
||||
configuration in classes. The annotation class of the previous example
|
||||
looks like this:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
*/
|
||||
final class MyAnnotation
|
||||
{
|
||||
public $myProperty;
|
||||
}
|
||||
|
||||
The annotation class is declared as an annotation by ``@Annotation``.
|
||||
|
||||
:ref:`Read more about custom annotations. <custom>`
|
||||
|
||||
Reading annotations
|
||||
===================
|
||||
|
||||
The access to the annotations happens by reflection of the class or function
|
||||
containing them. There are multiple reader-classes implementing the
|
||||
``Doctrine\Common\Annotations\Reader`` interface, that can access the
|
||||
annotations of a class. A common one is
|
||||
``Doctrine\Common\Annotations\AnnotationReader``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
|
||||
// Deprecated and will be removed in 2.0 but currently needed
|
||||
AnnotationRegistry::registerLoader('class_exists');
|
||||
|
||||
$reflectionClass = new ReflectionClass(Foo::class);
|
||||
$property = $reflectionClass->getProperty('bar');
|
||||
|
||||
$reader = new AnnotationReader();
|
||||
$myAnnotation = $reader->getPropertyAnnotation(
|
||||
$property,
|
||||
MyAnnotation::class
|
||||
);
|
||||
|
||||
echo $myAnnotation->myProperty; // result: "value"
|
||||
|
||||
Note that ``AnnotationRegistry::registerLoader('class_exists')`` only works
|
||||
if you already have an autoloader configured (i.e. composer autoloader).
|
||||
Otherwise, :ref:`please take a look to the other annotation autoload mechanisms <annotations>`.
|
||||
|
||||
A reader has multiple methods to access the annotations of a class or
|
||||
function.
|
||||
|
||||
:ref:`Read more about handling annotations. <annotations>`
|
||||
|
||||
IDE Support
|
||||
-----------
|
||||
|
||||
Some IDEs already provide support for annotations:
|
||||
|
||||
- Eclipse via the `Symfony2 Plugin <https://github.com/pulse00/Symfony-2-Eclipse-Plugin>`_
|
||||
- PhpStorm via the `PHP Annotations Plugin <https://plugins.jetbrains.com/plugin/7320-php-annotations>`_ or the `Symfony Plugin <https://plugins.jetbrains.com/plugin/7219-symfony-support>`_
|
||||
|
||||
.. _Read more about handling annotations.: annotations
|
||||
.. _Read more about custom annotations.: custom
|
||||
6
vendor/doctrine/annotations/docs/en/sidebar.rst
vendored
Normal file
6
vendor/doctrine/annotations/docs/en/sidebar.rst
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.. toctree::
|
||||
:depth: 3
|
||||
|
||||
index
|
||||
annotations
|
||||
custom
|
||||
57
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php
vendored
Normal file
57
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use BadMethodCallException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Annotations class.
|
||||
*/
|
||||
class Annotation
|
||||
{
|
||||
/**
|
||||
* Value property. Common among all derived classes.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/** @param array<string, mixed> $data Key-value for properties to be defined in this class. */
|
||||
final public function __construct(array $data)
|
||||
{
|
||||
foreach ($data as $key => $value) {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler for unknown property accessor in Annotation class.
|
||||
*
|
||||
* @param string $name Unknown property name.
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
throw new BadMethodCallException(
|
||||
sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error handler for unknown property mutator in Annotation class.
|
||||
*
|
||||
* @param string $name Unknown property name.
|
||||
* @param mixed $value Property value.
|
||||
*
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
throw new BadMethodCallException(
|
||||
sprintf("Unknown property '%s' on annotation '%s'.", $name, static::class)
|
||||
);
|
||||
}
|
||||
}
|
||||
21
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attribute.php
vendored
Normal file
21
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attribute.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the attribute type during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Attribute
|
||||
{
|
||||
/** @var string */
|
||||
public $name;
|
||||
|
||||
/** @var string */
|
||||
public $type;
|
||||
|
||||
/** @var bool */
|
||||
public $required = false;
|
||||
}
|
||||
15
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attributes.php
vendored
Normal file
15
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attributes.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the types of all declared attributes during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Attributes
|
||||
{
|
||||
/** @var array<Attribute> */
|
||||
public $value;
|
||||
}
|
||||
69
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php
vendored
Normal file
69
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function in_array;
|
||||
use function is_object;
|
||||
use function is_scalar;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the available values during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
* @Attributes({
|
||||
* @Attribute("value", required = true, type = "array"),
|
||||
* @Attribute("literal", required = false, type = "array")
|
||||
* })
|
||||
*/
|
||||
final class Enum
|
||||
{
|
||||
/** @phpstan-var list<scalar> */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Literal target declaration.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
public $literal;
|
||||
|
||||
/**
|
||||
* @phpstan-param array{literal?: mixed[], value: list<scalar>} $values
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (! isset($values['literal'])) {
|
||||
$values['literal'] = [];
|
||||
}
|
||||
|
||||
foreach ($values['value'] as $var) {
|
||||
if (! is_scalar($var)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'@Enum supports only scalar values "%s" given.',
|
||||
is_object($var) ? get_class($var) : gettype($var)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($values['literal'] as $key => $var) {
|
||||
if (! in_array($key, $values['value'])) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Undefined enumerator value "%s" for literal "%s".',
|
||||
$key,
|
||||
$var
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$this->value = $values['value'];
|
||||
$this->literal = $values['literal'];
|
||||
}
|
||||
}
|
||||
43
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php
vendored
Normal file
43
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function json_encode;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser to ignore specific
|
||||
* annotations during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class IgnoreAnnotation
|
||||
{
|
||||
/** @phpstan-var list<string> */
|
||||
public $names;
|
||||
|
||||
/**
|
||||
* @phpstan-param array{value: string|list<string>} $values
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (is_string($values['value'])) {
|
||||
$values['value'] = [$values['value']];
|
||||
}
|
||||
|
||||
if (! is_array($values['value'])) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.',
|
||||
json_encode($values['value'])
|
||||
));
|
||||
}
|
||||
|
||||
$this->names = $values['value'];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that indicates that the annotated class should be constructed with a named argument call.
|
||||
*
|
||||
* @Annotation
|
||||
* @Target("CLASS")
|
||||
*/
|
||||
final class NamedArgumentConstructor
|
||||
{
|
||||
}
|
||||
13
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Required.php
vendored
Normal file
13
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Required.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check if that attribute is required during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Required
|
||||
{
|
||||
}
|
||||
101
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php
vendored
Normal file
101
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations\Annotation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
use function array_keys;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
use function is_array;
|
||||
use function is_object;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Annotation that can be used to signal to the parser
|
||||
* to check the annotation target during the parsing process.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
final class Target
|
||||
{
|
||||
public const TARGET_CLASS = 1;
|
||||
public const TARGET_METHOD = 2;
|
||||
public const TARGET_PROPERTY = 4;
|
||||
public const TARGET_ANNOTATION = 8;
|
||||
public const TARGET_FUNCTION = 16;
|
||||
public const TARGET_ALL = 31;
|
||||
|
||||
/** @var array<string, int> */
|
||||
private static $map = [
|
||||
'ALL' => self::TARGET_ALL,
|
||||
'CLASS' => self::TARGET_CLASS,
|
||||
'METHOD' => self::TARGET_METHOD,
|
||||
'PROPERTY' => self::TARGET_PROPERTY,
|
||||
'FUNCTION' => self::TARGET_FUNCTION,
|
||||
'ANNOTATION' => self::TARGET_ANNOTATION,
|
||||
];
|
||||
|
||||
/** @phpstan-var list<string> */
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* Targets as bitmask.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $targets;
|
||||
|
||||
/**
|
||||
* Literal target declaration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $literal;
|
||||
|
||||
/**
|
||||
* @phpstan-param array{value?: string|list<string>} $values
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $values)
|
||||
{
|
||||
if (! isset($values['value'])) {
|
||||
$values['value'] = null;
|
||||
}
|
||||
|
||||
if (is_string($values['value'])) {
|
||||
$values['value'] = [$values['value']];
|
||||
}
|
||||
|
||||
if (! is_array($values['value'])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'@Target expects either a string value, or an array of strings, "%s" given.',
|
||||
is_object($values['value']) ? get_class($values['value']) : gettype($values['value'])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$bitmask = 0;
|
||||
foreach ($values['value'] as $literal) {
|
||||
if (! isset(self::$map[$literal])) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Invalid Target "%s". Available targets: [%s]',
|
||||
$literal,
|
||||
implode(', ', array_keys(self::$map))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$bitmask |= self::$map[$literal];
|
||||
}
|
||||
|
||||
$this->targets = $bitmask;
|
||||
$this->value = $values['value'];
|
||||
$this->literal = implode(', ', $this->value);
|
||||
}
|
||||
}
|
||||
167
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php
vendored
Normal file
167
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Exception;
|
||||
use Throwable;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function implode;
|
||||
use function is_object;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Description of AnnotationException
|
||||
*/
|
||||
class AnnotationException extends Exception
|
||||
{
|
||||
/**
|
||||
* Creates a new AnnotationException describing a Syntax error.
|
||||
*
|
||||
* @param string $message Exception message
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function syntaxError($message)
|
||||
{
|
||||
return new self('[Syntax Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a Semantical error.
|
||||
*
|
||||
* @param string $message Exception message
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function semanticalError($message)
|
||||
{
|
||||
return new self('[Semantical Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an error which occurred during
|
||||
* the creation of the annotation.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function creationError($message, ?Throwable $previous = null)
|
||||
{
|
||||
return new self('[Creation Error] ' . $message, 0, $previous);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a type error.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function typeError($message)
|
||||
{
|
||||
return new self('[Type Error] ' . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a constant semantical error.
|
||||
*
|
||||
* @param string $identifier
|
||||
* @param string $context
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function semanticalErrorConstants($identifier, $context = null)
|
||||
{
|
||||
return self::semanticalError(sprintf(
|
||||
"Couldn't find constant %s%s.",
|
||||
$identifier,
|
||||
$context ? ', ' . $context : ''
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an type error of an attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param string $expected
|
||||
* @param mixed $actual
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual)
|
||||
{
|
||||
return self::typeError(sprintf(
|
||||
'Attribute "%s" of @%s declared on %s expects %s, but got %s.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
$expected,
|
||||
is_object($actual) ? 'an instance of ' . get_class($actual) : gettype($actual)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing an required error of an attribute.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param string $expected
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function requiredError($attributeName, $annotationName, $context, $expected)
|
||||
{
|
||||
return self::typeError(sprintf(
|
||||
'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
$expected
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AnnotationException describing a invalid enummerator.
|
||||
*
|
||||
* @param string $attributeName
|
||||
* @param string $annotationName
|
||||
* @param string $context
|
||||
* @param mixed $given
|
||||
* @phpstan-param list<string> $available
|
||||
*
|
||||
* @return AnnotationException
|
||||
*/
|
||||
public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
|
||||
{
|
||||
return new self(sprintf(
|
||||
'[Enum Error] Attribute "%s" of @%s declared on %s accepts only [%s], but got %s.',
|
||||
$attributeName,
|
||||
$annotationName,
|
||||
$context,
|
||||
implode(', ', $available),
|
||||
is_object($given) ? get_class($given) : $given
|
||||
));
|
||||
}
|
||||
|
||||
/** @return AnnotationException */
|
||||
public static function optimizerPlusSaveComments()
|
||||
{
|
||||
return new self(
|
||||
'You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1.'
|
||||
);
|
||||
}
|
||||
|
||||
/** @return AnnotationException */
|
||||
public static function optimizerPlusLoadComments()
|
||||
{
|
||||
return new self(
|
||||
'You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1.'
|
||||
);
|
||||
}
|
||||
}
|
||||
389
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php
vendored
Normal file
389
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php
vendored
Normal file
@@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
|
||||
use Doctrine\Common\Annotations\Annotation\Target;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function array_merge;
|
||||
use function class_exists;
|
||||
use function extension_loaded;
|
||||
use function ini_get;
|
||||
|
||||
/**
|
||||
* A reader for docblock annotations.
|
||||
*/
|
||||
class AnnotationReader implements Reader
|
||||
{
|
||||
/**
|
||||
* Global map for imports.
|
||||
*
|
||||
* @var array<string, class-string>
|
||||
*/
|
||||
private static $globalImports = [
|
||||
'ignoreannotation' => Annotation\IgnoreAnnotation::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* A list with annotations that are not causing exceptions when not resolved to an annotation class.
|
||||
*
|
||||
* The names are case sensitive.
|
||||
*
|
||||
* @var array<string, true>
|
||||
*/
|
||||
private static $globalIgnoredNames = ImplicitlyIgnoredAnnotationNames::LIST;
|
||||
|
||||
/**
|
||||
* A list with annotations that are not causing exceptions when not resolved to an annotation class.
|
||||
*
|
||||
* The names are case sensitive.
|
||||
*
|
||||
* @var array<string, true>
|
||||
*/
|
||||
private static $globalIgnoredNamespaces = [];
|
||||
|
||||
/**
|
||||
* Add a new annotation to the globally ignored annotation names with regard to exception handling.
|
||||
*
|
||||
* @param string $name
|
||||
*/
|
||||
public static function addGlobalIgnoredName($name)
|
||||
{
|
||||
self::$globalIgnoredNames[$name] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new annotation to the globally ignored annotation namespaces with regard to exception handling.
|
||||
*
|
||||
* @param string $namespace
|
||||
*/
|
||||
public static function addGlobalIgnoredNamespace($namespace)
|
||||
{
|
||||
self::$globalIgnoredNamespaces[$namespace] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Annotations parser.
|
||||
*
|
||||
* @var DocParser
|
||||
*/
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* Annotations parser used to collect parsing metadata.
|
||||
*
|
||||
* @var DocParser
|
||||
*/
|
||||
private $preParser;
|
||||
|
||||
/**
|
||||
* PHP parser used to collect imports.
|
||||
*
|
||||
* @var PhpParser
|
||||
*/
|
||||
private $phpParser;
|
||||
|
||||
/**
|
||||
* In-memory cache mechanism to store imported annotations per class.
|
||||
*
|
||||
* @psalm-var array<'class'|'function', array<string, array<string, class-string>>>
|
||||
*/
|
||||
private $imports = [];
|
||||
|
||||
/**
|
||||
* In-memory cache mechanism to store ignored annotations per class.
|
||||
*
|
||||
* @psalm-var array<'class'|'function', array<string, array<string, true>>>
|
||||
*/
|
||||
private $ignoredAnnotationNames = [];
|
||||
|
||||
/**
|
||||
* Initializes a new AnnotationReader.
|
||||
*
|
||||
* @throws AnnotationException
|
||||
*/
|
||||
public function __construct(?DocParser $parser = null)
|
||||
{
|
||||
if (
|
||||
extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === '0' ||
|
||||
ini_get('opcache.save_comments') === '0')
|
||||
) {
|
||||
throw AnnotationException::optimizerPlusSaveComments();
|
||||
}
|
||||
|
||||
if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') === 0) {
|
||||
throw AnnotationException::optimizerPlusSaveComments();
|
||||
}
|
||||
|
||||
// Make sure that the IgnoreAnnotation annotation is loaded
|
||||
class_exists(IgnoreAnnotation::class);
|
||||
|
||||
$this->parser = $parser ?: new DocParser();
|
||||
|
||||
$this->preParser = new DocParser();
|
||||
|
||||
$this->preParser->setImports(self::$globalImports);
|
||||
$this->preParser->setIgnoreNotImportedAnnotations(true);
|
||||
$this->preParser->setIgnoredAnnotationNames(self::$globalIgnoredNames);
|
||||
|
||||
$this->phpParser = new PhpParser();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
$this->parser->setTarget(Target::TARGET_CLASS);
|
||||
$this->parser->setImports($this->getImports($class));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
$this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
|
||||
|
||||
return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
$annotations = $this->getClassAnnotations($class);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$context = 'property ' . $class->getName() . '::$' . $property->getName();
|
||||
|
||||
$this->parser->setTarget(Target::TARGET_PROPERTY);
|
||||
$this->parser->setImports($this->getPropertyImports($property));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
$this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
|
||||
|
||||
return $this->parser->parse($property->getDocComment(), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
$annotations = $this->getPropertyAnnotations($property);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
|
||||
|
||||
$this->parser->setTarget(Target::TARGET_METHOD);
|
||||
$this->parser->setImports($this->getMethodImports($method));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
|
||||
$this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
|
||||
|
||||
return $this->parser->parse($method->getDocComment(), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
$annotations = $this->getMethodAnnotations($method);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a function.
|
||||
*
|
||||
* @phpstan-return list<object> An array of Annotations.
|
||||
*/
|
||||
public function getFunctionAnnotations(ReflectionFunction $function): array
|
||||
{
|
||||
$context = 'function ' . $function->getName();
|
||||
|
||||
$this->parser->setTarget(Target::TARGET_FUNCTION);
|
||||
$this->parser->setImports($this->getImports($function));
|
||||
$this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($function));
|
||||
$this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
|
||||
|
||||
return $this->parser->parse($function->getDocComment(), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a function annotation.
|
||||
*
|
||||
* @return object|null The Annotation or NULL, if the requested annotation does not exist.
|
||||
*/
|
||||
public function getFunctionAnnotation(ReflectionFunction $function, string $annotationName)
|
||||
{
|
||||
$annotations = $this->getFunctionAnnotations($function);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ignored annotations for the given class or function.
|
||||
*
|
||||
* @param ReflectionClass|ReflectionFunction $reflection
|
||||
*
|
||||
* @return array<string, true>
|
||||
*/
|
||||
private function getIgnoredAnnotationNames($reflection): array
|
||||
{
|
||||
$type = $reflection instanceof ReflectionClass ? 'class' : 'function';
|
||||
$name = $reflection->getName();
|
||||
|
||||
if (isset($this->ignoredAnnotationNames[$type][$name])) {
|
||||
return $this->ignoredAnnotationNames[$type][$name];
|
||||
}
|
||||
|
||||
$this->collectParsingMetadata($reflection);
|
||||
|
||||
return $this->ignoredAnnotationNames[$type][$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves imports for a class or a function.
|
||||
*
|
||||
* @param ReflectionClass|ReflectionFunction $reflection
|
||||
*
|
||||
* @return array<string, class-string>
|
||||
*/
|
||||
private function getImports($reflection): array
|
||||
{
|
||||
$type = $reflection instanceof ReflectionClass ? 'class' : 'function';
|
||||
$name = $reflection->getName();
|
||||
|
||||
if (isset($this->imports[$type][$name])) {
|
||||
return $this->imports[$type][$name];
|
||||
}
|
||||
|
||||
$this->collectParsingMetadata($reflection);
|
||||
|
||||
return $this->imports[$type][$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves imports for methods.
|
||||
*
|
||||
* @return array<string, class-string>
|
||||
*/
|
||||
private function getMethodImports(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$classImports = $this->getImports($class);
|
||||
|
||||
$traitImports = [];
|
||||
|
||||
foreach ($class->getTraits() as $trait) {
|
||||
if (
|
||||
! $trait->hasMethod($method->getName())
|
||||
|| $trait->getFileName() !== $method->getFileName()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$traitImports = array_merge($traitImports, $this->phpParser->parseUseStatements($trait));
|
||||
}
|
||||
|
||||
return array_merge($classImports, $traitImports);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves imports for properties.
|
||||
*
|
||||
* @return array<string, class-string>
|
||||
*/
|
||||
private function getPropertyImports(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$classImports = $this->getImports($class);
|
||||
|
||||
$traitImports = [];
|
||||
|
||||
foreach ($class->getTraits() as $trait) {
|
||||
if (! $trait->hasProperty($property->getName())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$traitImports = array_merge($traitImports, $this->phpParser->parseUseStatements($trait));
|
||||
}
|
||||
|
||||
return array_merge($classImports, $traitImports);
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects parsing metadata for a given class or function.
|
||||
*
|
||||
* @param ReflectionClass|ReflectionFunction $reflection
|
||||
*/
|
||||
private function collectParsingMetadata($reflection): void
|
||||
{
|
||||
$type = $reflection instanceof ReflectionClass ? 'class' : 'function';
|
||||
$name = $reflection->getName();
|
||||
|
||||
$ignoredAnnotationNames = self::$globalIgnoredNames;
|
||||
$annotations = $this->preParser->parse($reflection->getDocComment(), $type . ' ' . $name);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if (! ($annotation instanceof IgnoreAnnotation)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($annotation->names as $annot) {
|
||||
$ignoredAnnotationNames[$annot] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$this->imports[$type][$name] = array_merge(
|
||||
self::$globalImports,
|
||||
$this->phpParser->parseUseStatements($reflection),
|
||||
[
|
||||
'__NAMESPACE__' => $reflection->getNamespaceName(),
|
||||
'self' => $name,
|
||||
]
|
||||
);
|
||||
|
||||
$this->ignoredAnnotationNames[$type][$name] = $ignoredAnnotationNames;
|
||||
}
|
||||
}
|
||||
190
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php
vendored
Normal file
190
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use function array_key_exists;
|
||||
use function array_merge;
|
||||
use function class_exists;
|
||||
use function in_array;
|
||||
use function is_file;
|
||||
use function str_replace;
|
||||
use function stream_resolve_include_path;
|
||||
use function strpos;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
final class AnnotationRegistry
|
||||
{
|
||||
/**
|
||||
* A map of namespaces to use for autoloading purposes based on a PSR-0 convention.
|
||||
*
|
||||
* Contains the namespace as key and an array of directories as value. If the value is NULL
|
||||
* the include path is used for checking for the corresponding file.
|
||||
*
|
||||
* This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own.
|
||||
*
|
||||
* @var string[][]|string[]|null[]
|
||||
*/
|
||||
private static $autoloadNamespaces = [];
|
||||
|
||||
/**
|
||||
* A map of autoloader callables.
|
||||
*
|
||||
* @var callable[]
|
||||
*/
|
||||
private static $loaders = [];
|
||||
|
||||
/**
|
||||
* An array of classes which cannot be found
|
||||
*
|
||||
* @var null[] indexed by class name
|
||||
*/
|
||||
private static $failedToAutoload = [];
|
||||
|
||||
/**
|
||||
* Whenever registerFile() was used. Disables use of standard autoloader.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private static $registerFileUsed = false;
|
||||
|
||||
public static function reset(): void
|
||||
{
|
||||
self::$autoloadNamespaces = [];
|
||||
self::$loaders = [];
|
||||
self::$failedToAutoload = [];
|
||||
self::$registerFileUsed = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers file.
|
||||
*
|
||||
* @deprecated This method is deprecated and will be removed in
|
||||
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
|
||||
*/
|
||||
public static function registerFile(string $file): void
|
||||
{
|
||||
self::$registerFileUsed = true;
|
||||
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a namespace with one or many directories to look for files or null for the include path.
|
||||
*
|
||||
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
|
||||
*
|
||||
* @deprecated This method is deprecated and will be removed in
|
||||
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
|
||||
*
|
||||
* @phpstan-param string|list<string>|null $dirs
|
||||
*/
|
||||
public static function registerAutoloadNamespace(string $namespace, $dirs = null): void
|
||||
{
|
||||
self::$autoloadNamespaces[$namespace] = $dirs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers multiple namespaces.
|
||||
*
|
||||
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
|
||||
*
|
||||
* @deprecated This method is deprecated and will be removed in
|
||||
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
|
||||
*
|
||||
* @param string[][]|string[]|null[] $namespaces indexed by namespace name
|
||||
*/
|
||||
public static function registerAutoloadNamespaces(array $namespaces): void
|
||||
{
|
||||
self::$autoloadNamespaces = array_merge(self::$autoloadNamespaces, $namespaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an autoloading callable for annotations, much like spl_autoload_register().
|
||||
*
|
||||
* NOTE: These class loaders HAVE to be silent when a class was not found!
|
||||
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
|
||||
*
|
||||
* @deprecated This method is deprecated and will be removed in
|
||||
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
|
||||
*/
|
||||
public static function registerLoader(callable $callable): void
|
||||
{
|
||||
// Reset our static cache now that we have a new loader to work with
|
||||
self::$failedToAutoload = [];
|
||||
self::$loaders[] = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an autoloading callable for annotations, if it is not already registered
|
||||
*
|
||||
* @deprecated This method is deprecated and will be removed in
|
||||
* doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.
|
||||
*/
|
||||
public static function registerUniqueLoader(callable $callable): void
|
||||
{
|
||||
if (in_array($callable, self::$loaders, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self::registerLoader($callable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoloads an annotation class silently.
|
||||
*/
|
||||
public static function loadAnnotationClass(string $class): bool
|
||||
{
|
||||
if (class_exists($class, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (array_key_exists($class, self::$failedToAutoload)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (self::$autoloadNamespaces as $namespace => $dirs) {
|
||||
if (strpos($class, $namespace) !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
|
||||
|
||||
if ($dirs === null) {
|
||||
$path = stream_resolve_include_path($file);
|
||||
if ($path) {
|
||||
require $path;
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
foreach ((array) $dirs as $dir) {
|
||||
if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
|
||||
require $dir . DIRECTORY_SEPARATOR . $file;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (self::$loaders as $loader) {
|
||||
if ($loader($class) === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
self::$loaders === [] &&
|
||||
self::$autoloadNamespaces === [] &&
|
||||
self::$registerFileUsed === false &&
|
||||
class_exists($class)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
self::$failedToAutoload[$class] = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
266
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php
vendored
Normal file
266
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function filemtime;
|
||||
use function max;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* A cache aware annotation reader.
|
||||
*
|
||||
* @deprecated the CachedReader is deprecated and will be removed
|
||||
* in version 2.0.0 of doctrine/annotations. Please use the
|
||||
* {@see \Doctrine\Common\Annotations\PsrCachedReader} instead.
|
||||
*/
|
||||
final class CachedReader implements Reader
|
||||
{
|
||||
/** @var Reader */
|
||||
private $delegate;
|
||||
|
||||
/** @var Cache */
|
||||
private $cache;
|
||||
|
||||
/** @var bool */
|
||||
private $debug;
|
||||
|
||||
/** @var array<string, array<object>> */
|
||||
private $loadedAnnotations = [];
|
||||
|
||||
/** @var int[] */
|
||||
private $loadedFilemtimes = [];
|
||||
|
||||
/** @param bool $debug */
|
||||
public function __construct(Reader $reader, Cache $cache, $debug = false)
|
||||
{
|
||||
$this->delegate = $reader;
|
||||
$this->cache = $cache;
|
||||
$this->debug = (bool) $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
$cacheKey = $class->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class);
|
||||
if ($annots === false) {
|
||||
$annots = $this->delegate->getClassAnnotations($class);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
foreach ($this->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$cacheKey = $class->getName() . '$' . $property->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class);
|
||||
if ($annots === false) {
|
||||
$annots = $this->delegate->getPropertyAnnotations($property);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
foreach ($this->getPropertyAnnotations($property) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$cacheKey = $class->getName() . '#' . $method->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class);
|
||||
if ($annots === false) {
|
||||
$annots = $this->delegate->getMethodAnnotations($method);
|
||||
$this->saveToCache($cacheKey, $annots);
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
foreach ($this->getMethodAnnotations($method) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears loaded annotations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clearLoadedAnnotations()
|
||||
{
|
||||
$this->loadedAnnotations = [];
|
||||
$this->loadedFilemtimes = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a value from the cache.
|
||||
*
|
||||
* @param string $cacheKey The cache key.
|
||||
*
|
||||
* @return mixed The cached value or false when the value is not in cache.
|
||||
*/
|
||||
private function fetchFromCache($cacheKey, ReflectionClass $class)
|
||||
{
|
||||
$data = $this->cache->fetch($cacheKey);
|
||||
if ($data !== false) {
|
||||
if (! $this->debug || $this->isCacheFresh($cacheKey, $class)) {
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a value to the cache.
|
||||
*
|
||||
* @param string $cacheKey The cache key.
|
||||
* @param mixed $value The value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function saveToCache($cacheKey, $value)
|
||||
{
|
||||
$this->cache->save($cacheKey, $value);
|
||||
if (! $this->debug) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->cache->save('[C]' . $cacheKey, time());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the cache is fresh.
|
||||
*
|
||||
* @param string $cacheKey
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isCacheFresh($cacheKey, ReflectionClass $class)
|
||||
{
|
||||
$lastModification = $this->getLastModification($class);
|
||||
if ($lastModification === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->cache->fetch('[C]' . $cacheKey) >= $lastModification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the class was last modified, testing traits and parents
|
||||
*/
|
||||
private function getLastModification(ReflectionClass $class): int
|
||||
{
|
||||
$filename = $class->getFileName();
|
||||
|
||||
if (isset($this->loadedFilemtimes[$filename])) {
|
||||
return $this->loadedFilemtimes[$filename];
|
||||
}
|
||||
|
||||
$parent = $class->getParentClass();
|
||||
|
||||
$lastModification = max(array_merge(
|
||||
[$filename ? filemtime($filename) : 0],
|
||||
array_map(function (ReflectionClass $reflectionTrait): int {
|
||||
return $this->getTraitLastModificationTime($reflectionTrait);
|
||||
}, $class->getTraits()),
|
||||
array_map(function (ReflectionClass $class): int {
|
||||
return $this->getLastModification($class);
|
||||
}, $class->getInterfaces()),
|
||||
$parent ? [$this->getLastModification($parent)] : []
|
||||
));
|
||||
|
||||
assert($lastModification !== false);
|
||||
|
||||
return $this->loadedFilemtimes[$filename] = $lastModification;
|
||||
}
|
||||
|
||||
private function getTraitLastModificationTime(ReflectionClass $reflectionTrait): int
|
||||
{
|
||||
$fileName = $reflectionTrait->getFileName();
|
||||
|
||||
if (isset($this->loadedFilemtimes[$fileName])) {
|
||||
return $this->loadedFilemtimes[$fileName];
|
||||
}
|
||||
|
||||
$lastModificationTime = max(array_merge(
|
||||
[$fileName ? filemtime($fileName) : 0],
|
||||
array_map(function (ReflectionClass $reflectionTrait): int {
|
||||
return $this->getTraitLastModificationTime($reflectionTrait);
|
||||
}, $reflectionTrait->getTraits())
|
||||
));
|
||||
|
||||
assert($lastModificationTime !== false);
|
||||
|
||||
return $this->loadedFilemtimes[$fileName] = $lastModificationTime;
|
||||
}
|
||||
}
|
||||
143
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php
vendored
Normal file
143
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Doctrine\Common\Lexer\AbstractLexer;
|
||||
|
||||
use function ctype_alpha;
|
||||
use function is_numeric;
|
||||
use function str_replace;
|
||||
use function stripos;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Simple lexer for docblock annotations.
|
||||
*
|
||||
* @template-extends AbstractLexer<DocLexer::T_*, string>
|
||||
*/
|
||||
final class DocLexer extends AbstractLexer
|
||||
{
|
||||
public const T_NONE = 1;
|
||||
public const T_INTEGER = 2;
|
||||
public const T_STRING = 3;
|
||||
public const T_FLOAT = 4;
|
||||
|
||||
// All tokens that are also identifiers should be >= 100
|
||||
public const T_IDENTIFIER = 100;
|
||||
public const T_AT = 101;
|
||||
public const T_CLOSE_CURLY_BRACES = 102;
|
||||
public const T_CLOSE_PARENTHESIS = 103;
|
||||
public const T_COMMA = 104;
|
||||
public const T_EQUALS = 105;
|
||||
public const T_FALSE = 106;
|
||||
public const T_NAMESPACE_SEPARATOR = 107;
|
||||
public const T_OPEN_CURLY_BRACES = 108;
|
||||
public const T_OPEN_PARENTHESIS = 109;
|
||||
public const T_TRUE = 110;
|
||||
public const T_NULL = 111;
|
||||
public const T_COLON = 112;
|
||||
public const T_MINUS = 113;
|
||||
|
||||
/** @var array<string, self::T*> */
|
||||
protected $noCase = [
|
||||
'@' => self::T_AT,
|
||||
',' => self::T_COMMA,
|
||||
'(' => self::T_OPEN_PARENTHESIS,
|
||||
')' => self::T_CLOSE_PARENTHESIS,
|
||||
'{' => self::T_OPEN_CURLY_BRACES,
|
||||
'}' => self::T_CLOSE_CURLY_BRACES,
|
||||
'=' => self::T_EQUALS,
|
||||
':' => self::T_COLON,
|
||||
'-' => self::T_MINUS,
|
||||
'\\' => self::T_NAMESPACE_SEPARATOR,
|
||||
];
|
||||
|
||||
/** @var array<string, self::T*> */
|
||||
protected $withCase = [
|
||||
'true' => self::T_TRUE,
|
||||
'false' => self::T_FALSE,
|
||||
'null' => self::T_NULL,
|
||||
];
|
||||
|
||||
/**
|
||||
* Whether the next token starts immediately, or if there were
|
||||
* non-captured symbols before that
|
||||
*/
|
||||
public function nextTokenIsAdjacent(): bool
|
||||
{
|
||||
return $this->token === null
|
||||
|| ($this->lookahead !== null
|
||||
&& ($this->lookahead['position'] - $this->token['position']) === strlen($this->token['value']));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCatchablePatterns()
|
||||
{
|
||||
return [
|
||||
'[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*',
|
||||
'(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?',
|
||||
'"(?:""|[^"])*+"',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNonCatchablePatterns()
|
||||
{
|
||||
return ['\s+', '\*+', '(.)'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getType(&$value)
|
||||
{
|
||||
$type = self::T_NONE;
|
||||
|
||||
if ($value[0] === '"') {
|
||||
$value = str_replace('""', '"', substr($value, 1, strlen($value) - 2));
|
||||
|
||||
return self::T_STRING;
|
||||
}
|
||||
|
||||
if (isset($this->noCase[$value])) {
|
||||
return $this->noCase[$value];
|
||||
}
|
||||
|
||||
if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) {
|
||||
return self::T_IDENTIFIER;
|
||||
}
|
||||
|
||||
$lowerValue = strtolower($value);
|
||||
|
||||
if (isset($this->withCase[$lowerValue])) {
|
||||
return $this->withCase[$lowerValue];
|
||||
}
|
||||
|
||||
// Checking numeric value
|
||||
if (is_numeric($value)) {
|
||||
return strpos($value, '.') !== false || stripos($value, 'e') !== false
|
||||
? self::T_FLOAT : self::T_INTEGER;
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
/** @return array{value: int|string, type:self::T_*|null, position:int} */
|
||||
public function peek(): ?array
|
||||
{
|
||||
$token = parent::peek();
|
||||
|
||||
if ($token === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (array) $token;
|
||||
}
|
||||
}
|
||||
1506
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php
vendored
Normal file
1506
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
315
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php
vendored
Normal file
315
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php
vendored
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
use RuntimeException;
|
||||
|
||||
use function chmod;
|
||||
use function file_put_contents;
|
||||
use function filemtime;
|
||||
use function gettype;
|
||||
use function is_dir;
|
||||
use function is_file;
|
||||
use function is_int;
|
||||
use function is_writable;
|
||||
use function mkdir;
|
||||
use function rename;
|
||||
use function rtrim;
|
||||
use function serialize;
|
||||
use function sha1;
|
||||
use function sprintf;
|
||||
use function strtr;
|
||||
use function tempnam;
|
||||
use function uniqid;
|
||||
use function unlink;
|
||||
use function var_export;
|
||||
|
||||
/**
|
||||
* File cache reader for annotations.
|
||||
*
|
||||
* @deprecated the FileCacheReader is deprecated and will be removed
|
||||
* in version 2.0.0 of doctrine/annotations. Please use the
|
||||
* {@see \Doctrine\Common\Annotations\PsrCachedReader} instead.
|
||||
*/
|
||||
class FileCacheReader implements Reader
|
||||
{
|
||||
/** @var Reader */
|
||||
private $reader;
|
||||
|
||||
/** @var string */
|
||||
private $dir;
|
||||
|
||||
/** @var bool */
|
||||
private $debug;
|
||||
|
||||
/** @phpstan-var array<string, list<object>> */
|
||||
private $loadedAnnotations = [];
|
||||
|
||||
/** @var array<string, string> */
|
||||
private $classNameHashes = [];
|
||||
|
||||
/** @var int */
|
||||
private $umask;
|
||||
|
||||
/**
|
||||
* @param string $cacheDir
|
||||
* @param bool $debug
|
||||
* @param int $umask
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(Reader $reader, $cacheDir, $debug = false, $umask = 0002)
|
||||
{
|
||||
if (! is_int($umask)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The parameter umask must be an integer, was: %s',
|
||||
gettype($umask)
|
||||
));
|
||||
}
|
||||
|
||||
$this->reader = $reader;
|
||||
$this->umask = $umask;
|
||||
|
||||
if (! is_dir($cacheDir) && ! @mkdir($cacheDir, 0777 & (~$this->umask), true)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'The directory "%s" does not exist and could not be created.',
|
||||
$cacheDir
|
||||
));
|
||||
}
|
||||
|
||||
$this->dir = rtrim($cacheDir, '\\/');
|
||||
$this->debug = $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
if (! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
|
||||
$key = $this->classNameHashes[$class->name];
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir . '/' . strtr($key, '\\', '-') . '.cache.php';
|
||||
if (! is_file($path)) {
|
||||
$annot = $this->reader->getClassAnnotations($class);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
$filename = $class->getFilename();
|
||||
if (
|
||||
$this->debug
|
||||
&& $filename !== false
|
||||
&& filemtime($path) < filemtime($filename)
|
||||
) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getClassAnnotations($class);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
if (! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
|
||||
$key = $this->classNameHashes[$class->name] . '$' . $property->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir . '/' . strtr($key, '\\', '-') . '.cache.php';
|
||||
if (! is_file($path)) {
|
||||
$annot = $this->reader->getPropertyAnnotations($property);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
$filename = $class->getFilename();
|
||||
if (
|
||||
$this->debug
|
||||
&& $filename !== false
|
||||
&& filemtime($path) < filemtime($filename)
|
||||
) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getPropertyAnnotations($property);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
if (! isset($this->classNameHashes[$class->name])) {
|
||||
$this->classNameHashes[$class->name] = sha1($class->name);
|
||||
}
|
||||
|
||||
$key = $this->classNameHashes[$class->name] . '#' . $method->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$key])) {
|
||||
return $this->loadedAnnotations[$key];
|
||||
}
|
||||
|
||||
$path = $this->dir . '/' . strtr($key, '\\', '-') . '.cache.php';
|
||||
if (! is_file($path)) {
|
||||
$annot = $this->reader->getMethodAnnotations($method);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
$filename = $class->getFilename();
|
||||
if (
|
||||
$this->debug
|
||||
&& $filename !== false
|
||||
&& filemtime($path) < filemtime($filename)
|
||||
) {
|
||||
@unlink($path);
|
||||
|
||||
$annot = $this->reader->getMethodAnnotations($method);
|
||||
$this->saveCacheFile($path, $annot);
|
||||
|
||||
return $this->loadedAnnotations[$key] = $annot;
|
||||
}
|
||||
|
||||
return $this->loadedAnnotations[$key] = include $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the cache file.
|
||||
*
|
||||
* @param string $path
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function saveCacheFile($path, $data)
|
||||
{
|
||||
if (! is_writable($this->dir)) {
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
<<<'EXCEPTION'
|
||||
The directory "%s" is not writable. Both the webserver and the console user need access.
|
||||
You can manage access rights for multiple users with "chmod +a".
|
||||
If your system does not support this, check out the acl package.,
|
||||
EXCEPTION
|
||||
,
|
||||
$this->dir
|
||||
));
|
||||
}
|
||||
|
||||
$tempfile = tempnam($this->dir, uniqid('', true));
|
||||
|
||||
if ($tempfile === false) {
|
||||
throw new RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
|
||||
}
|
||||
|
||||
@chmod($tempfile, 0666 & (~$this->umask));
|
||||
|
||||
$written = file_put_contents(
|
||||
$tempfile,
|
||||
'<?php return unserialize(' . var_export(serialize($data), true) . ');'
|
||||
);
|
||||
|
||||
if ($written === false) {
|
||||
throw new RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
|
||||
}
|
||||
|
||||
@chmod($tempfile, 0666 & (~$this->umask));
|
||||
|
||||
if (rename($tempfile, $path) === false) {
|
||||
@unlink($tempfile);
|
||||
|
||||
throw new RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
$annotations = $this->getClassAnnotations($class);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
$annotations = $this->getMethodAnnotations($method);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
$annotations = $this->getPropertyAnnotations($property);
|
||||
|
||||
foreach ($annotations as $annotation) {
|
||||
if ($annotation instanceof $annotationName) {
|
||||
return $annotation;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears loaded annotations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clearLoadedAnnotations()
|
||||
{
|
||||
$this->loadedAnnotations = [];
|
||||
}
|
||||
}
|
||||
178
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/ImplicitlyIgnoredAnnotationNames.php
vendored
Normal file
178
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/ImplicitlyIgnoredAnnotationNames.php
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* A list of annotations that are implicitly ignored during the parsing process.
|
||||
*
|
||||
* All names are case sensitive.
|
||||
*/
|
||||
final class ImplicitlyIgnoredAnnotationNames
|
||||
{
|
||||
private const Reserved = [
|
||||
'Annotation' => true,
|
||||
'Attribute' => true,
|
||||
'Attributes' => true,
|
||||
/* Can we enable this? 'Enum' => true, */
|
||||
'Required' => true,
|
||||
'Target' => true,
|
||||
'NamedArgumentConstructor' => true,
|
||||
];
|
||||
|
||||
private const WidelyUsedNonStandard = [
|
||||
'fix' => true,
|
||||
'fixme' => true,
|
||||
'override' => true,
|
||||
];
|
||||
|
||||
private const PhpDocumentor1 = [
|
||||
'abstract' => true,
|
||||
'access' => true,
|
||||
'code' => true,
|
||||
'deprec' => true,
|
||||
'endcode' => true,
|
||||
'exception' => true,
|
||||
'final' => true,
|
||||
'ingroup' => true,
|
||||
'inheritdoc' => true,
|
||||
'inheritDoc' => true,
|
||||
'magic' => true,
|
||||
'name' => true,
|
||||
'private' => true,
|
||||
'static' => true,
|
||||
'staticvar' => true,
|
||||
'staticVar' => true,
|
||||
'toc' => true,
|
||||
'tutorial' => true,
|
||||
'throw' => true,
|
||||
];
|
||||
|
||||
private const PhpDocumentor2 = [
|
||||
'api' => true,
|
||||
'author' => true,
|
||||
'category' => true,
|
||||
'copyright' => true,
|
||||
'deprecated' => true,
|
||||
'example' => true,
|
||||
'filesource' => true,
|
||||
'global' => true,
|
||||
'ignore' => true,
|
||||
/* Can we enable this? 'index' => true, */
|
||||
'internal' => true,
|
||||
'license' => true,
|
||||
'link' => true,
|
||||
'method' => true,
|
||||
'package' => true,
|
||||
'param' => true,
|
||||
'property' => true,
|
||||
'property-read' => true,
|
||||
'property-write' => true,
|
||||
'return' => true,
|
||||
'see' => true,
|
||||
'since' => true,
|
||||
'source' => true,
|
||||
'subpackage' => true,
|
||||
'throws' => true,
|
||||
'todo' => true,
|
||||
'TODO' => true,
|
||||
'usedby' => true,
|
||||
'uses' => true,
|
||||
'var' => true,
|
||||
'version' => true,
|
||||
];
|
||||
|
||||
private const PHPUnit = [
|
||||
'author' => true,
|
||||
'after' => true,
|
||||
'afterClass' => true,
|
||||
'backupGlobals' => true,
|
||||
'backupStaticAttributes' => true,
|
||||
'before' => true,
|
||||
'beforeClass' => true,
|
||||
'codeCoverageIgnore' => true,
|
||||
'codeCoverageIgnoreStart' => true,
|
||||
'codeCoverageIgnoreEnd' => true,
|
||||
'covers' => true,
|
||||
'coversDefaultClass' => true,
|
||||
'coversNothing' => true,
|
||||
'dataProvider' => true,
|
||||
'depends' => true,
|
||||
'doesNotPerformAssertions' => true,
|
||||
'expectedException' => true,
|
||||
'expectedExceptionCode' => true,
|
||||
'expectedExceptionMessage' => true,
|
||||
'expectedExceptionMessageRegExp' => true,
|
||||
'group' => true,
|
||||
'large' => true,
|
||||
'medium' => true,
|
||||
'preserveGlobalState' => true,
|
||||
'requires' => true,
|
||||
'runTestsInSeparateProcesses' => true,
|
||||
'runInSeparateProcess' => true,
|
||||
'small' => true,
|
||||
'test' => true,
|
||||
'testdox' => true,
|
||||
'testWith' => true,
|
||||
'ticket' => true,
|
||||
'uses' => true,
|
||||
];
|
||||
|
||||
private const PhpCheckStyle = ['SuppressWarnings' => true];
|
||||
|
||||
private const PhpStorm = ['noinspection' => true];
|
||||
|
||||
private const PEAR = ['package_version' => true];
|
||||
|
||||
private const PlainUML = [
|
||||
'startuml' => true,
|
||||
'enduml' => true,
|
||||
];
|
||||
|
||||
private const Symfony = ['experimental' => true];
|
||||
|
||||
private const PhpCodeSniffer = [
|
||||
'codingStandardsIgnoreStart' => true,
|
||||
'codingStandardsIgnoreEnd' => true,
|
||||
];
|
||||
|
||||
private const SlevomatCodingStandard = ['phpcsSuppress' => true];
|
||||
|
||||
private const Phan = ['suppress' => true];
|
||||
|
||||
private const Rector = ['noRector' => true];
|
||||
|
||||
private const StaticAnalysis = [
|
||||
// PHPStan, Psalm
|
||||
'extends' => true,
|
||||
'implements' => true,
|
||||
'readonly' => true,
|
||||
'template' => true,
|
||||
'use' => true,
|
||||
|
||||
// Psalm
|
||||
'pure' => true,
|
||||
'immutable' => true,
|
||||
];
|
||||
|
||||
public const LIST = self::Reserved
|
||||
+ self::WidelyUsedNonStandard
|
||||
+ self::PhpDocumentor1
|
||||
+ self::PhpDocumentor2
|
||||
+ self::PHPUnit
|
||||
+ self::PhpCheckStyle
|
||||
+ self::PhpStorm
|
||||
+ self::PEAR
|
||||
+ self::PlainUML
|
||||
+ self::Symfony
|
||||
+ self::SlevomatCodingStandard
|
||||
+ self::PhpCodeSniffer
|
||||
+ self::Phan
|
||||
+ self::Rector
|
||||
+ self::StaticAnalysis;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
100
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php
vendored
Normal file
100
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
use function call_user_func_array;
|
||||
use function get_class;
|
||||
|
||||
/**
|
||||
* Allows the reader to be used in-place of Doctrine's reader.
|
||||
*/
|
||||
class IndexedReader implements Reader
|
||||
{
|
||||
/** @var Reader */
|
||||
private $delegate;
|
||||
|
||||
public function __construct(Reader $reader)
|
||||
{
|
||||
$this->delegate = $reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
$annotations = [];
|
||||
foreach ($this->delegate->getClassAnnotations($class) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
return $this->delegate->getClassAnnotation($class, $annotationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$annotations = [];
|
||||
foreach ($this->delegate->getMethodAnnotations($method) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
return $this->delegate->getMethodAnnotation($method, $annotationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$annotations = [];
|
||||
foreach ($this->delegate->getPropertyAnnotations($property) as $annot) {
|
||||
$annotations[get_class($annot)] = $annot;
|
||||
}
|
||||
|
||||
return $annotations;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
return $this->delegate->getPropertyAnnotation($property, $annotationName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxies all methods to the delegate.
|
||||
*
|
||||
* @param string $method
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array([$this->delegate, $method], $args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
/**
|
||||
* Marker interface for PHP7/PHP8 compatible support
|
||||
* for named arguments (and constructor property promotion).
|
||||
*
|
||||
* @deprecated Implementing this interface is deprecated
|
||||
* Use the Annotation @NamedArgumentConstructor instead
|
||||
*/
|
||||
interface NamedArgumentConstructorAnnotation
|
||||
{
|
||||
}
|
||||
92
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php
vendored
Normal file
92
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use SplFileObject;
|
||||
|
||||
use function is_file;
|
||||
use function method_exists;
|
||||
use function preg_quote;
|
||||
use function preg_replace;
|
||||
|
||||
/**
|
||||
* Parses a file for namespaces/use/class declarations.
|
||||
*/
|
||||
final class PhpParser
|
||||
{
|
||||
/**
|
||||
* Parses a class.
|
||||
*
|
||||
* @deprecated use parseUseStatements instead
|
||||
*
|
||||
* @param ReflectionClass $class A <code>ReflectionClass</code> object.
|
||||
*
|
||||
* @return array<string, class-string> A list with use statements in the form (Alias => FQN).
|
||||
*/
|
||||
public function parseClass(ReflectionClass $class)
|
||||
{
|
||||
return $this->parseUseStatements($class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a class or function for use statements.
|
||||
*
|
||||
* @param ReflectionClass|ReflectionFunction $reflection
|
||||
*
|
||||
* @psalm-return array<string, string> a list with use statements in the form (Alias => FQN).
|
||||
*/
|
||||
public function parseUseStatements($reflection): array
|
||||
{
|
||||
if (method_exists($reflection, 'getUseStatements')) {
|
||||
return $reflection->getUseStatements();
|
||||
}
|
||||
|
||||
$filename = $reflection->getFileName();
|
||||
|
||||
if ($filename === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$content = $this->getFileContent($filename, $reflection->getStartLine());
|
||||
|
||||
if ($content === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$namespace = preg_quote($reflection->getNamespaceName());
|
||||
$content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
|
||||
$tokenizer = new TokenParser('<?php ' . $content);
|
||||
|
||||
return $tokenizer->parseUseStatements($reflection->getNamespaceName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content of the file right up to the given line number.
|
||||
*
|
||||
* @param string $filename The name of the file to load.
|
||||
* @param int $lineNumber The number of lines to read from file.
|
||||
*
|
||||
* @return string|null The content of the file or null if the file does not exist.
|
||||
*/
|
||||
private function getFileContent($filename, $lineNumber)
|
||||
{
|
||||
if (! is_file($filename)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
$lineCnt = 0;
|
||||
$file = new SplFileObject($filename);
|
||||
while (! $file->eof()) {
|
||||
if ($lineCnt++ === $lineNumber) {
|
||||
break;
|
||||
}
|
||||
|
||||
$content .= $file->fgets();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
232
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PsrCachedReader.php
vendored
Normal file
232
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PsrCachedReader.php
vendored
Normal file
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
use Reflector;
|
||||
|
||||
use function array_map;
|
||||
use function array_merge;
|
||||
use function assert;
|
||||
use function filemtime;
|
||||
use function max;
|
||||
use function rawurlencode;
|
||||
use function time;
|
||||
|
||||
/**
|
||||
* A cache aware annotation reader.
|
||||
*/
|
||||
final class PsrCachedReader implements Reader
|
||||
{
|
||||
/** @var Reader */
|
||||
private $delegate;
|
||||
|
||||
/** @var CacheItemPoolInterface */
|
||||
private $cache;
|
||||
|
||||
/** @var bool */
|
||||
private $debug;
|
||||
|
||||
/** @var array<string, array<object>> */
|
||||
private $loadedAnnotations = [];
|
||||
|
||||
/** @var int[] */
|
||||
private $loadedFilemtimes = [];
|
||||
|
||||
public function __construct(Reader $reader, CacheItemPoolInterface $cache, bool $debug = false)
|
||||
{
|
||||
$this->delegate = $reader;
|
||||
$this->cache = $cache;
|
||||
$this->debug = (bool) $debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
$cacheKey = $class->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class, 'getClassAnnotations', $class);
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
foreach ($this->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
$class = $property->getDeclaringClass();
|
||||
$cacheKey = $class->getName() . '$' . $property->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class, 'getPropertyAnnotations', $property);
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
foreach ($this->getPropertyAnnotations($property) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
$class = $method->getDeclaringClass();
|
||||
$cacheKey = $class->getName() . '#' . $method->getName();
|
||||
|
||||
if (isset($this->loadedAnnotations[$cacheKey])) {
|
||||
return $this->loadedAnnotations[$cacheKey];
|
||||
}
|
||||
|
||||
$annots = $this->fetchFromCache($cacheKey, $class, 'getMethodAnnotations', $method);
|
||||
|
||||
return $this->loadedAnnotations[$cacheKey] = $annots;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
foreach ($this->getMethodAnnotations($method) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function clearLoadedAnnotations(): void
|
||||
{
|
||||
$this->loadedAnnotations = [];
|
||||
$this->loadedFilemtimes = [];
|
||||
}
|
||||
|
||||
/** @return mixed[] */
|
||||
private function fetchFromCache(
|
||||
string $cacheKey,
|
||||
ReflectionClass $class,
|
||||
string $method,
|
||||
Reflector $reflector
|
||||
): array {
|
||||
$cacheKey = rawurlencode($cacheKey);
|
||||
|
||||
$item = $this->cache->getItem($cacheKey);
|
||||
if (($this->debug && ! $this->refresh($cacheKey, $class)) || ! $item->isHit()) {
|
||||
$this->cache->save($item->set($this->delegate->{$method}($reflector)));
|
||||
}
|
||||
|
||||
return $item->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in debug mode to check if the cache is fresh.
|
||||
*
|
||||
* @return bool Returns true if the cache was fresh, or false if the class
|
||||
* being read was modified since writing to the cache.
|
||||
*/
|
||||
private function refresh(string $cacheKey, ReflectionClass $class): bool
|
||||
{
|
||||
$lastModification = $this->getLastModification($class);
|
||||
if ($lastModification === 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$item = $this->cache->getItem('[C]' . $cacheKey);
|
||||
if ($item->isHit() && $item->get() >= $lastModification) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->cache->save($item->set(time()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the class was last modified, testing traits and parents
|
||||
*/
|
||||
private function getLastModification(ReflectionClass $class): int
|
||||
{
|
||||
$filename = $class->getFileName();
|
||||
|
||||
if (isset($this->loadedFilemtimes[$filename])) {
|
||||
return $this->loadedFilemtimes[$filename];
|
||||
}
|
||||
|
||||
$parent = $class->getParentClass();
|
||||
|
||||
$lastModification = max(array_merge(
|
||||
[$filename ? filemtime($filename) : 0],
|
||||
array_map(function (ReflectionClass $reflectionTrait): int {
|
||||
return $this->getTraitLastModificationTime($reflectionTrait);
|
||||
}, $class->getTraits()),
|
||||
array_map(function (ReflectionClass $class): int {
|
||||
return $this->getLastModification($class);
|
||||
}, $class->getInterfaces()),
|
||||
$parent ? [$this->getLastModification($parent)] : []
|
||||
));
|
||||
|
||||
assert($lastModification !== false);
|
||||
|
||||
return $this->loadedFilemtimes[$filename] = $lastModification;
|
||||
}
|
||||
|
||||
private function getTraitLastModificationTime(ReflectionClass $reflectionTrait): int
|
||||
{
|
||||
$fileName = $reflectionTrait->getFileName();
|
||||
|
||||
if (isset($this->loadedFilemtimes[$fileName])) {
|
||||
return $this->loadedFilemtimes[$fileName];
|
||||
}
|
||||
|
||||
$lastModificationTime = max(array_merge(
|
||||
[$fileName ? filemtime($fileName) : 0],
|
||||
array_map(function (ReflectionClass $reflectionTrait): int {
|
||||
return $this->getTraitLastModificationTime($reflectionTrait);
|
||||
}, $reflectionTrait->getTraits())
|
||||
));
|
||||
|
||||
assert($lastModificationTime !== false);
|
||||
|
||||
return $this->loadedFilemtimes[$fileName] = $lastModificationTime;
|
||||
}
|
||||
}
|
||||
80
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php
vendored
Normal file
80
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Interface for annotation readers.
|
||||
*/
|
||||
interface Reader
|
||||
{
|
||||
/**
|
||||
* Gets the annotations applied to a class.
|
||||
*
|
||||
* @param ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
*
|
||||
* @return array<object> An array of Annotations.
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class);
|
||||
|
||||
/**
|
||||
* Gets a class annotation.
|
||||
*
|
||||
* @param ReflectionClass $class The ReflectionClass of the class from which
|
||||
* the class annotations should be read.
|
||||
* @param class-string<T> $annotationName The name of the annotation.
|
||||
*
|
||||
* @return T|null The Annotation or NULL, if the requested annotation does not exist.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName);
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a method.
|
||||
*
|
||||
* @param ReflectionMethod $method The ReflectionMethod of the method from which
|
||||
* the annotations should be read.
|
||||
*
|
||||
* @return array<object> An array of Annotations.
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method);
|
||||
|
||||
/**
|
||||
* Gets a method annotation.
|
||||
*
|
||||
* @param ReflectionMethod $method The ReflectionMethod to read the annotations from.
|
||||
* @param class-string<T> $annotationName The name of the annotation.
|
||||
*
|
||||
* @return T|null The Annotation or NULL, if the requested annotation does not exist.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName);
|
||||
|
||||
/**
|
||||
* Gets the annotations applied to a property.
|
||||
*
|
||||
* @param ReflectionProperty $property The ReflectionProperty of the property
|
||||
* from which the annotations should be read.
|
||||
*
|
||||
* @return array<object> An array of Annotations.
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property);
|
||||
|
||||
/**
|
||||
* Gets a property annotation.
|
||||
*
|
||||
* @param ReflectionProperty $property The ReflectionProperty to read the annotations from.
|
||||
* @param class-string<T> $annotationName The name of the annotation.
|
||||
*
|
||||
* @return T|null The Annotation or NULL, if the requested annotation does not exist.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName);
|
||||
}
|
||||
114
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php
vendored
Normal file
114
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Simple Annotation Reader.
|
||||
*
|
||||
* This annotation reader is intended to be used in projects where you have
|
||||
* full-control over all annotations that are available.
|
||||
*
|
||||
* @deprecated Deprecated in favour of using AnnotationReader
|
||||
*/
|
||||
class SimpleAnnotationReader implements Reader
|
||||
{
|
||||
/** @var DocParser */
|
||||
private $parser;
|
||||
|
||||
/**
|
||||
* Initializes a new SimpleAnnotationReader.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->parser = new DocParser();
|
||||
$this->parser->setIgnoreNotImportedAnnotations(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a namespace in which we will look for annotations.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addNamespace($namespace)
|
||||
{
|
||||
$this->parser->addNamespace($namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotations(ReflectionClass $class)
|
||||
{
|
||||
return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotations(ReflectionMethod $method)
|
||||
{
|
||||
return $this->parser->parse(
|
||||
$method->getDocComment(),
|
||||
'method ' . $method->getDeclaringClass()->name . '::' . $method->getName() . '()'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotations(ReflectionProperty $property)
|
||||
{
|
||||
return $this->parser->parse(
|
||||
$property->getDocComment(),
|
||||
'property ' . $property->getDeclaringClass()->name . '::$' . $property->getName()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getClassAnnotation(ReflectionClass $class, $annotationName)
|
||||
{
|
||||
foreach ($this->getClassAnnotations($class) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
|
||||
{
|
||||
foreach ($this->getMethodAnnotations($method) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
|
||||
{
|
||||
foreach ($this->getPropertyAnnotations($property) as $annot) {
|
||||
if ($annot instanceof $annotationName) {
|
||||
return $annot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
206
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php
vendored
Normal file
206
vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php
vendored
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Annotations;
|
||||
|
||||
use function array_merge;
|
||||
use function count;
|
||||
use function explode;
|
||||
use function strtolower;
|
||||
use function token_get_all;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
use const T_AS;
|
||||
use const T_COMMENT;
|
||||
use const T_DOC_COMMENT;
|
||||
use const T_NAME_FULLY_QUALIFIED;
|
||||
use const T_NAME_QUALIFIED;
|
||||
use const T_NAMESPACE;
|
||||
use const T_NS_SEPARATOR;
|
||||
use const T_STRING;
|
||||
use const T_USE;
|
||||
use const T_WHITESPACE;
|
||||
|
||||
/**
|
||||
* Parses a file for namespaces/use/class declarations.
|
||||
*/
|
||||
class TokenParser
|
||||
{
|
||||
/**
|
||||
* The token list.
|
||||
*
|
||||
* @phpstan-var list<mixed[]>
|
||||
*/
|
||||
private $tokens;
|
||||
|
||||
/**
|
||||
* The number of tokens.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $numTokens;
|
||||
|
||||
/**
|
||||
* The current array pointer.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $pointer = 0;
|
||||
|
||||
/** @param string $contents */
|
||||
public function __construct($contents)
|
||||
{
|
||||
$this->tokens = token_get_all($contents);
|
||||
|
||||
// The PHP parser sets internal compiler globals for certain things. Annoyingly, the last docblock comment it
|
||||
// saw gets stored in doc_comment. When it comes to compile the next thing to be include()d this stored
|
||||
// doc_comment becomes owned by the first thing the compiler sees in the file that it considers might have a
|
||||
// docblock. If the first thing in the file is a class without a doc block this would cause calls to
|
||||
// getDocBlock() on said class to return our long lost doc_comment. Argh.
|
||||
// To workaround, cause the parser to parse an empty docblock. Sure getDocBlock() will return this, but at least
|
||||
// it's harmless to us.
|
||||
token_get_all("<?php\n/**\n *\n */");
|
||||
|
||||
$this->numTokens = count($this->tokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next non whitespace and non comment token.
|
||||
*
|
||||
* @param bool $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped.
|
||||
* If FALSE then only whitespace and normal comments are skipped.
|
||||
*
|
||||
* @return mixed[]|string|null The token if exists, null otherwise.
|
||||
*/
|
||||
public function next($docCommentIsComment = true)
|
||||
{
|
||||
for ($i = $this->pointer; $i < $this->numTokens; $i++) {
|
||||
$this->pointer++;
|
||||
if (
|
||||
$this->tokens[$i][0] === T_WHITESPACE ||
|
||||
$this->tokens[$i][0] === T_COMMENT ||
|
||||
($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return $this->tokens[$i];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a single use statement.
|
||||
*
|
||||
* @return array<string, string> A list with all found class names for a use statement.
|
||||
*/
|
||||
public function parseUseStatement()
|
||||
{
|
||||
$groupRoot = '';
|
||||
$class = '';
|
||||
$alias = '';
|
||||
$statements = [];
|
||||
$explicitAlias = false;
|
||||
while (($token = $this->next())) {
|
||||
if (! $explicitAlias && $token[0] === T_STRING) {
|
||||
$class .= $token[1];
|
||||
$alias = $token[1];
|
||||
} elseif ($explicitAlias && $token[0] === T_STRING) {
|
||||
$alias = $token[1];
|
||||
} elseif (
|
||||
PHP_VERSION_ID >= 80000 &&
|
||||
($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)
|
||||
) {
|
||||
$class .= $token[1];
|
||||
|
||||
$classSplit = explode('\\', $token[1]);
|
||||
$alias = $classSplit[count($classSplit) - 1];
|
||||
} elseif ($token[0] === T_NS_SEPARATOR) {
|
||||
$class .= '\\';
|
||||
$alias = '';
|
||||
} elseif ($token[0] === T_AS) {
|
||||
$explicitAlias = true;
|
||||
$alias = '';
|
||||
} elseif ($token === ',') {
|
||||
$statements[strtolower($alias)] = $groupRoot . $class;
|
||||
$class = '';
|
||||
$alias = '';
|
||||
$explicitAlias = false;
|
||||
} elseif ($token === ';') {
|
||||
$statements[strtolower($alias)] = $groupRoot . $class;
|
||||
break;
|
||||
} elseif ($token === '{') {
|
||||
$groupRoot = $class;
|
||||
$class = '';
|
||||
} elseif ($token === '}') {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all use statements.
|
||||
*
|
||||
* @param string $namespaceName The namespace name of the reflected class.
|
||||
*
|
||||
* @return array<string, string> A list with all found use statements.
|
||||
*/
|
||||
public function parseUseStatements($namespaceName)
|
||||
{
|
||||
$statements = [];
|
||||
while (($token = $this->next())) {
|
||||
if ($token[0] === T_USE) {
|
||||
$statements = array_merge($statements, $this->parseUseStatement());
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($token[0] !== T_NAMESPACE || $this->parseNamespace() !== $namespaceName) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get fresh array for new namespace. This is to prevent the parser to collect the use statements
|
||||
// for a previous namespace with the same name. This is the case if a namespace is defined twice
|
||||
// or if a namespace with the same name is commented out.
|
||||
$statements = [];
|
||||
}
|
||||
|
||||
return $statements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace.
|
||||
*
|
||||
* @return string The found namespace.
|
||||
*/
|
||||
public function parseNamespace()
|
||||
{
|
||||
$name = '';
|
||||
while (
|
||||
($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR || (
|
||||
PHP_VERSION_ID >= 80000 &&
|
||||
($token[0] === T_NAME_QUALIFIED || $token[0] === T_NAME_FULLY_QUALIFIED)
|
||||
))
|
||||
) {
|
||||
$name .= $token[1];
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the class name.
|
||||
*
|
||||
* @return string The found class name.
|
||||
*/
|
||||
public function parseClass()
|
||||
{
|
||||
// Namespaces and class names are tokenized the same: T_STRINGs
|
||||
// separated by T_NS_SEPARATOR so we can use one function to provide
|
||||
// both.
|
||||
return $this->parseNamespace();
|
||||
}
|
||||
}
|
||||
15
vendor/doctrine/annotations/psalm.xml
vendored
Normal file
15
vendor/doctrine/annotations/psalm.xml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="7"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="lib/Doctrine/Common/Annotations" />
|
||||
<ignoreFiles>
|
||||
<directory name="vendor" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
||||
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
19
vendor/doctrine/cache/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2015 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.
|
||||
13
vendor/doctrine/cache/README.md
vendored
Normal file
13
vendor/doctrine/cache/README.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Doctrine Cache
|
||||
|
||||
[](https://github.com/doctrine/cache/actions)
|
||||
[](https://codecov.io/gh/doctrine/cache/branch/1.10.x)
|
||||
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
[](https://packagist.org/packages/doctrine/cache)
|
||||
|
||||
Cache component extracted from the Doctrine Common project. [Documentation](https://www.doctrine-project.org/projects/doctrine-cache/en/current/index.html)
|
||||
|
||||
This library is deprecated and will no longer receive bug fixes from the
|
||||
Doctrine Project. Please use a different cache library, preferably PSR-6 or
|
||||
PSR-16 instead.
|
||||
27
vendor/doctrine/cache/UPGRADE-1.11.md
vendored
Normal file
27
vendor/doctrine/cache/UPGRADE-1.11.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# Upgrade to 1.11
|
||||
|
||||
doctrine/cache will no longer be maintained and all cache implementations have
|
||||
been marked as deprecated. These implementations will be removed in 2.0, which
|
||||
will only contain interfaces to provide a lightweight package for backward
|
||||
compatibility.
|
||||
|
||||
There are two new classes to use in the `Doctrine\Common\Cache\Psr6` namespace:
|
||||
* The `CacheAdapter` class allows using any Doctrine Cache as PSR-6 cache. This
|
||||
is useful to provide a forward compatibility layer in libraries that accept
|
||||
Doctrine cache implementations and switch to PSR-6.
|
||||
* The `DoctrineProvider` class allows using any PSR-6 cache as Doctrine cache.
|
||||
This implementation is designed for libraries that leak the cache and want to
|
||||
switch to allowing PSR-6 implementations. This class is design to be used
|
||||
during the transition phase of sunsetting doctrine/cache support.
|
||||
|
||||
A full example to setup a filesystem based PSR-6 cache with symfony/cache
|
||||
using the `DoctrineProvider` to convert back to Doctrine's `Cache` interface:
|
||||
|
||||
```php
|
||||
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
|
||||
$cachePool = new FilesystemAdapter();
|
||||
$cache = DoctrineProvider::wrap($cachePool);
|
||||
// $cache instanceof \Doctrine\Common\Cache\Cache
|
||||
```
|
||||
16
vendor/doctrine/cache/UPGRADE-1.4.md
vendored
Normal file
16
vendor/doctrine/cache/UPGRADE-1.4.md
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Upgrade to 1.4
|
||||
|
||||
## Minor BC Break: `Doctrine\Common\Cache\FileCache#$extension` is now `private`.
|
||||
|
||||
If you need to override the value of `Doctrine\Common\Cache\FileCache#$extension`, then use the
|
||||
second parameter of `Doctrine\Common\Cache\FileCache#__construct()` instead of overriding
|
||||
the property in your own implementation.
|
||||
|
||||
## Minor BC Break: file based caches paths changed
|
||||
|
||||
`Doctrine\Common\Cache\FileCache`, `Doctrine\Common\Cache\PhpFileCache` and
|
||||
`Doctrine\Common\Cache\FilesystemCache` are using a different cache paths structure.
|
||||
|
||||
If you rely on warmed up caches for deployments, consider that caches generated
|
||||
with `doctrine/cache` `<1.4` are not compatible with the new directory structure,
|
||||
and will be ignored.
|
||||
50
vendor/doctrine/cache/composer.json
vendored
Normal file
50
vendor/doctrine/cache/composer.json
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "doctrine/cache",
|
||||
"type": "library",
|
||||
"description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.",
|
||||
"keywords": [
|
||||
"php",
|
||||
"cache",
|
||||
"caching",
|
||||
"abstraction",
|
||||
"redis",
|
||||
"memcached",
|
||||
"couchdb",
|
||||
"xcache",
|
||||
"apcu"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/cache.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"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "~7.1 || ^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
|
||||
"doctrine/coding-standard": "^9",
|
||||
"psr/cache": "^1.0 || ^2.0 || ^3.0",
|
||||
"cache/integration-tests": "dev-master",
|
||||
"symfony/cache": "^4.4 || ^5.4 || ^6",
|
||||
"symfony/var-exporter": "^4.4 || ^5.4 || ^6"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/common": ">2.2,<2.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Doctrine\\Tests\\": "tests/Doctrine/Tests" }
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||
}
|
||||
}
|
||||
}
|
||||
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
90
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface Cache
|
||||
{
|
||||
public const STATS_HITS = 'hits';
|
||||
public const STATS_MISSES = 'misses';
|
||||
public const STATS_UPTIME = 'uptime';
|
||||
public const STATS_MEMORY_USAGE = 'memory_usage';
|
||||
public const STATS_MEMORY_AVAILABLE = 'memory_available';
|
||||
/**
|
||||
* Only for backward compatibility (may be removed in next major release)
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public const STATS_MEMORY_AVAILIABLE = 'memory_available';
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
public function fetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
public function contains($id);
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* If a cache entry with the given id already exists, its data will be replaced.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param mixed $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime in number of seconds for this cache entry.
|
||||
* If zero (the default), the entry never expires (although it may be deleted from the cache
|
||||
* to make place for other entries).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
* Deleting a non-existing entry is considered successful.
|
||||
*/
|
||||
public function delete($id);
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* The server's statistics array has the following values:
|
||||
*
|
||||
* - <b>hits</b>
|
||||
* Number of keys that have been requested and found present.
|
||||
*
|
||||
* - <b>misses</b>
|
||||
* Number of items that have been requested and not found.
|
||||
*
|
||||
* - <b>uptime</b>
|
||||
* Time that the server is running.
|
||||
*
|
||||
* - <b>memory_usage</b>
|
||||
* Memory used by this server to store items.
|
||||
*
|
||||
* - <b>memory_available</b>
|
||||
* Memory allowed to use for storage.
|
||||
*
|
||||
* @return mixed[]|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
public function getStats();
|
||||
}
|
||||
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
325
vendor/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php
vendored
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
use function array_combine;
|
||||
use function array_key_exists;
|
||||
use function array_map;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Base class for cache provider implementations.
|
||||
*/
|
||||
abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiOperationCache
|
||||
{
|
||||
public const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]';
|
||||
|
||||
/**
|
||||
* The namespace to prefix all cache ids with.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $namespace = '';
|
||||
|
||||
/**
|
||||
* The namespace version.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private $namespaceVersion;
|
||||
|
||||
/**
|
||||
* Sets the namespace to prefix all cache ids with.
|
||||
*
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespace($namespace)
|
||||
{
|
||||
$this->namespace = (string) $namespace;
|
||||
$this->namespaceVersion = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the namespace that prefixes all cache ids.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace()
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetch($id)
|
||||
{
|
||||
return $this->doFetch($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fetchMultiple(array $keys)
|
||||
{
|
||||
if (empty($keys)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// note: the array_combine() is in place to keep an association between our $keys and the $namespacedKeys
|
||||
$namespacedKeys = array_combine($keys, array_map([$this, 'getNamespacedId'], $keys));
|
||||
$items = $this->doFetchMultiple($namespacedKeys);
|
||||
$foundItems = [];
|
||||
|
||||
// no internal array function supports this sort of mapping: needs to be iterative
|
||||
// this filters and combines keys in one pass
|
||||
foreach ($namespacedKeys as $requestedKey => $namespacedKey) {
|
||||
if (! isset($items[$namespacedKey]) && ! array_key_exists($namespacedKey, $items)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$foundItems[$requestedKey] = $items[$namespacedKey];
|
||||
}
|
||||
|
||||
return $foundItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$namespacedKeysAndValues = [];
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$namespacedKeysAndValues[$this->getNamespacedId($key)] = $value;
|
||||
}
|
||||
|
||||
return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function contains($id)
|
||||
{
|
||||
return $this->doContains($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save($id, $data, $lifeTime = 0)
|
||||
{
|
||||
return $this->doSave($this->getNamespacedId($id), $data, $lifeTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple(array $keys)
|
||||
{
|
||||
return $this->doDeleteMultiple(array_map([$this, 'getNamespacedId'], $keys));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->doDelete($this->getNamespacedId($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getStats()
|
||||
{
|
||||
return $this->doGetStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function flushAll()
|
||||
{
|
||||
return $this->doFlush();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteAll()
|
||||
{
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$namespaceVersion = $this->getNamespaceVersion() + 1;
|
||||
|
||||
if ($this->doSave($namespaceCacheKey, $namespaceVersion)) {
|
||||
$this->namespaceVersion = $namespaceVersion;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefixes the passed id with the configured namespace value.
|
||||
*
|
||||
* @param string $id The id to namespace.
|
||||
*
|
||||
* @return string The namespaced id.
|
||||
*/
|
||||
private function getNamespacedId(string $id): string
|
||||
{
|
||||
$namespaceVersion = $this->getNamespaceVersion();
|
||||
|
||||
return sprintf('%s[%s][%s]', $this->namespace, $id, $namespaceVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace cache key.
|
||||
*/
|
||||
private function getNamespaceCacheKey(): string
|
||||
{
|
||||
return sprintf(self::DOCTRINE_NAMESPACE_CACHEKEY, $this->namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the namespace version.
|
||||
*/
|
||||
private function getNamespaceVersion(): int
|
||||
{
|
||||
if ($this->namespaceVersion !== null) {
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
$namespaceCacheKey = $this->getNamespaceCacheKey();
|
||||
$this->namespaceVersion = (int) $this->doFetch($namespaceCacheKey) ?: 1;
|
||||
|
||||
return $this->namespaceVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of doFetchMultiple. Each driver that supports multi-get should owerwrite it.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return mixed[] Array of values retrieved for the given keys.
|
||||
*/
|
||||
protected function doFetchMultiple(array $keys)
|
||||
{
|
||||
$returnValues = [];
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$item = $this->doFetch($key);
|
||||
if ($item === false && ! $this->doContains($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$returnValues[$key] = $item;
|
||||
}
|
||||
|
||||
return $returnValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches an entry from the cache.
|
||||
*
|
||||
* @param string $id The id of the cache entry to fetch.
|
||||
*
|
||||
* @return mixed|false The cached data or FALSE, if no cache entry exists for the given id.
|
||||
*/
|
||||
abstract protected function doFetch($id);
|
||||
|
||||
/**
|
||||
* Tests if an entry exists in the cache.
|
||||
*
|
||||
* @param string $id The cache id of the entry to check for.
|
||||
*
|
||||
* @return bool TRUE if a cache entry exists for the given cache id, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doContains($id);
|
||||
|
||||
/**
|
||||
* Default implementation of doSaveMultiple. Each driver that supports multi-put should override it.
|
||||
*
|
||||
* @param mixed[] $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
protected function doSaveMultiple(array $keysAndValues, $lifetime = 0)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
if ($this->doSave($key, $value, $lifetime)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts data into the cache.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
* @param string $data The cache entry/data.
|
||||
* @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this
|
||||
* cache entry (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the entry was successfully stored in the cache, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doSave($id, $data, $lifeTime = 0);
|
||||
|
||||
/**
|
||||
* Default implementation of doDeleteMultiple. Each driver that supports multi-delete should override it.
|
||||
*
|
||||
* @param string[] $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't
|
||||
*/
|
||||
protected function doDeleteMultiple(array $keys)
|
||||
{
|
||||
$success = true;
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if ($this->doDelete($key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$success = false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a cache entry.
|
||||
*
|
||||
* @param string $id The cache id.
|
||||
*
|
||||
* @return bool TRUE if the cache entry was successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doDelete($id);
|
||||
|
||||
/**
|
||||
* Flushes all cache entries.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
abstract protected function doFlush();
|
||||
|
||||
/**
|
||||
* Retrieves cached information from the data store.
|
||||
*
|
||||
* @return mixed[]|null An associative array with server's statistics if available, NULL otherwise.
|
||||
*/
|
||||
abstract protected function doGetStats();
|
||||
}
|
||||
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
21
vendor/doctrine/cache/lib/Doctrine/Common/Cache/ClearableCache.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* Intended to be used for partial clearing of a cache namespace. For a more
|
||||
* global "flushing", see {@see FlushableCache}.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface ClearableCache
|
||||
{
|
||||
/**
|
||||
* Deletes all cache entries in the current cache namespace.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully deleted, FALSE otherwise.
|
||||
*/
|
||||
public function deleteAll();
|
||||
}
|
||||
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
18
vendor/doctrine/cache/lib/Doctrine/Common/Cache/FlushableCache.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache that can be flushed.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface FlushableCache
|
||||
{
|
||||
/**
|
||||
* Flushes all cache entries, globally.
|
||||
*
|
||||
* @return bool TRUE if the cache entries were successfully flushed, FALSE otherwise.
|
||||
*/
|
||||
public function flushAll();
|
||||
}
|
||||
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
22
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiDeleteCache.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiDeleteCache
|
||||
{
|
||||
/**
|
||||
* Deletes several cache entries.
|
||||
*
|
||||
* @param string[] $keys Array of keys to delete from cache
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function deleteMultiple(array $keys);
|
||||
}
|
||||
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
23
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to get many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiGetCache
|
||||
{
|
||||
/**
|
||||
* Returns an associative array of values for keys is found in cache.
|
||||
*
|
||||
* @param string[] $keys Array of keys to retrieve from cache
|
||||
*
|
||||
* @return mixed[] Array of retrieved values, indexed by the specified keys.
|
||||
* Values that couldn't be retrieved are not contained in this array.
|
||||
*/
|
||||
public function fetchMultiple(array $keys);
|
||||
}
|
||||
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
12
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiOperationCache.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that supports multiple items manipulation.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiOperationCache extends MultiGetCache, MultiDeleteCache, MultiPutCache
|
||||
{
|
||||
}
|
||||
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
24
vendor/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache;
|
||||
|
||||
/**
|
||||
* Interface for cache drivers that allows to put many items at once.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface MultiPutCache
|
||||
{
|
||||
/**
|
||||
* Returns a boolean value indicating if the operation succeeded.
|
||||
*
|
||||
* @param mixed[] $keysAndValues Array of keys and values to save in cache
|
||||
* @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these
|
||||
* cache entries (0 => infinite lifeTime).
|
||||
*
|
||||
* @return bool TRUE if the operation was successful, FALSE if it wasn't.
|
||||
*/
|
||||
public function saveMultiple(array $keysAndValues, $lifetime = 0);
|
||||
}
|
||||
340
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php
vendored
Normal file
340
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheAdapter.php
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\ClearableCache;
|
||||
use Doctrine\Common\Cache\MultiDeleteCache;
|
||||
use Doctrine\Common\Cache\MultiGetCache;
|
||||
use Doctrine\Common\Cache\MultiPutCache;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\DoctrineProvider as SymfonyDoctrineProvider;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function current;
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_object;
|
||||
use function is_string;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
use function strpbrk;
|
||||
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
final class CacheAdapter implements CacheItemPoolInterface
|
||||
{
|
||||
private const RESERVED_CHARACTERS = '{}()/\@:';
|
||||
|
||||
/** @var Cache */
|
||||
private $cache;
|
||||
|
||||
/** @var array<CacheItem|TypedCacheItem> */
|
||||
private $deferredItems = [];
|
||||
|
||||
public static function wrap(Cache $cache): CacheItemPoolInterface
|
||||
{
|
||||
if ($cache instanceof DoctrineProvider && ! $cache->getNamespace()) {
|
||||
return $cache->getPool();
|
||||
}
|
||||
|
||||
if ($cache instanceof SymfonyDoctrineProvider && ! $cache->getNamespace()) {
|
||||
$getPool = function () {
|
||||
// phpcs:ignore Squiz.Scope.StaticThisUsage.Found
|
||||
return $this->pool;
|
||||
};
|
||||
|
||||
return $getPool->bindTo($cache, SymfonyDoctrineProvider::class)();
|
||||
}
|
||||
|
||||
return new self($cache);
|
||||
}
|
||||
|
||||
private function __construct(Cache $cache)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function getCache(): Cache
|
||||
{
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getItem($key): CacheItemInterface
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
|
||||
if (isset($this->deferredItems[$key])) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
$value = $this->cache->fetch($key);
|
||||
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
if ($value !== false) {
|
||||
return new TypedCacheItem($key, $value, true);
|
||||
}
|
||||
|
||||
return new TypedCacheItem($key, null, false);
|
||||
}
|
||||
|
||||
if ($value !== false) {
|
||||
return new CacheItem($key, $value, true);
|
||||
}
|
||||
|
||||
return new CacheItem($key, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getItems(array $keys = []): array
|
||||
{
|
||||
if ($this->deferredItems) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
assert(self::validKeys($keys));
|
||||
|
||||
$values = $this->doFetchMultiple($keys);
|
||||
$items = [];
|
||||
|
||||
if (PHP_VERSION_ID >= 80000) {
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $values)) {
|
||||
$items[$key] = new TypedCacheItem($key, $values[$key], true);
|
||||
} else {
|
||||
$items[$key] = new TypedCacheItem($key, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $values)) {
|
||||
$items[$key] = new CacheItem($key, $values[$key], true);
|
||||
} else {
|
||||
$items[$key] = new CacheItem($key, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hasItem($key): bool
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
|
||||
if (isset($this->deferredItems[$key])) {
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
return $this->cache->contains($key);
|
||||
}
|
||||
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->deferredItems = [];
|
||||
|
||||
if (! $this->cache instanceof ClearableCache) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->cache->deleteAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteItem($key): bool
|
||||
{
|
||||
assert(self::validKey($key));
|
||||
unset($this->deferredItems[$key]);
|
||||
|
||||
return $this->cache->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function deleteItems(array $keys): bool
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
assert(self::validKey($key));
|
||||
unset($this->deferredItems[$key]);
|
||||
}
|
||||
|
||||
return $this->doDeleteMultiple($keys);
|
||||
}
|
||||
|
||||
public function save(CacheItemInterface $item): bool
|
||||
{
|
||||
return $this->saveDeferred($item) && $this->commit();
|
||||
}
|
||||
|
||||
public function saveDeferred(CacheItemInterface $item): bool
|
||||
{
|
||||
if (! $item instanceof CacheItem && ! $item instanceof TypedCacheItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->deferredItems[$item->getKey()] = $item;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function commit(): bool
|
||||
{
|
||||
if (! $this->deferredItems) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$now = microtime(true);
|
||||
$itemsCount = 0;
|
||||
$byLifetime = [];
|
||||
$expiredKeys = [];
|
||||
|
||||
foreach ($this->deferredItems as $key => $item) {
|
||||
$lifetime = ($item->getExpiry() ?? $now) - $now;
|
||||
|
||||
if ($lifetime < 0) {
|
||||
$expiredKeys[] = $key;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
++$itemsCount;
|
||||
$byLifetime[(int) $lifetime][$key] = $item->get();
|
||||
}
|
||||
|
||||
$this->deferredItems = [];
|
||||
|
||||
switch (count($expiredKeys)) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
$this->cache->delete(current($expiredKeys));
|
||||
break;
|
||||
default:
|
||||
$this->doDeleteMultiple($expiredKeys);
|
||||
break;
|
||||
}
|
||||
|
||||
if ($itemsCount === 1) {
|
||||
return $this->cache->save($key, $item->get(), (int) $lifetime);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($byLifetime as $lifetime => $values) {
|
||||
$success = $this->doSaveMultiple($values, $lifetime) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $key
|
||||
*/
|
||||
private static function validKey($key): bool
|
||||
{
|
||||
if (! is_string($key)) {
|
||||
throw new InvalidArgument(sprintf('Cache key must be string, "%s" given.', is_object($key) ? get_class($key) : gettype($key)));
|
||||
}
|
||||
|
||||
if ($key === '') {
|
||||
throw new InvalidArgument('Cache key length must be greater than zero.');
|
||||
}
|
||||
|
||||
if (strpbrk($key, self::RESERVED_CHARACTERS) !== false) {
|
||||
throw new InvalidArgument(sprintf('Cache key "%s" contains reserved characters "%s".', $key, self::RESERVED_CHARACTERS));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*/
|
||||
private static function validKeys(array $keys): bool
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
self::validKey($key);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*/
|
||||
private function doDeleteMultiple(array $keys): bool
|
||||
{
|
||||
if ($this->cache instanceof MultiDeleteCache) {
|
||||
return $this->cache->deleteMultiple($keys);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($keys as $key) {
|
||||
$success = $this->cache->delete($key) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keys
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
private function doFetchMultiple(array $keys): array
|
||||
{
|
||||
if ($this->cache instanceof MultiGetCache) {
|
||||
return $this->cache->fetchMultiple($keys);
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($keys as $key) {
|
||||
$value = $this->cache->fetch($key);
|
||||
if (! $value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values[$key] = $value;
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $keysAndValues
|
||||
*/
|
||||
private function doSaveMultiple(array $keysAndValues, int $lifetime = 0): bool
|
||||
{
|
||||
if ($this->cache instanceof MultiPutCache) {
|
||||
return $this->cache->saveMultiple($keysAndValues, $lifetime);
|
||||
}
|
||||
|
||||
$success = true;
|
||||
foreach ($keysAndValues as $key => $value) {
|
||||
$success = $this->cache->save($key, $value, $lifetime) && $success;
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
}
|
||||
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheItem.php
vendored
Normal file
118
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/CacheItem.php
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use TypeError;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_int;
|
||||
use function is_object;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
|
||||
final class CacheItem implements CacheItemInterface
|
||||
{
|
||||
/** @var string */
|
||||
private $key;
|
||||
/** @var mixed */
|
||||
private $value;
|
||||
/** @var bool */
|
||||
private $isHit;
|
||||
/** @var float|null */
|
||||
private $expiry;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @param mixed $data
|
||||
*/
|
||||
public function __construct(string $key, $data, bool $isHit)
|
||||
{
|
||||
$this->key = $key;
|
||||
$this->value = $data;
|
||||
$this->isHit = $isHit;
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->isHit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function set($value): self
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAt($expiration): self
|
||||
{
|
||||
if ($expiration === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($expiration instanceof DateTimeInterface) {
|
||||
$this->expiry = (float) $expiration->format('U.u');
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $expiration to be an instance of DateTimeInterface or null, got %s',
|
||||
is_object($expiration) ? get_class($expiration) : gettype($expiration)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAfter($time): self
|
||||
{
|
||||
if ($time === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($time instanceof DateInterval) {
|
||||
$this->expiry = microtime(true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u');
|
||||
} elseif (is_int($time)) {
|
||||
$this->expiry = $time + microtime(true);
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $time to be either an integer, an instance of DateInterval or null, got %s',
|
||||
is_object($time) ? get_class($time) : gettype($time)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getExpiry(): ?float
|
||||
{
|
||||
return $this->expiry;
|
||||
}
|
||||
}
|
||||
135
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/DoctrineProvider.php
vendored
Normal file
135
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/DoctrineProvider.php
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\CacheProvider;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Cache\Adapter\DoctrineAdapter as SymfonyDoctrineAdapter;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
use function rawurlencode;
|
||||
|
||||
/**
|
||||
* This class was copied from the Symfony Framework, see the original copyright
|
||||
* notice above. The code is distributed subject to the license terms in
|
||||
* https://github.com/symfony/symfony/blob/ff0cf61278982539c49e467db9ab13cbd342f76d/LICENSE
|
||||
*/
|
||||
final class DoctrineProvider extends CacheProvider
|
||||
{
|
||||
/** @var CacheItemPoolInterface */
|
||||
private $pool;
|
||||
|
||||
public static function wrap(CacheItemPoolInterface $pool): Cache
|
||||
{
|
||||
if ($pool instanceof CacheAdapter) {
|
||||
return $pool->getCache();
|
||||
}
|
||||
|
||||
if ($pool instanceof SymfonyDoctrineAdapter) {
|
||||
$getCache = function () {
|
||||
// phpcs:ignore Squiz.Scope.StaticThisUsage.Found
|
||||
return $this->provider;
|
||||
};
|
||||
|
||||
return $getCache->bindTo($pool, SymfonyDoctrineAdapter::class)();
|
||||
}
|
||||
|
||||
return new self($pool);
|
||||
}
|
||||
|
||||
private function __construct(CacheItemPoolInterface $pool)
|
||||
{
|
||||
$this->pool = $pool;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
public function getPool(): CacheItemPoolInterface
|
||||
{
|
||||
return $this->pool;
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
if ($this->pool instanceof ResetInterface) {
|
||||
$this->pool->reset();
|
||||
}
|
||||
|
||||
$this->setNamespace($this->getNamespace());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doFetch($id)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
return $item->isHit() ? $item->get() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doContains($id)
|
||||
{
|
||||
return $this->pool->hasItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doSave($id, $data, $lifeTime = 0)
|
||||
{
|
||||
$item = $this->pool->getItem(rawurlencode($id));
|
||||
|
||||
if (0 < $lifeTime) {
|
||||
$item->expiresAfter($lifeTime);
|
||||
}
|
||||
|
||||
return $this->pool->save($item->set($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doDelete($id)
|
||||
{
|
||||
return $this->pool->deleteItem(rawurlencode($id));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function doFlush()
|
||||
{
|
||||
return $this->pool->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function doGetStats()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
13
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/InvalidArgument.php
vendored
Normal file
13
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/InvalidArgument.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Psr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class InvalidArgument extends InvalidArgumentException implements PsrInvalidArgumentException
|
||||
{
|
||||
}
|
||||
99
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/TypedCacheItem.php
vendored
Normal file
99
vendor/doctrine/cache/lib/Doctrine/Common/Cache/Psr6/TypedCacheItem.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Cache\Psr6;
|
||||
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use DateTimeInterface;
|
||||
use Psr\Cache\CacheItemInterface;
|
||||
use TypeError;
|
||||
|
||||
use function get_debug_type;
|
||||
use function is_int;
|
||||
use function microtime;
|
||||
use function sprintf;
|
||||
|
||||
final class TypedCacheItem implements CacheItemInterface
|
||||
{
|
||||
private ?float $expiry = null;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function __construct(
|
||||
private string $key,
|
||||
private mixed $value,
|
||||
private bool $isHit,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function get(): mixed
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function isHit(): bool
|
||||
{
|
||||
return $this->isHit;
|
||||
}
|
||||
|
||||
public function set(mixed $value): static
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAt($expiration): static
|
||||
{
|
||||
if ($expiration === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($expiration instanceof DateTimeInterface) {
|
||||
$this->expiry = (float) $expiration->format('U.u');
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $expiration to be an instance of DateTimeInterface or null, got %s',
|
||||
get_debug_type($expiration)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function expiresAfter($time): static
|
||||
{
|
||||
if ($time === null) {
|
||||
$this->expiry = null;
|
||||
} elseif ($time instanceof DateInterval) {
|
||||
$this->expiry = microtime(true) + DateTime::createFromFormat('U', 0)->add($time)->format('U.u');
|
||||
} elseif (is_int($time)) {
|
||||
$this->expiry = $time + microtime(true);
|
||||
} else {
|
||||
throw new TypeError(sprintf(
|
||||
'Expected $time to be either an integer, an instance of DateInterval or null, got %s',
|
||||
get_debug_type($time)
|
||||
));
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function getExpiry(): ?float
|
||||
{
|
||||
return $this->expiry;
|
||||
}
|
||||
}
|
||||
60
vendor/doctrine/common/.doctrine-project.json
vendored
Normal file
60
vendor/doctrine/common/.doctrine-project.json
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"active": true,
|
||||
"name": "Common",
|
||||
"slug": "common",
|
||||
"docsSlug": "doctrine-common",
|
||||
"versions": [
|
||||
{
|
||||
"name": "3.4",
|
||||
"branchName": "3.4.x",
|
||||
"slug": "3.4",
|
||||
"current": true,
|
||||
"aliases": [
|
||||
"current",
|
||||
"stable"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "3.3",
|
||||
"branchName": "3.3.x",
|
||||
"slug": "3.3",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "3.2",
|
||||
"branchName": "3.2.x",
|
||||
"slug": "3.2",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "3.1",
|
||||
"branchName": "3.1.x",
|
||||
"slug": "3.1",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "3.0",
|
||||
"branchName": "3.0.x",
|
||||
"slug": "3.0",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.13",
|
||||
"branchName": "2.13.x",
|
||||
"slug": "2.13",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.12",
|
||||
"branchName": "2.12.x",
|
||||
"slug": "2.12",
|
||||
"maintained": false
|
||||
},
|
||||
{
|
||||
"name": "2.11",
|
||||
"branchName": "2.11",
|
||||
"slug": "2.11",
|
||||
"maintained": false
|
||||
}
|
||||
]
|
||||
}
|
||||
19
vendor/doctrine/common/LICENSE
vendored
Normal file
19
vendor/doctrine/common/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2006-2015 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.
|
||||
12
vendor/doctrine/common/README.md
vendored
Normal file
12
vendor/doctrine/common/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# Doctrine Common
|
||||
|
||||
[](https://github.com/doctrine/common/actions)
|
||||
[](https://codecov.io/gh/doctrine/common)
|
||||
|
||||
The Doctrine Common project is a library that provides extensions to core PHP functionality.
|
||||
|
||||
## More resources:
|
||||
|
||||
* [Website](https://www.doctrine-project.org/)
|
||||
* [Documentation](https://www.doctrine-project.org/projects/doctrine-common/en/current/)
|
||||
* [Downloads](https://github.com/doctrine/common/releases)
|
||||
39
vendor/doctrine/common/UPGRADE_TO_2_1
vendored
Normal file
39
vendor/doctrine/common/UPGRADE_TO_2_1
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
This document details all the possible changes that you should investigate when updating
|
||||
your project from Doctrine Common 2.0.x to 2.1
|
||||
|
||||
## AnnotationReader changes
|
||||
|
||||
The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way:
|
||||
|
||||
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
|
||||
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
|
||||
// new code necessary starting here
|
||||
$reader->setIgnoreNotImportedAnnotations(true);
|
||||
$reader->setEnableParsePhpImports(false);
|
||||
$reader = new \Doctrine\Common\Annotations\CachedReader(
|
||||
new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache()
|
||||
);
|
||||
|
||||
## Annotation Base class or @Annotation
|
||||
|
||||
Beginning after 2.1-RC2 you have to either extend ``Doctrine\Common\Annotations\Annotation`` or add @Annotation to your annotations class-level docblock, otherwise the class will simply be ignored.
|
||||
|
||||
## Removed methods on AnnotationReader
|
||||
|
||||
* AnnotationReader::setAutoloadAnnotations()
|
||||
* AnnotationReader::getAutoloadAnnotations()
|
||||
* AnnotationReader::isAutoloadAnnotations()
|
||||
|
||||
## AnnotationRegistry
|
||||
|
||||
Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes:
|
||||
|
||||
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations);
|
||||
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null);
|
||||
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces);
|
||||
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable);
|
||||
|
||||
The $callable for registering a loader accepts a class as first and only parameter and must try to silently autoload it. On success true has to be returned.
|
||||
The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories.
|
||||
If null is passed as directory the include path will be used.
|
||||
|
||||
61
vendor/doctrine/common/UPGRADE_TO_2_2
vendored
Normal file
61
vendor/doctrine/common/UPGRADE_TO_2_2
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
This document details all the possible changes that you should investigate when
|
||||
updating your project from Doctrine Common 2.1 to 2.2:
|
||||
|
||||
## Annotation Changes
|
||||
|
||||
- AnnotationReader::setIgnoreNotImportedAnnotations has been removed, you need to
|
||||
add ignore annotation names which are supposed to be ignored via
|
||||
AnnotationReader::addGlobalIgnoredName
|
||||
|
||||
- AnnotationReader::setAutoloadAnnotations was deprecated by the AnnotationRegistry
|
||||
in 2.1 and has been removed in 2.2
|
||||
|
||||
- AnnotationReader::setEnableParsePhpImports was added to ease transition to the new
|
||||
annotation mechanism in 2.1 and is removed in 2.2
|
||||
|
||||
- AnnotationReader::isParsePhpImportsEnabled is removed (see above)
|
||||
|
||||
- AnnotationReader::setDefaultAnnotationNamespace was deprecated in favor of explicit
|
||||
configuration in 2.1 and will be removed in 2.2 (for isolated projects where you
|
||||
have full-control over _all_ available annotations, we offer a dedicated reader
|
||||
class ``SimpleAnnotationReader``)
|
||||
|
||||
- AnnotationReader::setAnnotationCreationFunction was deprecated in 2.1 and will be
|
||||
removed in 2.2. We only offer two creation mechanisms which cannot be changed
|
||||
anymore to allow the same reader instance to work with all annotations regardless
|
||||
of which library they are coming from.
|
||||
|
||||
- AnnotationReader::setAnnotationNamespaceAlias was deprecated in 2.1 and will be
|
||||
removed in 2.2 (see setDefaultAnnotationNamespace)
|
||||
|
||||
- If you use a class as annotation which has not the @Annotation marker in it's
|
||||
class block, we will now throw an exception instead of silently ignoring it. You
|
||||
can however still achieve the previous behavior using the @IgnoreAnnotation, or
|
||||
AnnotationReader::addGlobalIgnoredName (the exception message will contain detailed
|
||||
instructions when you run into this problem).
|
||||
|
||||
## Cache Changes
|
||||
|
||||
- Renamed old AbstractCache to CacheProvider
|
||||
|
||||
- Dropped the support to the following functions of all cache providers:
|
||||
|
||||
- CacheProvider::deleteByWildcard
|
||||
|
||||
- CacheProvider::deleteByRegEx
|
||||
|
||||
- CacheProvider::deleteByPrefix
|
||||
|
||||
- CacheProvider::deleteBySuffix
|
||||
|
||||
- CacheProvider::deleteAll will not remove ALL entries, it will only mark them as invalid
|
||||
|
||||
- CacheProvider::flushAll will remove ALL entries, namespaced or not
|
||||
|
||||
- Added support to MemcachedCache
|
||||
|
||||
- Added support to WincacheCache
|
||||
|
||||
## ClassLoader Changes
|
||||
|
||||
- ClassLoader::fileExistsInIncludePath() no longer exists. Use the native stream_resolve_include_path() PHP function
|
||||
50
vendor/doctrine/common/composer.json
vendored
Normal file
50
vendor/doctrine/common/composer.json
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "doctrine/common",
|
||||
"type": "library",
|
||||
"description": "PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support, proxies and much more.",
|
||||
"keywords": [
|
||||
"php",
|
||||
"common",
|
||||
"doctrine"
|
||||
],
|
||||
"homepage": "https://www.doctrine-project.org/projects/common.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"},
|
||||
{"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"},
|
||||
{"name": "Marco Pivetta", "email": "ocramius@gmail.com"}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"doctrine/persistence": "^2.0 || ^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/collections": "^1",
|
||||
"phpstan/phpstan": "^1.4.1",
|
||||
"phpstan/phpstan-phpunit": "^1",
|
||||
"phpunit/phpunit": "^7.5.20 || ^8.5 || ^9.0",
|
||||
"doctrine/coding-standard": "^9.0 || ^10.0",
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"symfony/phpunit-bridge": "^6.1",
|
||||
"vimeo/psalm": "^4.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Common\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Doctrine\\Tests\\": "tests"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"dealerdirect/phpcodesniffer-composer-installer": true,
|
||||
"composer/package-versions-deprecated": true
|
||||
}
|
||||
}
|
||||
}
|
||||
10
vendor/doctrine/common/docs/en/index.rst
vendored
Normal file
10
vendor/doctrine/common/docs/en/index.rst
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
Common Documentation
|
||||
====================
|
||||
|
||||
Welcome to the Doctrine Common Library documentation.
|
||||
|
||||
.. toctree::
|
||||
:depth: 2
|
||||
:glob:
|
||||
|
||||
*
|
||||
241
vendor/doctrine/common/docs/en/reference/class-loading.rst
vendored
Normal file
241
vendor/doctrine/common/docs/en/reference/class-loading.rst
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
Class Loading
|
||||
=============
|
||||
|
||||
Class loading is an essential part of any PHP application that
|
||||
makes heavy use of classes and interfaces. Unfortunately, a lot of
|
||||
people and projects spend a lot of time and effort on custom and
|
||||
specialized class loading strategies. It can quickly become a pain
|
||||
to understand what is going on when using multiple libraries and/or
|
||||
frameworks, each with its own way to do class loading. Class
|
||||
loading should be simple and it is an ideal candidate for
|
||||
convention over configuration.
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
The Doctrine Common ClassLoader implements a simple and efficient
|
||||
approach to class loading that is easy to understand and use. The
|
||||
implementation is based on the widely used and accepted convention
|
||||
of mapping namespace and class names to a directory structure. This
|
||||
approach is used for example by Symfony2, the Zend Framework and of
|
||||
course, Doctrine.
|
||||
|
||||
For example, the following class:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
namespace MyProject\Shipping;
|
||||
class ShippingStrategy { ... }
|
||||
|
||||
resides in the following directory structure:
|
||||
|
||||
::
|
||||
|
||||
src/
|
||||
/MyProject
|
||||
/Shipping
|
||||
ShippingStrategy.php
|
||||
|
||||
Note that the name of "src" or the structure above or beside this
|
||||
directory is completely arbitrary. "src" could be named "classes"
|
||||
or "lib" or whatever. The only convention to adhere to is to map
|
||||
namespaces to directories and classes to files named after the
|
||||
class name.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
To use a Doctrine Common ClassLoader, you first need to load the
|
||||
class file containing the ClassLoader. This is the only class file
|
||||
that actually needs to be loaded explicitly via ``require``. All
|
||||
other classes will be loaded on demand by the configured class
|
||||
loaders.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
use Doctrine\Common\ClassLoader;
|
||||
require '/path/to/Doctrine/Common/ClassLoader.php';
|
||||
$classLoader = new ClassLoader('MyProject', '/path/to/src');
|
||||
|
||||
A ``ClassLoader`` takes two constructor parameters, both optional.
|
||||
In the normal case both arguments are supplied. The first argument
|
||||
specifies the namespace prefix this class loader should be
|
||||
responsible for and the second parameter is the path to the root
|
||||
directory where the classes can be found according to the
|
||||
convention mentioned previously.
|
||||
|
||||
The class loader in the example above would thus be responsible for
|
||||
all classes under the 'MyProject' namespace and it would look for
|
||||
the class files starting at the directory '/path/to/src'.
|
||||
|
||||
Also note that the prefix supplied in the first argument need not
|
||||
be a root namespace but can be an arbitrarily nested namespace as
|
||||
well. This allows you to even have the sources of subnamespaces
|
||||
split across different directories. For example, all projects under
|
||||
the Doctrine umbrella reside in the Doctrine namespace, yet the
|
||||
sources for each project usually do not reside under a common root
|
||||
directory. The following is an example of configuring three class
|
||||
loaders, one for each used Doctrine project:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
use Doctrine\Common\ClassLoader;
|
||||
require '/path/to/Doctrine/Common/ClassLoader.php';
|
||||
$commonLoader = new ClassLoader('Doctrine\Common', '/path/to/common/lib');
|
||||
$dbalLoader = new ClassLoader('Doctrine\DBAL', '/path/to/dbal/lib');
|
||||
$ormLoader = new ClassLoader('Doctrine\ORM', '/path/to/orm/lib');
|
||||
$commonLoader->register();
|
||||
$dbalLoader->register();
|
||||
$ormLoader->register();
|
||||
|
||||
Do not be afraid of using multiple class loaders. Due to the
|
||||
efficient class loading design you will not incur much overhead
|
||||
from using many class loaders. Take a look at the implementation of
|
||||
``ClassLoader#loadClass`` to see how simple and efficient the class
|
||||
loading is. The iteration over the installed class loaders happens
|
||||
in C (with the exception of using ``ClassLoader::classExists``).
|
||||
|
||||
A ClassLoader can be used in the following other variations,
|
||||
however, these are rarely used/needed:
|
||||
|
||||
|
||||
- If only the second argument is not supplied, the class loader
|
||||
will be responsible for the namespace prefix given in the first
|
||||
argument and it will rely on the PHP include_path.
|
||||
|
||||
- If only the first argument is not supplied, the class loader
|
||||
will be responsible for *all* classes and it will try to look up
|
||||
*all* classes starting at the directory given as the second
|
||||
argument.
|
||||
|
||||
- If both arguments are not supplied, the class loader will be
|
||||
responsible for *all* classes and it will rely on the PHP
|
||||
include_path.
|
||||
|
||||
|
||||
File Extension
|
||||
--------------
|
||||
|
||||
By default, a ClassLoader uses the ``.php`` file extension for all
|
||||
class files. You can change this behavior, for example to use a
|
||||
ClassLoader to load classes from a library that uses the
|
||||
".class.php" convention (but it must nevertheless adhere to the
|
||||
directory structure convention!):
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$customLoader = new ClassLoader('CustomLib', '/path/to/custom/lib');
|
||||
$customLoader->setFileExtension('.class.php');
|
||||
$customLoader->register();
|
||||
|
||||
Namespace Separator
|
||||
-------------------
|
||||
|
||||
By default, a ClassLoader uses the ``\`` namespace separator. You
|
||||
can change this behavior, for example to use a ClassLoader to load
|
||||
legacy Zend Framework classes that still use the underscore "_"
|
||||
separator:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
$zend1Loader = new ClassLoader('Zend', '/path/to/zend/lib');
|
||||
$zend1Loader->setNamespaceSeparator('_');
|
||||
$zend1Loader->register();
|
||||
|
||||
Failing Silently and class_exists
|
||||
----------------------------------
|
||||
|
||||
A lot of class/autoloaders these days try to fail silently when a
|
||||
class file is not found. For the most part this is necessary in
|
||||
order to support using ``class_exists('ClassName', true)`` which is
|
||||
supposed to return a boolean value but triggers autoloading. This
|
||||
is a bad thing as it basically forces class loaders to fail
|
||||
silently, which in turn requires costly file_exists or fopen calls
|
||||
for each class being loaded, even though in at least 99% of the
|
||||
cases this is not necessary (compare the number of
|
||||
class_exists(..., true) invocations to the total number of classes
|
||||
being loaded in a request).
|
||||
|
||||
The Doctrine Common ClassLoader does not fail silently, by design.
|
||||
It therefore does not need any costly checks for file existence. A
|
||||
ClassLoader is always responsible for all classes with a certain
|
||||
namespace prefix and if a class is requested to be loaded and can
|
||||
not be found this is considered to be a fatal error. This also
|
||||
means that using class_exists(..., true) to check for class
|
||||
existence when using a Doctrine Common ClassLoader is not possible
|
||||
but this is not a bad thing. What class\_exists(..., true) actually
|
||||
means is two things: 1) Check whether the class is already
|
||||
defined/exists (i.e. class_exists(..., false)) and if not 2) check
|
||||
whether a class file can be loaded for that class. In the Doctrine
|
||||
Common ClassLoader the two responsibilities of loading a class and
|
||||
checking for its existence are separated, which can be observed by
|
||||
the existence of the two methods ``loadClass`` and
|
||||
``canLoadClass``. Thereby ``loadClass`` does not invoke
|
||||
``canLoadClass`` internally, by design. However, you are free to
|
||||
use it yourself to check whether a class can be loaded and the
|
||||
following code snippet is thus equivalent to class\_exists(...,
|
||||
true):
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// Equivalent to if (('Foo', true)) if there is only 1 class loader to check
|
||||
if (class_exists('Foo', false) || $classLoader->canLoadClass('Foo')) {
|
||||
// ...
|
||||
}
|
||||
|
||||
The only problem with this is that it is inconvenient as you need
|
||||
to have a reference to the class loaders around (and there are
|
||||
often multiple class loaders in use). Therefore, a simpler
|
||||
alternative exists for the cases in which you really want to ask
|
||||
all installed class loaders whether they can load the class:
|
||||
``ClassLoader::classExists($className)``:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
// Equivalent to if (class_exists('Foo', true))
|
||||
if (ClassLoader::classExists('Foo')) {
|
||||
// ...
|
||||
}
|
||||
|
||||
This static method can basically be used as a drop-in replacement
|
||||
for class_exists(..., true). It iterates over all installed class
|
||||
loaders and asks each of them via ``canLoadClass``, returning early
|
||||
(with TRUE) as soon as one class loader returns TRUE from
|
||||
``canLoadClass``. If this sounds like it can potentially be rather
|
||||
costly then because that is true but it is exactly the same thing
|
||||
that class_exists(..., true) does under the hood, it triggers a
|
||||
complete interaction of all class/auto loaders. Checking for class
|
||||
existence via invoking autoloading was never a cheap thing to do
|
||||
but now it is more obvious and more importantly, this check is no
|
||||
longer interleaved with regular class loading, which avoids having
|
||||
to check each and every class for existence prior to loading it.
|
||||
The vast majority of classes to be loaded are *not* optional and a
|
||||
failure to load such a class is, and should be, a fatal error. The
|
||||
ClassLoader design reflects this.
|
||||
|
||||
If you have code that requires the usage of class\_exists(...,
|
||||
true) or ClassLoader::classExists during normal runtime of the
|
||||
application (i.e. on each request) try to refactor your design to
|
||||
avoid it.
|
||||
|
||||
Summary
|
||||
-------
|
||||
|
||||
No matter which class loader you prefer to use (Doctrine classes do
|
||||
not care about how they are loaded), we kindly encourage you to
|
||||
adhere to the simple convention of mapping namespaces and class
|
||||
names to a directory structure.
|
||||
|
||||
Class loading should be simple, automated and uniform. Time is
|
||||
better invested in actual application development than in designing
|
||||
special directory structures, autoloaders and clever caching
|
||||
strategies for class loading.
|
||||
|
||||
|
||||
58
vendor/doctrine/common/phpstan.neon.dist
vendored
Normal file
58
vendor/doctrine/common/phpstan.neon.dist
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
parameters:
|
||||
phpVersion: 80200
|
||||
level: 3
|
||||
paths:
|
||||
- src
|
||||
- tests
|
||||
excludePaths:
|
||||
- tests/Common/Proxy/InvalidReturnTypeClass.php
|
||||
- tests/Common/Proxy/InvalidTypeHintClass.php
|
||||
- tests/Common/Proxy/LazyLoadableObjectWithTypedProperties.php
|
||||
- tests/Common/Proxy/MagicIssetClassWithInteger.php
|
||||
- tests/Common/Proxy/NullableNonOptionalHintClass.php
|
||||
- tests/Common/Proxy/PHP81NeverType.php
|
||||
- tests/Common/Proxy/PHP81IntersectionTypes.php
|
||||
- tests/Common/Proxy/Php8UnionTypes.php
|
||||
- tests/Common/Proxy/Php8StaticType.php
|
||||
- tests/Common/Proxy/ProxyGeneratorTest.php
|
||||
- tests/Common/Proxy/ProxyLogicTypedPropertiesTest.php
|
||||
- tests/Common/Proxy/SerializedClass.php
|
||||
- tests/Common/Proxy/VariadicTypeHintClass.php
|
||||
- tests/Common/Proxy/Php71NullableDefaultedNonOptionalHintClass.php
|
||||
- tests/Common/Proxy/generated
|
||||
ignoreErrors:
|
||||
- '#Access to an undefined property Doctrine\\Common\\Proxy\\Proxy::\$publicField#'
|
||||
-
|
||||
message: '#^Result of method Doctrine\\Tests\\Common\\Proxy\\LazyLoadableObjectWithVoid::(adding|incrementing)AndReturningVoid\(\) \(void\) is used\.$#'
|
||||
path: 'tests/Common/Proxy/ProxyLogicVoidReturnTypeTest.php'
|
||||
-
|
||||
message: '#^Property Doctrine\\Tests\\Common\\Proxy\\ProxyLogicTest::\$initializerCallbackMock \(callable\(\): mixed&PHPUnit\\Framework\\MockObject\\MockObject\) does not accept PHPUnit\\Framework\\MockObject\\MockObject&stdClass\.$#'
|
||||
path: 'tests/Common/Proxy/ProxyLogicTest.php'
|
||||
-
|
||||
message: '#.*LazyLoadableObject.*#'
|
||||
paths:
|
||||
- 'tests/Common/Proxy/ProxyLogicTest.php'
|
||||
- 'tests/Common/Proxy/ProxyLogicVoidReturnTypeTest.php'
|
||||
-
|
||||
message: '#^Instantiated class Doctrine\\Tests\\Common\\ProxyProxy\\__CG__\\Doctrine\\Tests\\Common\\Proxy\\.* not found.$#'
|
||||
path: 'tests/Common/Proxy/ProxyLogicTest.php'
|
||||
-
|
||||
message: '#^Instantiated class Doctrine\\Tests\\Common\\ProxyProxy\\__CG__\\Doctrine\\Tests\\Common\\Proxy\\.* not found.$#'
|
||||
path: 'tests/Common/Proxy/ProxyLogicVoidReturnTypeTest.php'
|
||||
-
|
||||
message: '#^Property Doctrine\\Tests\\Common\\Proxy\\ProxyLogicVoidReturnTypeTest::\$initializerCallbackMock \(callable\(\): mixed&PHPUnit\\Framework\\MockObject\\MockObject\) does not accept PHPUnit\\Framework\\MockObject\\MockObject&stdClass\.$#'
|
||||
path: 'tests/Common/Proxy/ProxyLogicVoidReturnTypeTest.php'
|
||||
-
|
||||
message: '#^Method Doctrine\\Tests\\Common\\Proxy\\MagicIssetClassWithInteger::__isset\(\) should return bool but returns int\.$#'
|
||||
path: 'tests/Common/Proxy/MagicIssetClassWithInteger.php'
|
||||
-
|
||||
message: '#^Access to an undefined property Doctrine\\Tests\\Common\\Proxy\\MagicGetByRefClass\:\:\$nonExisting\.$#'
|
||||
path: 'tests/Common/Proxy/ProxyMagicMethodsTest.php'
|
||||
|
||||
-
|
||||
message: "#^Class Doctrine\\\\Tests\\\\Common\\\\Proxy\\\\MagicIssetClassWithInteger not found\\.$#"
|
||||
count: 1
|
||||
path: tests/Common/Proxy/ProxyMagicMethodsTest.php
|
||||
includes:
|
||||
- vendor/phpstan/phpstan-phpunit/extension.neon
|
||||
- vendor/phpstan/phpstan-phpunit/rules.neon
|
||||
16
vendor/doctrine/common/psalm.xml
vendored
Normal file
16
vendor/doctrine/common/psalm.xml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<psalm
|
||||
errorLevel="8"
|
||||
resolveFromConfigFile="true"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="https://getpsalm.org/schema/config"
|
||||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||
phpVersion="8.1"
|
||||
>
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
<ignoreFiles>
|
||||
<file name="src/Proxy/ProxyGenerator.php" />
|
||||
</ignoreFiles>
|
||||
</projectFiles>
|
||||
</psalm>
|
||||
285
vendor/doctrine/common/src/ClassLoader.php
vendored
Normal file
285
vendor/doctrine/common/src/ClassLoader.php
vendored
Normal file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
use function class_exists;
|
||||
use function interface_exists;
|
||||
use function is_array;
|
||||
use function is_file;
|
||||
use function reset;
|
||||
use function spl_autoload_functions;
|
||||
use function spl_autoload_register;
|
||||
use function spl_autoload_unregister;
|
||||
use function str_replace;
|
||||
use function stream_resolve_include_path;
|
||||
use function strpos;
|
||||
use function trait_exists;
|
||||
use function trigger_error;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use const E_USER_DEPRECATED;
|
||||
|
||||
@trigger_error(ClassLoader::class . ' is deprecated.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* A <tt>ClassLoader</tt> is an autoloader for class files that can be
|
||||
* installed on the SPL autoload stack. It is a class loader that either loads only classes
|
||||
* of a specific namespace or all namespaces and it is suitable for working together
|
||||
* with other autoloaders in the SPL autoload stack.
|
||||
*
|
||||
* If no include path is configured through the constructor or {@link setIncludePath}, a ClassLoader
|
||||
* relies on the PHP <code>include_path</code>.
|
||||
*
|
||||
* @deprecated The ClassLoader is deprecated and will be removed in version 4.0 of doctrine/common.
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/**
|
||||
* PHP file extension.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fileExtension = '.php';
|
||||
|
||||
/**
|
||||
* Current namespace.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $namespace;
|
||||
|
||||
/**
|
||||
* Current include path.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $includePath;
|
||||
|
||||
/**
|
||||
* PHP namespace separator.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespaceSeparator = '\\';
|
||||
|
||||
/**
|
||||
* Creates a new <tt>ClassLoader</tt> that loads classes of the
|
||||
* specified namespace from the specified include path.
|
||||
*
|
||||
* If no include path is given, the ClassLoader relies on the PHP include_path.
|
||||
* If neither a namespace nor an include path is given, the ClassLoader will
|
||||
* be responsible for loading all classes, thereby relying on the PHP include_path.
|
||||
*
|
||||
* @param string|null $ns The namespace of the classes to load.
|
||||
* @param string|null $includePath The base include path to use.
|
||||
*/
|
||||
public function __construct($ns = null, $includePath = null)
|
||||
{
|
||||
$this->namespace = $ns;
|
||||
$this->includePath = $includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the namespace separator used by classes in the namespace of this ClassLoader.
|
||||
*
|
||||
* @param string $sep The separator to use.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setNamespaceSeparator($sep)
|
||||
{
|
||||
$this->namespaceSeparator = $sep;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the namespace separator used by classes in the namespace of this ClassLoader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespaceSeparator()
|
||||
{
|
||||
return $this->namespaceSeparator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base include path for all class files in the namespace of this ClassLoader.
|
||||
*
|
||||
* @param string|null $includePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIncludePath($includePath)
|
||||
{
|
||||
$this->includePath = $includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base include path for all class files in the namespace of this ClassLoader.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getIncludePath()
|
||||
{
|
||||
return $this->includePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the file extension of class files in the namespace of this ClassLoader.
|
||||
*
|
||||
* @param string $fileExtension
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFileExtension($fileExtension)
|
||||
{
|
||||
$this->fileExtension = $fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file extension of class files in the namespace of this ClassLoader.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileExtension()
|
||||
{
|
||||
return $this->fileExtension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this ClassLoader on the SPL autoload stack.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
spl_autoload_register([$this, 'loadClass']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this ClassLoader from the SPL autoload stack.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister([$this, 'loadClass']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $className The name of the class to load.
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool TRUE if the class has been successfully loaded, FALSE otherwise.
|
||||
*/
|
||||
public function loadClass($className)
|
||||
{
|
||||
if (self::typeExists($className)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! $this->canLoadClass($className)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '')
|
||||
. str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className)
|
||||
. $this->fileExtension;
|
||||
|
||||
return self::typeExists($className);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks this ClassLoader whether it can potentially load the class (file) with
|
||||
* the given name.
|
||||
*
|
||||
* @param string $className The fully-qualified name of the class.
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool TRUE if this ClassLoader can load the class, FALSE otherwise.
|
||||
*/
|
||||
public function canLoadClass($className)
|
||||
{
|
||||
if ($this->namespace !== null && strpos($className, $this->namespace . $this->namespaceSeparator) !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$file = str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) . $this->fileExtension;
|
||||
|
||||
if ($this->includePath !== null) {
|
||||
return is_file($this->includePath . DIRECTORY_SEPARATOR . $file);
|
||||
}
|
||||
|
||||
return stream_resolve_include_path($file) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a class with a given name exists. A class "exists" if it is either
|
||||
* already defined in the current request or if there is an autoloader on the SPL
|
||||
* autoload stack that is a) responsible for the class in question and b) is able to
|
||||
* load a class file in which the class definition resides.
|
||||
*
|
||||
* If the class is not already defined, each autoloader in the SPL autoload stack
|
||||
* is asked whether it is able to tell if the class exists. If the autoloader is
|
||||
* a <tt>ClassLoader</tt>, {@link canLoadClass} is used, otherwise the autoload
|
||||
* function of the autoloader is invoked and expected to return a value that
|
||||
* evaluates to TRUE if the class (file) exists. As soon as one autoloader reports
|
||||
* that the class exists, TRUE is returned.
|
||||
*
|
||||
* Note that, depending on what kinds of autoloaders are installed on the SPL
|
||||
* autoload stack, the class (file) might already be loaded as a result of checking
|
||||
* for its existence. This is not the case with a <tt>ClassLoader</tt>, who separates
|
||||
* these responsibilities.
|
||||
*
|
||||
* @param string $className The fully-qualified name of the class.
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return bool TRUE if the class exists as per the definition given above, FALSE otherwise.
|
||||
*/
|
||||
public static function classExists($className)
|
||||
{
|
||||
return self::typeExists($className, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the <tt>ClassLoader</tt> from the SPL autoload stack that is responsible
|
||||
* for (and is able to load) the class with the given name.
|
||||
*
|
||||
* @param string $className The name of the class.
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return ClassLoader|null The <tt>ClassLoader</tt> for the class or NULL if no such <tt>ClassLoader</tt> exists.
|
||||
*/
|
||||
public static function getClassLoader($className)
|
||||
{
|
||||
foreach (spl_autoload_functions() as $loader) {
|
||||
if (! is_array($loader)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$classLoader = reset($loader);
|
||||
|
||||
if ($classLoader instanceof ClassLoader && $classLoader->canLoadClass($className)) {
|
||||
return $classLoader;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given type exists
|
||||
*
|
||||
* @param string $type
|
||||
* @param bool $autoload
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function typeExists($type, $autoload = false)
|
||||
{
|
||||
return class_exists($type, $autoload)
|
||||
|| interface_exists($type, $autoload)
|
||||
|| trait_exists($type, $autoload);
|
||||
}
|
||||
}
|
||||
14
vendor/doctrine/common/src/CommonException.php
vendored
Normal file
14
vendor/doctrine/common/src/CommonException.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Base exception class for package Doctrine\Common.
|
||||
*
|
||||
* @deprecated The doctrine/common package is deprecated, please use specific packages and their exceptions instead.
|
||||
*/
|
||||
class CommonException extends Exception
|
||||
{
|
||||
}
|
||||
26
vendor/doctrine/common/src/Comparable.php
vendored
Normal file
26
vendor/doctrine/common/src/Comparable.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common;
|
||||
|
||||
/**
|
||||
* Comparable interface that allows to compare two value objects to each other for similarity.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface Comparable
|
||||
{
|
||||
/**
|
||||
* Compares the current object to the passed $other.
|
||||
*
|
||||
* Returns 0 if they are semantically equal, 1 if the other object
|
||||
* is less than the current one, or -1 if its more than the current one.
|
||||
*
|
||||
* This method should not check for identity using ===, only for semantical equality for example
|
||||
* when two different DateTime instances point to the exact same Date + TZ.
|
||||
*
|
||||
* @param mixed $other
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function compareTo($other);
|
||||
}
|
||||
244
vendor/doctrine/common/src/Proxy/AbstractProxyFactory.php
vendored
Normal file
244
vendor/doctrine/common/src/Proxy/AbstractProxyFactory.php
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy;
|
||||
|
||||
use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
|
||||
use Doctrine\Common\Proxy\Exception\OutOfBoundsException;
|
||||
use Doctrine\Common\Util\ClassUtils;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadata;
|
||||
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
|
||||
|
||||
use function class_exists;
|
||||
use function file_exists;
|
||||
use function filemtime;
|
||||
use function in_array;
|
||||
|
||||
/**
|
||||
* Abstract factory for proxy objects.
|
||||
*/
|
||||
abstract class AbstractProxyFactory
|
||||
{
|
||||
/**
|
||||
* Never autogenerate a proxy and rely that it was generated by some
|
||||
* process before deployment.
|
||||
*/
|
||||
public const AUTOGENERATE_NEVER = 0;
|
||||
|
||||
/**
|
||||
* Always generates a new proxy in every request.
|
||||
*
|
||||
* This is only sane during development.
|
||||
*/
|
||||
public const AUTOGENERATE_ALWAYS = 1;
|
||||
|
||||
/**
|
||||
* Autogenerate the proxy class when the proxy file does not exist.
|
||||
*
|
||||
* This strategy causes a file_exists() call whenever any proxy is used the
|
||||
* first time in a request.
|
||||
*/
|
||||
public const AUTOGENERATE_FILE_NOT_EXISTS = 2;
|
||||
|
||||
/**
|
||||
* Generate the proxy classes using eval().
|
||||
*
|
||||
* This strategy is only sane for development, and even then it gives me
|
||||
* the creeps a little.
|
||||
*/
|
||||
public const AUTOGENERATE_EVAL = 3;
|
||||
|
||||
/**
|
||||
* Autogenerate the proxy class when the proxy file does not exist or
|
||||
* when the proxied file changed.
|
||||
*
|
||||
* This strategy causes a file_exists() call whenever any proxy is used the
|
||||
* first time in a request. When the proxied file is changed, the proxy will
|
||||
* be updated.
|
||||
*/
|
||||
public const AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED = 4;
|
||||
|
||||
private const AUTOGENERATE_MODES = [
|
||||
self::AUTOGENERATE_NEVER,
|
||||
self::AUTOGENERATE_ALWAYS,
|
||||
self::AUTOGENERATE_FILE_NOT_EXISTS,
|
||||
self::AUTOGENERATE_EVAL,
|
||||
self::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED,
|
||||
];
|
||||
|
||||
/** @var ClassMetadataFactory */
|
||||
private $metadataFactory;
|
||||
|
||||
/** @var ProxyGenerator the proxy generator responsible for creating the proxy classes/files. */
|
||||
private $proxyGenerator;
|
||||
|
||||
/** @var int Whether to automatically (re)generate proxy classes. */
|
||||
private $autoGenerate;
|
||||
|
||||
/** @var ProxyDefinition[] */
|
||||
private $definitions = [];
|
||||
|
||||
/**
|
||||
* @param bool|int $autoGenerate
|
||||
*
|
||||
* @throws InvalidArgumentException When auto generate mode is not valid.
|
||||
*/
|
||||
public function __construct(ProxyGenerator $proxyGenerator, ClassMetadataFactory $metadataFactory, $autoGenerate)
|
||||
{
|
||||
$this->proxyGenerator = $proxyGenerator;
|
||||
$this->metadataFactory = $metadataFactory;
|
||||
$this->autoGenerate = (int) $autoGenerate;
|
||||
|
||||
if (! in_array($this->autoGenerate, self::AUTOGENERATE_MODES, true)) {
|
||||
throw InvalidArgumentException::invalidAutoGenerateMode($autoGenerate);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a reference proxy instance for the entity of the given type and identified by
|
||||
* the given identifier.
|
||||
*
|
||||
* @param string $className
|
||||
* @param array<mixed> $identifier
|
||||
*
|
||||
* @return Proxy
|
||||
*
|
||||
* @throws OutOfBoundsException
|
||||
*/
|
||||
public function getProxy($className, array $identifier)
|
||||
{
|
||||
$definition = $this->definitions[$className] ?? $this->getProxyDefinition($className);
|
||||
$fqcn = $definition->proxyClassName;
|
||||
$proxy = new $fqcn($definition->initializer, $definition->cloner);
|
||||
|
||||
foreach ($definition->identifierFields as $idField) {
|
||||
if (! isset($identifier[$idField])) {
|
||||
throw OutOfBoundsException::missingPrimaryKeyValue($className, $idField);
|
||||
}
|
||||
|
||||
$definition->reflectionFields[$idField]->setValue($proxy, $identifier[$idField]);
|
||||
}
|
||||
|
||||
return $proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates proxy classes for all given classes.
|
||||
*
|
||||
* @param ClassMetadata[] $classes The classes (ClassMetadata instances)
|
||||
* for which to generate proxies.
|
||||
* @param string $proxyDir The target directory of the proxy classes. If not specified, the
|
||||
* directory configured on the Configuration of the EntityManager used
|
||||
* by this factory is used.
|
||||
*
|
||||
* @return int Number of generated proxies.
|
||||
*/
|
||||
public function generateProxyClasses(array $classes, $proxyDir = null)
|
||||
{
|
||||
$generated = 0;
|
||||
|
||||
foreach ($classes as $class) {
|
||||
if ($this->skipClass($class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$proxyFileName = $this->proxyGenerator->getProxyFileName($class->getName(), $proxyDir);
|
||||
|
||||
$this->proxyGenerator->generateProxyClass($class, $proxyFileName);
|
||||
|
||||
$generated += 1;
|
||||
}
|
||||
|
||||
return $generated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset initialization/cloning logic for an un-initialized proxy
|
||||
*
|
||||
* @return Proxy
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function resetUninitializedProxy(Proxy $proxy)
|
||||
{
|
||||
if ($proxy->__isInitialized()) {
|
||||
throw InvalidArgumentException::unitializedProxyExpected($proxy);
|
||||
}
|
||||
|
||||
$className = ClassUtils::getClass($proxy);
|
||||
$definition = $this->definitions[$className] ?? $this->getProxyDefinition($className);
|
||||
|
||||
$proxy->__setInitializer($definition->initializer);
|
||||
$proxy->__setCloner($definition->cloner);
|
||||
|
||||
return $proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a proxy definition for the given class name.
|
||||
*
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return ProxyDefinition
|
||||
*/
|
||||
private function getProxyDefinition($className)
|
||||
{
|
||||
$classMetadata = $this->metadataFactory->getMetadataFor($className);
|
||||
$className = $classMetadata->getName(); // aliases and case sensitivity
|
||||
|
||||
$this->definitions[$className] = $this->createProxyDefinition($className);
|
||||
$proxyClassName = $this->definitions[$className]->proxyClassName;
|
||||
|
||||
if (! class_exists($proxyClassName, false)) {
|
||||
$fileName = $this->proxyGenerator->getProxyFileName($className);
|
||||
|
||||
switch ($this->autoGenerate) {
|
||||
case self::AUTOGENERATE_NEVER:
|
||||
require $fileName;
|
||||
break;
|
||||
|
||||
case self::AUTOGENERATE_FILE_NOT_EXISTS:
|
||||
if (! file_exists($fileName)) {
|
||||
$this->proxyGenerator->generateProxyClass($classMetadata, $fileName);
|
||||
}
|
||||
|
||||
require $fileName;
|
||||
break;
|
||||
|
||||
case self::AUTOGENERATE_ALWAYS:
|
||||
$this->proxyGenerator->generateProxyClass($classMetadata, $fileName);
|
||||
require $fileName;
|
||||
break;
|
||||
|
||||
case self::AUTOGENERATE_EVAL:
|
||||
$this->proxyGenerator->generateProxyClass($classMetadata, false);
|
||||
break;
|
||||
|
||||
case self::AUTOGENERATE_FILE_NOT_EXISTS_OR_CHANGED:
|
||||
if (! file_exists($fileName) || filemtime($fileName) < filemtime($classMetadata->getReflectionClass()->getFileName())) {
|
||||
$this->proxyGenerator->generateProxyClass($classMetadata, $fileName);
|
||||
}
|
||||
|
||||
require $fileName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->definitions[$className];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this class should be skipped during proxy generation.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract protected function skipClass(ClassMetadata $metadata);
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return ProxyDefinition
|
||||
*/
|
||||
abstract protected function createProxyDefinition($className);
|
||||
}
|
||||
99
vendor/doctrine/common/src/Proxy/Autoloader.php
vendored
Normal file
99
vendor/doctrine/common/src/Proxy/Autoloader.php
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
|
||||
|
||||
use function call_user_func;
|
||||
use function file_exists;
|
||||
use function is_callable;
|
||||
use function ltrim;
|
||||
use function spl_autoload_register;
|
||||
use function str_replace;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function substr;
|
||||
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
|
||||
/**
|
||||
* Special Autoloader for Proxy classes, which are not PSR-0 compliant.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
/**
|
||||
* Resolves proxy class name to a filename based on the following pattern.
|
||||
*
|
||||
* 1. Remove Proxy namespace from class name.
|
||||
* 2. Remove namespace separators from remaining class name.
|
||||
* 3. Return PHP filename from proxy-dir with the result from 2.
|
||||
*
|
||||
* @param string $proxyDir
|
||||
* @param string $proxyNamespace
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function resolveFile($proxyDir, $proxyNamespace, $className)
|
||||
{
|
||||
if (strpos($className, $proxyNamespace) !== 0) {
|
||||
throw InvalidArgumentException::notProxyClass($className, $proxyNamespace);
|
||||
}
|
||||
|
||||
// remove proxy namespace from class name
|
||||
$classNameRelativeToProxyNamespace = substr($className, strlen($proxyNamespace));
|
||||
|
||||
// remove namespace separators from remaining class name
|
||||
$fileName = str_replace('\\', '', $classNameRelativeToProxyNamespace);
|
||||
|
||||
return $proxyDir . DIRECTORY_SEPARATOR . $fileName . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers and returns autoloader callback for the given proxy dir and namespace.
|
||||
*
|
||||
* @param string $proxyDir
|
||||
* @param string $proxyNamespace
|
||||
* @param callable|null $notFoundCallback Invoked when the proxy file is not found.
|
||||
*
|
||||
* @return Closure
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function register($proxyDir, $proxyNamespace, $notFoundCallback = null)
|
||||
{
|
||||
$proxyNamespace = ltrim($proxyNamespace, '\\');
|
||||
|
||||
if ($notFoundCallback !== null && ! is_callable($notFoundCallback)) {
|
||||
throw InvalidArgumentException::invalidClassNotFoundCallback($notFoundCallback);
|
||||
}
|
||||
|
||||
$autoloader = static function ($className) use ($proxyDir, $proxyNamespace, $notFoundCallback) {
|
||||
if ($proxyNamespace === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (strpos($className, $proxyNamespace) !== 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$file = Autoloader::resolveFile($proxyDir, $proxyNamespace, $className);
|
||||
|
||||
if ($notFoundCallback && ! file_exists($file)) {
|
||||
call_user_func($notFoundCallback, $proxyDir, $proxyNamespace, $className);
|
||||
}
|
||||
|
||||
require $file;
|
||||
};
|
||||
|
||||
spl_autoload_register($autoloader);
|
||||
|
||||
return $autoloader;
|
||||
}
|
||||
}
|
||||
110
vendor/doctrine/common/src/Proxy/Exception/InvalidArgumentException.php
vendored
Normal file
110
vendor/doctrine/common/src/Proxy/Exception/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy\Exception;
|
||||
|
||||
use Doctrine\Persistence\Proxy;
|
||||
use InvalidArgumentException as BaseInvalidArgumentException;
|
||||
|
||||
use function get_class;
|
||||
use function gettype;
|
||||
use function is_object;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Proxy Invalid Argument Exception.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class InvalidArgumentException extends BaseInvalidArgumentException implements ProxyException
|
||||
{
|
||||
/** @return self */
|
||||
public static function proxyDirectoryRequired()
|
||||
{
|
||||
return new self('You must configure a proxy directory. See docs for details');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $proxyNamespace
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function notProxyClass($className, $proxyNamespace)
|
||||
{
|
||||
return new self(sprintf('The class "%s" is not part of the proxy namespace "%s"', $className, $proxyNamespace));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidPlaceholder($name)
|
||||
{
|
||||
return new self(sprintf('Provided placeholder for "%s" must be either a string or a valid callable', $name));
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function proxyNamespaceRequired()
|
||||
{
|
||||
return new self('You must configure a proxy namespace');
|
||||
}
|
||||
|
||||
/** @return self */
|
||||
public static function unitializedProxyExpected(Proxy $proxy)
|
||||
{
|
||||
return new self(sprintf('Provided proxy of type "%s" must not be initialized.', get_class($proxy)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $callback
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidClassNotFoundCallback($callback)
|
||||
{
|
||||
$type = is_object($callback) ? get_class($callback) : gettype($callback);
|
||||
|
||||
return new self(sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function classMustNotBeAbstract($className)
|
||||
{
|
||||
return new self(sprintf('Unable to create a proxy for an abstract class "%s".', $className));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function classMustNotBeFinal($className)
|
||||
{
|
||||
return new self(sprintf('Unable to create a proxy for a final class "%s".', $className));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function classMustNotBeReadOnly($className)
|
||||
{
|
||||
return new self(sprintf('Unable to create a proxy for a readonly class "%s".', $className));
|
||||
}
|
||||
|
||||
/** @param mixed $value */
|
||||
public static function invalidAutoGenerateMode($value): self
|
||||
{
|
||||
return new self(sprintf('Invalid auto generate mode "%s" given.', $value));
|
||||
}
|
||||
}
|
||||
27
vendor/doctrine/common/src/Proxy/Exception/OutOfBoundsException.php
vendored
Normal file
27
vendor/doctrine/common/src/Proxy/Exception/OutOfBoundsException.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy\Exception;
|
||||
|
||||
use OutOfBoundsException as BaseOutOfBoundsException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Proxy Invalid Argument Exception.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class OutOfBoundsException extends BaseOutOfBoundsException implements ProxyException
|
||||
{
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $idField
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function missingPrimaryKeyValue($className, $idField)
|
||||
{
|
||||
return new self(sprintf('Missing value for primary key %s on %s', $idField, $className));
|
||||
}
|
||||
}
|
||||
12
vendor/doctrine/common/src/Proxy/Exception/ProxyException.php
vendored
Normal file
12
vendor/doctrine/common/src/Proxy/Exception/ProxyException.php
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy\Exception;
|
||||
|
||||
/**
|
||||
* Base exception interface for proxy exceptions.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
interface ProxyException
|
||||
{
|
||||
}
|
||||
72
vendor/doctrine/common/src/Proxy/Exception/UnexpectedValueException.php
vendored
Normal file
72
vendor/doctrine/common/src/Proxy/Exception/UnexpectedValueException.php
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy\Exception;
|
||||
|
||||
use Throwable;
|
||||
use UnexpectedValueException as BaseUnexpectedValueException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Proxy Unexpected Value Exception.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
class UnexpectedValueException extends BaseUnexpectedValueException implements ProxyException
|
||||
{
|
||||
/**
|
||||
* @param string $proxyDirectory
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function proxyDirectoryNotWritable($proxyDirectory)
|
||||
{
|
||||
return new self(sprintf('Your proxy directory "%s" must be writable', $proxyDirectory));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
* @param string $parameterName
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidParameterTypeHint(
|
||||
$className,
|
||||
$methodName,
|
||||
$parameterName,
|
||||
?Throwable $previous = null
|
||||
) {
|
||||
return new self(
|
||||
sprintf(
|
||||
'The type hint of parameter "%s" in method "%s" in class "%s" is invalid.',
|
||||
$parameterName,
|
||||
$methodName,
|
||||
$className
|
||||
),
|
||||
0,
|
||||
$previous
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $className
|
||||
* @param string $methodName
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function invalidReturnTypeHint($className, $methodName, ?Throwable $previous = null)
|
||||
{
|
||||
return new self(
|
||||
sprintf(
|
||||
'The return type of method "%s" in class "%s" is invalid.',
|
||||
$methodName,
|
||||
$className
|
||||
),
|
||||
0,
|
||||
$previous
|
||||
);
|
||||
}
|
||||
}
|
||||
68
vendor/doctrine/common/src/Proxy/Proxy.php
vendored
Normal file
68
vendor/doctrine/common/src/Proxy/Proxy.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy;
|
||||
|
||||
use Closure;
|
||||
use Doctrine\Persistence\Proxy as BaseProxy;
|
||||
|
||||
/**
|
||||
* Interface for proxy classes.
|
||||
*
|
||||
* @template T of object
|
||||
* @template-extends BaseProxy<T>
|
||||
*/
|
||||
interface Proxy extends BaseProxy
|
||||
{
|
||||
/**
|
||||
* Marks the proxy as initialized or not.
|
||||
*
|
||||
* @param bool $initialized
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __setInitialized($initialized);
|
||||
|
||||
/**
|
||||
* Sets the initializer callback to be used when initializing the proxy. That
|
||||
* initializer should accept 3 parameters: $proxy, $method and $params. Those
|
||||
* are respectively the proxy object that is being initialized, the method name
|
||||
* that triggered initialization and the parameters passed to that method.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __setInitializer(?Closure $initializer = null);
|
||||
|
||||
/**
|
||||
* Retrieves the initializer callback used to initialize the proxy.
|
||||
*
|
||||
* @see __setInitializer
|
||||
*
|
||||
* @return Closure|null
|
||||
*/
|
||||
public function __getInitializer();
|
||||
|
||||
/**
|
||||
* Sets the callback to be used when cloning the proxy. That initializer should accept
|
||||
* a single parameter, which is the cloned proxy instance itself.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __setCloner(?Closure $cloner = null);
|
||||
|
||||
/**
|
||||
* Retrieves the callback to be used when cloning the proxy.
|
||||
*
|
||||
* @see __setCloner
|
||||
*
|
||||
* @return Closure|null
|
||||
*/
|
||||
public function __getCloner();
|
||||
|
||||
/**
|
||||
* Retrieves the list of lazy loaded properties for a given proxy
|
||||
*
|
||||
* @return array<string, mixed> Keys are the property names, and values are the default values
|
||||
* for those properties.
|
||||
*/
|
||||
public function __getLazyProperties();
|
||||
}
|
||||
42
vendor/doctrine/common/src/Proxy/ProxyDefinition.php
vendored
Normal file
42
vendor/doctrine/common/src/Proxy/ProxyDefinition.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Proxy;
|
||||
|
||||
use ReflectionProperty;
|
||||
|
||||
/**
|
||||
* Definition structure how to create a proxy.
|
||||
*/
|
||||
class ProxyDefinition
|
||||
{
|
||||
/** @var string */
|
||||
public $proxyClassName;
|
||||
|
||||
/** @var array<string> */
|
||||
public $identifierFields;
|
||||
|
||||
/** @var ReflectionProperty[] */
|
||||
public $reflectionFields;
|
||||
|
||||
/** @var callable */
|
||||
public $initializer;
|
||||
|
||||
/** @var callable */
|
||||
public $cloner;
|
||||
|
||||
/**
|
||||
* @param string $proxyClassName
|
||||
* @param array<string> $identifierFields
|
||||
* @param array<string, ReflectionProperty> $reflectionFields
|
||||
* @param callable $initializer
|
||||
* @param callable $cloner
|
||||
*/
|
||||
public function __construct($proxyClassName, array $identifierFields, array $reflectionFields, $initializer, $cloner)
|
||||
{
|
||||
$this->proxyClassName = $proxyClassName;
|
||||
$this->identifierFields = $identifierFields;
|
||||
$this->reflectionFields = $reflectionFields;
|
||||
$this->initializer = $initializer;
|
||||
$this->cloner = $cloner;
|
||||
}
|
||||
}
|
||||
1292
vendor/doctrine/common/src/Proxy/ProxyGenerator.php
vendored
Normal file
1292
vendor/doctrine/common/src/Proxy/ProxyGenerator.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
113
vendor/doctrine/common/src/Util/ClassUtils.php
vendored
Normal file
113
vendor/doctrine/common/src/Util/ClassUtils.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Util;
|
||||
|
||||
use Doctrine\Persistence\Proxy;
|
||||
use ReflectionClass;
|
||||
|
||||
use function get_class;
|
||||
use function get_parent_class;
|
||||
use function ltrim;
|
||||
use function rtrim;
|
||||
use function strrpos;
|
||||
use function substr;
|
||||
|
||||
/**
|
||||
* Class and reflection related functionality for objects that
|
||||
* might or not be proxy objects at the moment.
|
||||
*/
|
||||
class ClassUtils
|
||||
{
|
||||
/**
|
||||
* Gets the real class name of a class name that could be a proxy.
|
||||
*
|
||||
* @param string $className
|
||||
* @psalm-param class-string<Proxy<T>>|class-string<T> $className
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public static function getRealClass($className)
|
||||
{
|
||||
$pos = strrpos($className, '\\' . Proxy::MARKER . '\\');
|
||||
|
||||
if ($pos === false) {
|
||||
/** @psalm-var class-string<T> */
|
||||
return $className;
|
||||
}
|
||||
|
||||
return substr($className, $pos + Proxy::MARKER_LENGTH + 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real class name of an object (even if its a proxy).
|
||||
*
|
||||
* @param object $object
|
||||
* @psalm-param Proxy<T>|T $object
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string<T>
|
||||
*
|
||||
* @template T of object
|
||||
*/
|
||||
public static function getClass($object)
|
||||
{
|
||||
return self::getRealClass(get_class($object));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the real parent class name of a class or object.
|
||||
*
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
public static function getParentClass($className)
|
||||
{
|
||||
return get_parent_class(self::getRealClass($className));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new reflection class.
|
||||
*
|
||||
* @param string $className
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return ReflectionClass
|
||||
*/
|
||||
public static function newReflectionClass($className)
|
||||
{
|
||||
return new ReflectionClass(self::getRealClass($className));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new reflection object.
|
||||
*
|
||||
* @param object $object
|
||||
*
|
||||
* @return ReflectionClass
|
||||
*/
|
||||
public static function newReflectionObject($object)
|
||||
{
|
||||
return self::newReflectionClass(self::getClass($object));
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a class name and a proxy namespace returns the proxy name.
|
||||
*
|
||||
* @param string $className
|
||||
* @param string $proxyNamespace
|
||||
* @psalm-param class-string $className
|
||||
*
|
||||
* @return string
|
||||
* @psalm-return class-string
|
||||
*/
|
||||
public static function generateProxyClassName($className, $proxyNamespace)
|
||||
{
|
||||
return rtrim($proxyNamespace, '\\') . '\\' . Proxy::MARKER . '\\' . ltrim($className, '\\');
|
||||
}
|
||||
}
|
||||
185
vendor/doctrine/common/src/Util/Debug.php
vendored
Normal file
185
vendor/doctrine/common/src/Util/Debug.php
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Common\Util;
|
||||
|
||||
use ArrayIterator;
|
||||
use ArrayObject;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Persistence\Proxy;
|
||||
use stdClass;
|
||||
|
||||
use function array_keys;
|
||||
use function count;
|
||||
use function end;
|
||||
use function explode;
|
||||
use function extension_loaded;
|
||||
use function get_class;
|
||||
use function html_entity_decode;
|
||||
use function ini_get;
|
||||
use function ini_set;
|
||||
use function is_array;
|
||||
use function is_object;
|
||||
use function method_exists;
|
||||
use function ob_end_clean;
|
||||
use function ob_get_contents;
|
||||
use function ob_start;
|
||||
use function spl_object_hash;
|
||||
use function strip_tags;
|
||||
use function var_dump;
|
||||
|
||||
/**
|
||||
* Static class containing most used debug methods.
|
||||
*
|
||||
* @deprecated The Debug class is deprecated, please use symfony/var-dumper instead.
|
||||
*
|
||||
* @link www.doctrine-project.org
|
||||
*/
|
||||
final class Debug
|
||||
{
|
||||
/**
|
||||
* Private constructor (prevents instantiation).
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a dump of the public, protected and private properties of $var.
|
||||
*
|
||||
* @link https://xdebug.org/
|
||||
*
|
||||
* @param mixed $var The variable to dump.
|
||||
* @param int $maxDepth The maximum nesting level for object properties.
|
||||
* @param bool $stripTags Whether output should strip HTML tags.
|
||||
* @param bool $echo Send the dumped value to the output buffer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true)
|
||||
{
|
||||
$html = ini_get('html_errors');
|
||||
|
||||
if ($html !== true) {
|
||||
ini_set('html_errors', 'on');
|
||||
}
|
||||
|
||||
if (extension_loaded('xdebug')) {
|
||||
ini_set('xdebug.var_display_max_depth', $maxDepth);
|
||||
}
|
||||
|
||||
$var = self::export($var, $maxDepth);
|
||||
|
||||
ob_start();
|
||||
var_dump($var);
|
||||
|
||||
$dump = ob_get_contents();
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
$dumpText = ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
|
||||
|
||||
ini_set('html_errors', $html);
|
||||
|
||||
if ($echo) {
|
||||
echo $dumpText;
|
||||
}
|
||||
|
||||
return $dumpText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $var
|
||||
* @param int $maxDepth
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function export($var, $maxDepth)
|
||||
{
|
||||
$return = null;
|
||||
$isObj = is_object($var);
|
||||
|
||||
if ($var instanceof Collection) {
|
||||
$var = $var->toArray();
|
||||
}
|
||||
|
||||
if (! $maxDepth) {
|
||||
return is_object($var) ? get_class($var)
|
||||
: (is_array($var) ? 'Array(' . count($var) . ')' : $var);
|
||||
}
|
||||
|
||||
if (is_array($var)) {
|
||||
$return = [];
|
||||
|
||||
foreach ($var as $k => $v) {
|
||||
$return[$k] = self::export($v, $maxDepth - 1);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
if (! $isObj) {
|
||||
return $var;
|
||||
}
|
||||
|
||||
$return = new stdClass();
|
||||
if ($var instanceof DateTimeInterface) {
|
||||
$return->__CLASS__ = get_class($var);
|
||||
$return->date = $var->format('c');
|
||||
$return->timezone = $var->getTimezone()->getName();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
$return->__CLASS__ = ClassUtils::getClass($var);
|
||||
|
||||
if ($var instanceof Proxy) {
|
||||
$return->__IS_PROXY__ = true;
|
||||
$return->__PROXY_INITIALIZED__ = $var->__isInitialized();
|
||||
}
|
||||
|
||||
if ($var instanceof ArrayObject || $var instanceof ArrayIterator) {
|
||||
$return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1);
|
||||
}
|
||||
|
||||
return self::fillReturnWithClassAttributes($var, $return, $maxDepth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill the $return variable with class attributes
|
||||
* Based on obj2array function from {@see https://secure.php.net/manual/en/function.get-object-vars.php#47075}
|
||||
*
|
||||
* @param object $var
|
||||
* @param int $maxDepth
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private static function fillReturnWithClassAttributes($var, stdClass $return, $maxDepth)
|
||||
{
|
||||
$clone = (array) $var;
|
||||
|
||||
foreach (array_keys($clone) as $key) {
|
||||
$aux = explode("\0", $key);
|
||||
$name = end($aux);
|
||||
if ($aux[0] === '') {
|
||||
$name .= ':' . ($aux[1] === '*' ? 'protected' : $aux[1] . ':private');
|
||||
}
|
||||
|
||||
$return->$name = self::export($clone[$key], $maxDepth - 1);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of an object.
|
||||
*
|
||||
* @param object $obj
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toString($obj)
|
||||
{
|
||||
return method_exists($obj, '__toString') ? (string) $obj : get_class($obj) . '@' . spl_object_hash($obj);
|
||||
}
|
||||
}
|
||||
4
vendor/doctrine/dbal/CONTRIBUTING.md
vendored
Normal file
4
vendor/doctrine/dbal/CONTRIBUTING.md
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
Doctrine has [general contributing guidelines][contributor workflow], make
|
||||
sure you follow them.
|
||||
|
||||
[contributor workflow]: https://www.doctrine-project.org/contribute/index.html
|
||||
19
vendor/doctrine/dbal/LICENSE
vendored
Normal file
19
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.
|
||||
34
vendor/doctrine/dbal/README.md
vendored
Normal file
34
vendor/doctrine/dbal/README.md
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# Doctrine DBAL
|
||||
|
||||
| [4.0-dev][4.0] | [3.6][3.6] |
|
||||
|:-----------------------------------------------:|:---------------------------------------------------:|
|
||||
| [![GitHub Actions][GA 4.0 image]][GA 4.0] | [![GitHub Actions][GA 3.6 image]][GA 3.6] |
|
||||
| [![AppVeyor][AppVeyor 4.0 image]][AppVeyor 4.0] | [![AppVeyor][AppVeyor 3.6 image]][AppVeyor 3.6] |
|
||||
| [![Code Coverage][Coverage image]][CodeCov 4.0] | [![Code Coverage][Coverage 3.6 image]][CodeCov 3.6] |
|
||||
| N/A | [![Type Coverage][TypeCov 3.6 image]][TypeCov 3.6] |
|
||||
|
||||
Powerful ***D***ata***B***ase ***A***bstraction ***L***ayer with many features for database schema introspection and schema management.
|
||||
|
||||
## More resources:
|
||||
|
||||
* [Website](http://www.doctrine-project.org/projects/dbal.html)
|
||||
* [Documentation](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/)
|
||||
* [Issue Tracker](https://github.com/doctrine/dbal/issues)
|
||||
|
||||
[Coverage image]: https://codecov.io/gh/doctrine/dbal/branch/4.0.x/graph/badge.svg
|
||||
[4.0]: https://github.com/doctrine/dbal/tree/4.0.x
|
||||
[CodeCov 4.0]: https://codecov.io/gh/doctrine/dbal/branch/4.0.x
|
||||
[AppVeyor 4.0]: https://ci.appveyor.com/project/doctrine/dbal/branch/4.0.x
|
||||
[AppVeyor 4.0 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/4.0.x?svg=true
|
||||
[GA 4.0]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A4.0.x
|
||||
[GA 4.0 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg
|
||||
|
||||
[Coverage 3.6 image]: https://codecov.io/gh/doctrine/dbal/branch/3.6.x/graph/badge.svg
|
||||
[3.6]: https://github.com/doctrine/dbal/tree/3.6.x
|
||||
[CodeCov 3.6]: https://codecov.io/gh/doctrine/dbal/branch/3.6.x
|
||||
[AppVeyor 3.6]: https://ci.appveyor.com/project/doctrine/dbal/branch/3.6.x
|
||||
[AppVeyor 3.6 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/3.6.x?svg=true
|
||||
[GA 3.6]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A3.6.x
|
||||
[GA 3.6 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg?branch=3.6.x
|
||||
[TypeCov 3.6]: https://shepherd.dev/github/doctrine/dbal
|
||||
[TypeCov 3.6 image]: https://shepherd.dev/github/doctrine/dbal/coverage.svg
|
||||
4
vendor/doctrine/dbal/bin/doctrine-dbal
vendored
Normal file
4
vendor/doctrine/dbal/bin/doctrine-dbal
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/doctrine-dbal.php';
|
||||
55
vendor/doctrine/dbal/bin/doctrine-dbal.php
vendored
Normal file
55
vendor/doctrine/dbal/bin/doctrine-dbal.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
|
||||
|
||||
fwrite(
|
||||
STDERR,
|
||||
'[Warning] The use of this script is discouraged.'
|
||||
. ' You find instructions on how to bootstrap the console runner in our documentation.'
|
||||
. PHP_EOL,
|
||||
);
|
||||
|
||||
echo PHP_EOL . PHP_EOL;
|
||||
|
||||
$files = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'];
|
||||
$loader = null;
|
||||
$cwd = getcwd();
|
||||
$directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config'];
|
||||
$configFile = null;
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (file_exists($file)) {
|
||||
$loader = require $file;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $loader) {
|
||||
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
|
||||
}
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
|
||||
|
||||
if (file_exists($configFile)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! file_exists($configFile)) {
|
||||
ConsoleRunner::printCliConfigTemplate();
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (! is_readable($configFile)) {
|
||||
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$commands = [];
|
||||
$connectionProvider = require $configFile;
|
||||
|
||||
ConsoleRunner::run($connectionProvider, $commands);
|
||||
72
vendor/doctrine/dbal/composer.json
vendored
Normal file
72
vendor/doctrine/dbal/composer.json
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"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": "^7.4 || ^8.0",
|
||||
"composer-runtime-api": "^2",
|
||||
"doctrine/cache": "^1.11|^2.0",
|
||||
"doctrine/deprecations": "^0.5.3|^1",
|
||||
"doctrine/event-manager": "^1|^2",
|
||||
"psr/cache": "^1|^2|^3",
|
||||
"psr/log": "^1|^2|^3"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "12.0.0",
|
||||
"fig/log-test": "^1",
|
||||
"jetbrains/phpstorm-stubs": "2023.1",
|
||||
"phpstan/phpstan": "1.10.21",
|
||||
"phpstan/phpstan-strict-rules": "^1.5",
|
||||
"phpunit/phpunit": "9.6.9",
|
||||
"psalm/plugin-phpunit": "0.18.4",
|
||||
"squizlabs/php_codesniffer": "3.7.2",
|
||||
"symfony/cache": "^5.4|^6.0",
|
||||
"symfony/console": "^4.4|^5.4|^6.0",
|
||||
"vimeo/psalm": "4.30.0"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/console": "For helpful console commands such as SQL execution and import of files."
|
||||
},
|
||||
"bin": ["bin/doctrine-dbal"],
|
||||
"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" }
|
||||
}
|
||||
}
|
||||
37
vendor/doctrine/dbal/src/ArrayParameterType.php
vendored
Normal file
37
vendor/doctrine/dbal/src/ArrayParameterType.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
final class ArrayParameterType
|
||||
{
|
||||
/**
|
||||
* Represents an array of ints to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
public const INTEGER = ParameterType::INTEGER + Connection::ARRAY_PARAM_OFFSET;
|
||||
|
||||
/**
|
||||
* Represents an array of strings to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
public const STRING = ParameterType::STRING + Connection::ARRAY_PARAM_OFFSET;
|
||||
|
||||
/**
|
||||
* Represents an array of ascii strings to be expanded by Doctrine SQL parsing.
|
||||
*/
|
||||
public const ASCII = ParameterType::ASCII + Connection::ARRAY_PARAM_OFFSET;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-param self::INTEGER|self::STRING|self::ASCII $type
|
||||
*
|
||||
* @psalm-return ParameterType::INTEGER|ParameterType::STRING|ParameterType::ASCII
|
||||
*/
|
||||
public static function toElementParameterType(int $type): int
|
||||
{
|
||||
return $type - Connection::ARRAY_PARAM_OFFSET;
|
||||
}
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
10
vendor/doctrine/dbal/src/ArrayParameters/Exception.php
vendored
Normal file
10
vendor/doctrine/dbal/src/ArrayParameters/Exception.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters;
|
||||
|
||||
use Throwable;
|
||||
|
||||
/** @internal */
|
||||
interface Exception extends Throwable
|
||||
{
|
||||
}
|
||||
19
vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingNamedParameter.php
vendored
Normal file
19
vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingNamedParameter.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters\Exception;
|
||||
|
||||
use Doctrine\DBAL\ArrayParameters\Exception;
|
||||
use LogicException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/** @psalm-immutable */
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
23
vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingPositionalParameter.php
vendored
Normal file
23
vendor/doctrine/dbal/src/ArrayParameters/Exception/MissingPositionalParameter.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\ArrayParameters\Exception;
|
||||
|
||||
use Doctrine\DBAL\ArrayParameters\Exception;
|
||||
use LogicException;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
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),
|
||||
);
|
||||
}
|
||||
}
|
||||
116
vendor/doctrine/dbal/src/Cache/ArrayResult.php
vendored
Normal file
116
vendor/doctrine/dbal/src/Cache/ArrayResult.php
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\Result;
|
||||
|
||||
use function array_values;
|
||||
use function count;
|
||||
use function reset;
|
||||
|
||||
/** @internal The class is internal to the caching layer implementation. */
|
||||
final class ArrayResult implements Result
|
||||
{
|
||||
/** @var list<array<string, mixed>> */
|
||||
private array $data;
|
||||
|
||||
private int $columnCount = 0;
|
||||
private int $num = 0;
|
||||
|
||||
/** @param list<array<string, mixed>> $data */
|
||||
public function __construct(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
if (count($data) === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->columnCount = count($data[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchNumeric()
|
||||
{
|
||||
$row = $this->fetch();
|
||||
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return array_values($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchAssociative()
|
||||
{
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function fetchOne()
|
||||
{
|
||||
$row = $this->fetch();
|
||||
|
||||
if ($row === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return reset($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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->data);
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
return $this->columnCount;
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
$this->data = [];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed>|false */
|
||||
private function fetch()
|
||||
{
|
||||
if (! isset($this->data[$this->num])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->data[$this->num++];
|
||||
}
|
||||
}
|
||||
21
vendor/doctrine/dbal/src/Cache/CacheException.php
vendored
Normal file
21
vendor/doctrine/dbal/src/Cache/CacheException.php
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class CacheException extends Exception
|
||||
{
|
||||
/** @return CacheException */
|
||||
public static function noCacheKey()
|
||||
{
|
||||
return new self('No cache key was set.');
|
||||
}
|
||||
|
||||
/** @return CacheException */
|
||||
public static function noResultDriverConfigured()
|
||||
{
|
||||
return new self('Trying to cache a query but no result driver is configured.');
|
||||
}
|
||||
}
|
||||
176
vendor/doctrine/dbal/src/Cache/QueryCacheProfile.php
vendored
Normal file
176
vendor/doctrine/dbal/src/Cache/QueryCacheProfile.php
vendored
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Cache;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\Psr6\CacheAdapter;
|
||||
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use TypeError;
|
||||
|
||||
use function get_class;
|
||||
use function hash;
|
||||
use function serialize;
|
||||
use function sha1;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Query Cache Profile handles the data relevant for query caching.
|
||||
*
|
||||
* It is a value object, setter methods return NEW instances.
|
||||
*/
|
||||
class QueryCacheProfile
|
||||
{
|
||||
private ?CacheItemPoolInterface $resultCache = null;
|
||||
|
||||
/** @var int */
|
||||
private $lifetime;
|
||||
|
||||
/** @var string|null */
|
||||
private $cacheKey;
|
||||
|
||||
/**
|
||||
* @param int $lifetime
|
||||
* @param string|null $cacheKey
|
||||
* @param CacheItemPoolInterface|Cache|null $resultCache
|
||||
*/
|
||||
public function __construct($lifetime = 0, $cacheKey = null, ?object $resultCache = null)
|
||||
{
|
||||
$this->lifetime = $lifetime;
|
||||
$this->cacheKey = $cacheKey;
|
||||
if ($resultCache instanceof CacheItemPoolInterface) {
|
||||
$this->resultCache = $resultCache;
|
||||
} elseif ($resultCache instanceof Cache) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4620',
|
||||
'Passing an instance of %s to %s as $resultCache is deprecated. Pass an instance of %s instead.',
|
||||
Cache::class,
|
||||
__METHOD__,
|
||||
CacheItemPoolInterface::class,
|
||||
);
|
||||
|
||||
$this->resultCache = CacheAdapter::wrap($resultCache);
|
||||
} elseif ($resultCache !== null) {
|
||||
throw new TypeError(sprintf(
|
||||
'$resultCache: Expected either null or an instance of %s or %s, got %s.',
|
||||
CacheItemPoolInterface::class,
|
||||
Cache::class,
|
||||
get_class($resultCache),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function getResultCache(): ?CacheItemPoolInterface
|
||||
{
|
||||
return $this->resultCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see getResultCache()} instead.
|
||||
*
|
||||
* @return Cache|null
|
||||
*/
|
||||
public function getResultCacheDriver()
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4620',
|
||||
'%s is deprecated, call getResultCache() instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
return $this->resultCache !== null ? DoctrineProvider::wrap($this->resultCache) : null;
|
||||
}
|
||||
|
||||
/** @return int */
|
||||
public function getLifetime()
|
||||
{
|
||||
return $this->lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @throws CacheException
|
||||
*/
|
||||
public function getCacheKey()
|
||||
{
|
||||
if ($this->cacheKey === null) {
|
||||
throw CacheException::noCacheKey();
|
||||
}
|
||||
|
||||
return $this->cacheKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the real cache key from query, params, types and connection parameters.
|
||||
*
|
||||
* @param string $sql
|
||||
* @param list<mixed>|array<string, mixed> $params
|
||||
* @param array<int, Type|int|string|null>|array<string, Type|int|string|null> $types
|
||||
* @param array<string, mixed> $connectionParams
|
||||
*
|
||||
* @return array{string, string}
|
||||
*/
|
||||
public function generateCacheKeys($sql, $params, $types, array $connectionParams = [])
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@see setResultCache()} instead.
|
||||
*
|
||||
* @return QueryCacheProfile
|
||||
*/
|
||||
public function setResultCacheDriver(Cache $cache)
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4620',
|
||||
'%s is deprecated, call setResultCache() instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
return new QueryCacheProfile($this->lifetime, $this->cacheKey, CacheAdapter::wrap($cache));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $cacheKey
|
||||
*
|
||||
* @return QueryCacheProfile
|
||||
*/
|
||||
public function setCacheKey($cacheKey)
|
||||
{
|
||||
return new QueryCacheProfile($this->lifetime, $cacheKey, $this->resultCache);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lifetime
|
||||
*
|
||||
* @return QueryCacheProfile
|
||||
*/
|
||||
public function setLifetime($lifetime)
|
||||
{
|
||||
return new QueryCacheProfile($lifetime, $this->cacheKey, $this->resultCache);
|
||||
}
|
||||
}
|
||||
28
vendor/doctrine/dbal/src/ColumnCase.php
vendored
Normal file
28
vendor/doctrine/dbal/src/ColumnCase.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
/**
|
||||
* Contains portable column case conversions.
|
||||
*/
|
||||
final class ColumnCase
|
||||
{
|
||||
/**
|
||||
* Convert column names to upper case.
|
||||
*/
|
||||
public const UPPER = 1;
|
||||
|
||||
/**
|
||||
* Convert column names to lower case.
|
||||
*/
|
||||
public const LOWER = 2;
|
||||
|
||||
/**
|
||||
* This class cannot be instantiated.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
}
|
||||
244
vendor/doctrine/dbal/src/Configuration.php
vendored
Normal file
244
vendor/doctrine/dbal/src/Configuration.php
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Common\Cache\Psr6\CacheAdapter;
|
||||
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
|
||||
use Doctrine\DBAL\Driver\Middleware;
|
||||
use Doctrine\DBAL\Logging\SQLLogger;
|
||||
use Doctrine\DBAL\Schema\SchemaManagerFactory;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
use function func_num_args;
|
||||
|
||||
/**
|
||||
* Configuration container for the Doctrine DBAL.
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
/** @var Middleware[] */
|
||||
private array $middlewares = [];
|
||||
|
||||
/**
|
||||
* The SQL logger in use. If null, SQL logging is disabled.
|
||||
*
|
||||
* @var SQLLogger|null
|
||||
*/
|
||||
protected $sqlLogger;
|
||||
|
||||
/**
|
||||
* The cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
private ?CacheItemPoolInterface $resultCache = null;
|
||||
|
||||
/**
|
||||
* The cache driver implementation that is used for query result caching.
|
||||
*
|
||||
* @deprecated Use {@see $resultCache} instead.
|
||||
*
|
||||
* @var Cache|null
|
||||
*/
|
||||
protected $resultCacheImpl;
|
||||
|
||||
/**
|
||||
* The callable to use to filter schema assets.
|
||||
*
|
||||
* @var callable|null
|
||||
*/
|
||||
protected $schemaAssetsFilter;
|
||||
|
||||
/**
|
||||
* The default auto-commit mode for connections.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $autoCommit = true;
|
||||
|
||||
private ?SchemaManagerFactory $schemaManagerFactory = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->schemaAssetsFilter = static function (): bool {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
|
||||
*
|
||||
* @deprecated Use {@see setMiddlewares()} and {@see \Doctrine\DBAL\Logging\Middleware} instead.
|
||||
*/
|
||||
public function setSQLLogger(?SQLLogger $logger = null): void
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4967',
|
||||
'%s is deprecated, use setMiddlewares() and Logging\\Middleware instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
$this->sqlLogger = $logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SQL logger that is used.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function getSQLLogger(): ?SQLLogger
|
||||
{
|
||||
Deprecation::triggerIfCalledFromOutside(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4967',
|
||||
'%s is deprecated.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
return $this->sqlLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
public function getResultCache(): ?CacheItemPoolInterface
|
||||
{
|
||||
return $this->resultCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cache driver implementation that is used for query result caching.
|
||||
*
|
||||
* @deprecated Use {@see getResultCache()} instead.
|
||||
*/
|
||||
public function getResultCacheImpl(): ?Cache
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4620',
|
||||
'%s is deprecated, call getResultCache() instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
return $this->resultCacheImpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache driver implementation that is used for query result caching.
|
||||
*/
|
||||
public function setResultCache(CacheItemPoolInterface $cache): void
|
||||
{
|
||||
$this->resultCacheImpl = DoctrineProvider::wrap($cache);
|
||||
$this->resultCache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cache driver implementation that is used for query result caching.
|
||||
*
|
||||
* @deprecated Use {@see setResultCache()} instead.
|
||||
*/
|
||||
public function setResultCacheImpl(Cache $cacheImpl): void
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/4620',
|
||||
'%s is deprecated, call setResultCache() instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
$this->resultCacheImpl = $cacheImpl;
|
||||
$this->resultCache = CacheAdapter::wrap($cacheImpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the callable to use to filter schema assets.
|
||||
*/
|
||||
public function setSchemaAssetsFilter(?callable $callable = null): void
|
||||
{
|
||||
if (func_num_args() < 1) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5483',
|
||||
'Not passing an argument to %s is deprecated.',
|
||||
__METHOD__,
|
||||
);
|
||||
} elseif ($callable === null) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5483',
|
||||
'Using NULL as a schema asset filter is deprecated.'
|
||||
. ' Use a callable that always returns true instead.',
|
||||
);
|
||||
}
|
||||
|
||||
$this->schemaAssetsFilter = $callable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
1976
vendor/doctrine/dbal/src/Connection.php
vendored
Normal file
1976
vendor/doctrine/dbal/src/Connection.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
vendor/doctrine/dbal/src/ConnectionException.php
vendored
Normal file
31
vendor/doctrine/dbal/src/ConnectionException.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL;
|
||||
|
||||
/** @psalm-immutable */
|
||||
class ConnectionException extends Exception
|
||||
{
|
||||
/** @return ConnectionException */
|
||||
public static function commitFailedRollbackOnly()
|
||||
{
|
||||
return new self('Transaction commit failed because the transaction has been marked for rollback only.');
|
||||
}
|
||||
|
||||
/** @return ConnectionException */
|
||||
public static function noActiveTransaction()
|
||||
{
|
||||
return new self('There is no active transaction.');
|
||||
}
|
||||
|
||||
/** @return ConnectionException */
|
||||
public static function savepointsNotSupported()
|
||||
{
|
||||
return new self('Savepoints are not supported by this driver.');
|
||||
}
|
||||
|
||||
/** @return ConnectionException */
|
||||
public static function mayNotAlterNestedTransactionWithSavepointsInTransaction()
|
||||
{
|
||||
return new self('May not alter the nested transaction with savepoints behavior while a transaction is open.');
|
||||
}
|
||||
}
|
||||
374
vendor/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php
vendored
Normal file
374
vendor/doctrine/dbal/src/Connections/PrimaryReadReplicaConnection.php
vendored
Normal file
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Connections;
|
||||
|
||||
use Doctrine\Common\EventManager;
|
||||
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\Event\ConnectionEventArgs;
|
||||
use Doctrine\DBAL\Events;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\Statement;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use InvalidArgumentException;
|
||||
use SensitiveParameter;
|
||||
|
||||
use function array_rand;
|
||||
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:
|
||||
*
|
||||
* @psalm-import-type Params 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 DriverConnection[]|null[]
|
||||
*/
|
||||
protected $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.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $keepReplica = false;
|
||||
|
||||
/**
|
||||
* Creates Primary Replica Connection.
|
||||
*
|
||||
* @internal The connection can be only instantiated by the driver manager.
|
||||
*
|
||||
* @param array<string,mixed> $params
|
||||
* @psalm-param Params $params
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __construct(
|
||||
array $params,
|
||||
Driver $driver,
|
||||
?Configuration $config = null,
|
||||
?EventManager $eventManager = 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 = (bool) ($params['keepReplica'] ?? false);
|
||||
|
||||
parent::__construct($params, $driver, $config, $eventManager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the connection is currently towards the primary or not.
|
||||
*/
|
||||
public function isConnectedToPrimary(): bool
|
||||
{
|
||||
return $this->_conn !== null && $this->_conn === $this->connections['primary'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $connectionName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function connect($connectionName = null)
|
||||
{
|
||||
if ($connectionName !== null) {
|
||||
throw new InvalidArgumentException(
|
||||
'Passing a connection name as first argument is not supported anymore.'
|
||||
. ' Use ensureConnectedToPrimary()/ensureConnectedToReplica() instead.',
|
||||
);
|
||||
}
|
||||
|
||||
return $this->performConnect();
|
||||
}
|
||||
|
||||
protected function performConnect(?string $connectionName = null): bool
|
||||
{
|
||||
$requestedConnectionChange = ($connectionName !== null);
|
||||
$connectionName = $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 false;
|
||||
}
|
||||
|
||||
$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 false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if ($this->_eventManager->hasListeners(Events::postConnect)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/5784',
|
||||
'Subscribing to %s events is deprecated. Implement a middleware instead.',
|
||||
Events::postConnect,
|
||||
);
|
||||
|
||||
$eventArgs = new ConnectionEventArgs($this);
|
||||
$this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the primary node of the database cluster.
|
||||
*
|
||||
* All following statements after this will be executed against the primary node.
|
||||
*/
|
||||
public function ensureConnectedToPrimary(): bool
|
||||
{
|
||||
return $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.
|
||||
*/
|
||||
public function ensureConnectedToReplica(): bool
|
||||
{
|
||||
return $this->performConnect('replica');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to a specific connection.
|
||||
*
|
||||
* @param string $connectionName
|
||||
*
|
||||
* @return DriverConnection
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function connectTo($connectionName)
|
||||
{
|
||||
$params = $this->getParams();
|
||||
|
||||
$connectionParams = $this->chooseConnectionConfiguration($connectionName, $params);
|
||||
|
||||
try {
|
||||
return $this->_driver->connect($connectionParams);
|
||||
} catch (DriverException $e) {
|
||||
throw $this->convertException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $connectionName
|
||||
* @param mixed[] $params
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function chooseConnectionConfiguration(
|
||||
$connectionName,
|
||||
#[SensitiveParameter]
|
||||
$params
|
||||
) {
|
||||
if ($connectionName === 'primary') {
|
||||
return $params['primary'];
|
||||
}
|
||||
|
||||
$config = $params['replica'][array_rand($params['replica'])];
|
||||
|
||||
if (! isset($config['charset']) && isset($params['primary']['charset'])) {
|
||||
$config['charset'] = $params['primary']['charset'];
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function executeStatement($sql, array $params = [], array $types = [])
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::executeStatement($sql, $params, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function beginTransaction()
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::beginTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function commit()
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function rollBack()
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::rollBack();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
unset($this->connections['primary'], $this->connections['replica']);
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->_conn = null;
|
||||
$this->connections = ['primary' => null, 'replica' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function createSavepoint($savepoint)
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::createSavepoint($savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function releaseSavepoint($savepoint)
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::releaseSavepoint($savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function rollbackSavepoint($savepoint)
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
parent::rollbackSavepoint($savepoint);
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
$this->ensureConnectedToPrimary();
|
||||
|
||||
return parent::prepare($sql);
|
||||
}
|
||||
}
|
||||
57
vendor/doctrine/dbal/src/Driver.php
vendored
Normal file
57
vendor/doctrine/dbal/src/Driver.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
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\Schema\AbstractSchemaManager;
|
||||
use SensitiveParameter;
|
||||
|
||||
/**
|
||||
* Driver interface.
|
||||
* Interface that all DBAL drivers must implement.
|
||||
*
|
||||
* @psalm-import-type Params from DriverManager
|
||||
*/
|
||||
interface Driver
|
||||
{
|
||||
/**
|
||||
* Attempts to create a connection with the database.
|
||||
*
|
||||
* @param array<string, mixed> $params All connection parameters.
|
||||
* @psalm-param Params $params All connection parameters.
|
||||
*
|
||||
* @return DriverConnection The database connection.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params
|
||||
);
|
||||
|
||||
/**
|
||||
* Gets the DatabasePlatform instance that provides all the metadata about
|
||||
* the platform this driver connects to.
|
||||
*
|
||||
* @return AbstractPlatform The database platform.
|
||||
*/
|
||||
public function getDatabasePlatform();
|
||||
|
||||
/**
|
||||
* Gets the SchemaManager that can be used to inspect and change the underlying
|
||||
* database schema of the platform this driver connects to.
|
||||
*
|
||||
* @deprecated Use {@link AbstractPlatform::createSchemaManager()} instead.
|
||||
*
|
||||
* @return AbstractSchemaManager
|
||||
*/
|
||||
public function getSchemaManager(Connection $conn, AbstractPlatform $platform);
|
||||
|
||||
/**
|
||||
* Gets the ExceptionConverter that can be used to convert driver-level exceptions into DBAL exceptions.
|
||||
*/
|
||||
public function getExceptionConverter(): ExceptionConverter;
|
||||
}
|
||||
25
vendor/doctrine/dbal/src/Driver/API/ExceptionConverter.php
vendored
Normal file
25
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;
|
||||
}
|
||||
65
vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
vendored
Normal file
65
vendor/doctrine/dbal/src/Driver/API/IBMDB2/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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
|
||||
{
|
||||
switch ($exception->getCode()) {
|
||||
case -104:
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
|
||||
case -203:
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
|
||||
case -204:
|
||||
return new TableNotFoundException($exception, $query);
|
||||
|
||||
case -206:
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
|
||||
case -407:
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
|
||||
case -530:
|
||||
case -531:
|
||||
case -532:
|
||||
case -20356:
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
|
||||
case -601:
|
||||
return new TableExistsException($exception, $query);
|
||||
|
||||
case -803:
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
|
||||
case -1336:
|
||||
case -30082:
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
119
vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
vendored
Normal file
119
vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?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;
|
||||
|
||||
/** @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
|
||||
{
|
||||
switch ($exception->getCode()) {
|
||||
case 1008:
|
||||
return new DatabaseDoesNotExist($exception, $query);
|
||||
|
||||
case 1213:
|
||||
return new DeadlockException($exception, $query);
|
||||
|
||||
case 1205:
|
||||
return new LockWaitTimeoutException($exception, $query);
|
||||
|
||||
case 1050:
|
||||
return new TableExistsException($exception, $query);
|
||||
|
||||
case 1051:
|
||||
case 1146:
|
||||
return new TableNotFoundException($exception, $query);
|
||||
|
||||
case 1216:
|
||||
case 1217:
|
||||
case 1451:
|
||||
case 1452:
|
||||
case 1701:
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
|
||||
case 1062:
|
||||
case 1557:
|
||||
case 1569:
|
||||
case 1586:
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
|
||||
case 1054:
|
||||
case 1166:
|
||||
case 1611:
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
|
||||
case 1052:
|
||||
case 1060:
|
||||
case 1110:
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
|
||||
case 1064:
|
||||
case 1149:
|
||||
case 1287:
|
||||
case 1341:
|
||||
case 1342:
|
||||
case 1343:
|
||||
case 1344:
|
||||
case 1382:
|
||||
case 1479:
|
||||
case 1541:
|
||||
case 1554:
|
||||
case 1626:
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
|
||||
case 1044:
|
||||
case 1045:
|
||||
case 1046:
|
||||
case 1049:
|
||||
case 1095:
|
||||
case 1142:
|
||||
case 1143:
|
||||
case 1227:
|
||||
case 1370:
|
||||
case 1429:
|
||||
case 2002:
|
||||
case 2005:
|
||||
case 2054:
|
||||
return new ConnectionException($exception, $query);
|
||||
|
||||
case 2006:
|
||||
return new ConnectionLost($exception, $query);
|
||||
|
||||
case 1048:
|
||||
case 1121:
|
||||
case 1138:
|
||||
case 1171:
|
||||
case 1252:
|
||||
case 1263:
|
||||
case 1364:
|
||||
case 1566:
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
74
vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
vendored
Normal file
74
vendor/doctrine/dbal/src/Driver/API/OCI/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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\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\UniqueConstraintViolationException;
|
||||
use Doctrine\DBAL\Query;
|
||||
|
||||
/** @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
|
||||
{
|
||||
switch ($exception->getCode()) {
|
||||
case 1:
|
||||
case 2299:
|
||||
case 38911:
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
|
||||
case 904:
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
|
||||
case 918:
|
||||
case 960:
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
|
||||
case 923:
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
|
||||
case 942:
|
||||
return new TableNotFoundException($exception, $query);
|
||||
|
||||
case 955:
|
||||
return new TableExistsException($exception, $query);
|
||||
|
||||
case 1017:
|
||||
case 12545:
|
||||
return new ConnectionException($exception, $query);
|
||||
|
||||
case 1400:
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
|
||||
case 1918:
|
||||
return new DatabaseDoesNotExist($exception, $query);
|
||||
|
||||
case 2289:
|
||||
case 2443:
|
||||
case 4080:
|
||||
return new DatabaseObjectNotFoundException($exception, $query);
|
||||
|
||||
case 2266:
|
||||
case 2291:
|
||||
case 2292:
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
89
vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php
vendored
Normal file
89
vendor/doctrine/dbal/src/Driver/API/PostgreSQL/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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\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 strpos;
|
||||
|
||||
/** @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 (strpos($exception->getMessage(), 'truncate') !== false) {
|
||||
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);
|
||||
}
|
||||
|
||||
// Prior to fixing https://bugs.php.net/bug.php?id=64705 (PHP 7.4.10),
|
||||
// in some cases (mainly connection errors) the PDO exception wouldn't provide a SQLSTATE via its code.
|
||||
// We have to match against the SQLSTATE in the error message in these cases.
|
||||
if ($exception->getCode() === 7 && strpos($exception->getMessage(), 'SQLSTATE[08006]') !== false) {
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
69
vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
vendored
Normal file
69
vendor/doctrine/dbal/src/Driver/API/SQLSrv/ExceptionConverter.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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
|
||||
{
|
||||
switch ($exception->getCode()) {
|
||||
case 102:
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
|
||||
case 207:
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
|
||||
case 208:
|
||||
return new TableNotFoundException($exception, $query);
|
||||
|
||||
case 209:
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
|
||||
case 515:
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
|
||||
case 547:
|
||||
case 4712:
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
|
||||
case 2601:
|
||||
case 2627:
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
|
||||
case 2714:
|
||||
return new TableExistsException($exception, $query);
|
||||
|
||||
case 3701:
|
||||
case 15151:
|
||||
return new DatabaseObjectNotFoundException($exception, $query);
|
||||
|
||||
case 11001:
|
||||
case 18456:
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
85
vendor/doctrine/dbal/src/Driver/API/SQLite/ExceptionConverter.php
vendored
Normal file
85
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 strpos;
|
||||
|
||||
/** @internal */
|
||||
final class ExceptionConverter implements ExceptionConverterInterface
|
||||
{
|
||||
/** @link http://www.sqlite.org/c3ref/c_abort.html */
|
||||
public function convert(Exception $exception, ?Query $query): DriverException
|
||||
{
|
||||
if (strpos($exception->getMessage(), 'database is locked') !== false) {
|
||||
return new LockWaitTimeoutException($exception, $query);
|
||||
}
|
||||
|
||||
if (
|
||||
strpos($exception->getMessage(), 'must be unique') !== false ||
|
||||
strpos($exception->getMessage(), 'is not unique') !== false ||
|
||||
strpos($exception->getMessage(), 'are not unique') !== false ||
|
||||
strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false
|
||||
) {
|
||||
return new UniqueConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
if (
|
||||
strpos($exception->getMessage(), 'may not be NULL') !== false ||
|
||||
strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false
|
||||
) {
|
||||
return new NotNullConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'no such table:') !== false) {
|
||||
return new TableNotFoundException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'already exists') !== false) {
|
||||
return new TableExistsException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'has no column named') !== false) {
|
||||
return new InvalidFieldNameException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'ambiguous column name') !== false) {
|
||||
return new NonUniqueFieldNameException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'syntax error') !== false) {
|
||||
return new SyntaxErrorException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'attempt to write a readonly database') !== false) {
|
||||
return new ReadOnlyException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'unable to open database file') !== false) {
|
||||
return new ConnectionException($exception, $query);
|
||||
}
|
||||
|
||||
if (strpos($exception->getMessage(), 'FOREIGN KEY constraint failed') !== false) {
|
||||
return new ForeignKeyConstraintViolationException($exception, $query);
|
||||
}
|
||||
|
||||
return new DriverException($exception, $query);
|
||||
}
|
||||
}
|
||||
80
vendor/doctrine/dbal/src/Driver/API/SQLite/UserDefinedFunctions.php
vendored
Normal file
80
vendor/doctrine/dbal/src/Driver/API/SQLite/UserDefinedFunctions.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\API\SQLite;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function array_merge;
|
||||
use function strpos;
|
||||
|
||||
/**
|
||||
* User-defined SQLite functions.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
final class UserDefinedFunctions
|
||||
{
|
||||
private const DEFAULT_FUNCTIONS = [
|
||||
'sqrt' => ['callback' => [SqlitePlatform::class, 'udfSqrt'], 'numArgs' => 1],
|
||||
'mod' => ['callback' => [SqlitePlatform::class, 'udfMod'], 'numArgs' => 2],
|
||||
'locate' => ['callback' => [SqlitePlatform::class, 'udfLocate'], 'numArgs' => -1],
|
||||
];
|
||||
|
||||
/**
|
||||
* @param callable(string, callable, int): bool $callback
|
||||
* @param array<string, array{callback: callable, numArgs: int}> $additionalFunctions
|
||||
*/
|
||||
public static function register(callable $callback, array $additionalFunctions = []): void
|
||||
{
|
||||
$userDefinedFunctions = array_merge(self::DEFAULT_FUNCTIONS, $additionalFunctions);
|
||||
|
||||
foreach ($userDefinedFunctions as $function => $data) {
|
||||
$callback($function, $data['callback'], $data['numArgs']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User-defined function that implements MOD().
|
||||
*
|
||||
* @param int $a
|
||||
* @param int $b
|
||||
*/
|
||||
public static function mod($a, $b): int
|
||||
{
|
||||
return $a % $b;
|
||||
}
|
||||
|
||||
/**
|
||||
* User-defined function that implements LOCATE().
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $substr
|
||||
* @param int $offset
|
||||
*/
|
||||
public static function locate($str, $substr, $offset = 0): int
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5749',
|
||||
'Relying on DBAL\'s emulated LOCATE() function is deprecated. '
|
||||
. 'Use INSTR() or %s::getLocateExpression() instead.',
|
||||
AbstractPlatform::class,
|
||||
);
|
||||
|
||||
// SQL's LOCATE function works on 1-based positions, while PHP's strpos works on 0-based positions.
|
||||
// So we have to make them compatible if an offset is given.
|
||||
if ($offset > 0) {
|
||||
$offset -= 1;
|
||||
}
|
||||
|
||||
$pos = strpos($str, $substr, $offset);
|
||||
|
||||
if ($pos !== false) {
|
||||
return $pos + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user