Upgrade framework
This commit is contained in:
85
vendor/ramsey/uuid/src/Builder/BuilderCollection.php
vendored
Normal file
85
vendor/ramsey/uuid/src/Builder/BuilderCollection.php
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Collection\AbstractCollection;
|
||||
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
use Ramsey\Uuid\Converter\Time\PhpTimeConverter;
|
||||
use Ramsey\Uuid\Guid\GuidBuilder;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Nonstandard\UuidBuilder as NonstandardUuidBuilder;
|
||||
use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* A collection of UuidBuilderInterface objects
|
||||
*
|
||||
* @deprecated this class has been deprecated, and will be removed in 5.0.0. The use-case for this class comes from
|
||||
* a pre-`phpstan/phpstan` and pre-`vimeo/psalm` ecosystem, in which type safety had to be mostly enforced
|
||||
* at runtime: that is no longer necessary, now that you can safely verify your code to be correct, and use
|
||||
* more generic types like `iterable<T>` instead.
|
||||
*
|
||||
* @extends AbstractCollection<UuidBuilderInterface>
|
||||
*/
|
||||
class BuilderCollection extends AbstractCollection
|
||||
{
|
||||
public function getType(): string
|
||||
{
|
||||
return UuidBuilderInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-mutation-free
|
||||
* @psalm-suppress ImpureMethodCall
|
||||
* @psalm-suppress InvalidTemplateParam
|
||||
*/
|
||||
public function getIterator(): Traversable
|
||||
{
|
||||
return parent::getIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-constructs the object from its serialized form
|
||||
*
|
||||
* @param string $serialized The serialized PHP string to unserialize into
|
||||
* a UuidInterface instance
|
||||
*
|
||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
|
||||
* @psalm-suppress RedundantConditionGivenDocblockType
|
||||
*/
|
||||
public function unserialize($serialized): void
|
||||
{
|
||||
/** @var array<array-key, UuidBuilderInterface> $data */
|
||||
$data = unserialize($serialized, [
|
||||
'allowed_classes' => [
|
||||
BrickMathCalculator::class,
|
||||
GenericNumberConverter::class,
|
||||
GenericTimeConverter::class,
|
||||
GuidBuilder::class,
|
||||
NonstandardUuidBuilder::class,
|
||||
PhpTimeConverter::class,
|
||||
Rfc4122UuidBuilder::class,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->data = array_filter(
|
||||
$data,
|
||||
function ($unserialized): bool {
|
||||
return $unserialized instanceof UuidBuilderInterface;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
@@ -7,48 +8,19 @@
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @link https://benramsey.com/projects/ramsey-uuid/ Documentation
|
||||
* @link https://packagist.org/packages/ramsey/uuid Packagist
|
||||
* @link https://github.com/ramsey/uuid GitHub
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder;
|
||||
|
||||
/**
|
||||
* DefaultUuidBuilder is the default UUID builder for ramsey/uuid; it builds
|
||||
* instances of Uuid objects
|
||||
* @deprecated Transition to {@see Rfc4122UuidBuilder}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DefaultUuidBuilder implements UuidBuilderInterface
|
||||
class DefaultUuidBuilder extends Rfc4122UuidBuilder
|
||||
{
|
||||
/**
|
||||
* @var NumberConverterInterface
|
||||
*/
|
||||
private $converter;
|
||||
|
||||
/**
|
||||
* Constructs the DefaultUuidBuilder
|
||||
*
|
||||
* @param NumberConverterInterface $converter The number converter to use when constructing the Uuid
|
||||
*/
|
||||
public function __construct(NumberConverterInterface $converter)
|
||||
{
|
||||
$this->converter = $converter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Uuid
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this Uuid
|
||||
* @param array $fields An array of fields from which to construct the Uuid;
|
||||
* see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
|
||||
* @return Uuid
|
||||
*/
|
||||
public function build(CodecInterface $codec, array $fields)
|
||||
{
|
||||
return new Uuid($fields, $this->converter, $codec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
@@ -7,47 +8,60 @@
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @link https://benramsey.com/projects/ramsey-uuid/ Documentation
|
||||
* @link https://packagist.org/packages/ramsey/uuid Packagist
|
||||
* @link https://github.com/ramsey/uuid GitHub
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\Time\DegradedTimeConverter;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\DegradedUuid;
|
||||
use Ramsey\Uuid\Rfc4122\Fields as Rfc4122Fields;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* DegradedUuidBuilder builds instances of DegradedUuid
|
||||
* @deprecated DegradedUuid instances are no longer necessary to support 32-bit
|
||||
* systems. Transition to {@see DefaultUuidBuilder}.
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class DegradedUuidBuilder implements UuidBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var NumberConverterInterface
|
||||
*/
|
||||
private $converter;
|
||||
private TimeConverterInterface $timeConverter;
|
||||
|
||||
/**
|
||||
* Constructs the DegradedUuidBuilder
|
||||
*
|
||||
* @param NumberConverterInterface $converter The number converter to use when constructing the DegradedUuid
|
||||
* @param NumberConverterInterface $numberConverter The number converter to
|
||||
* use when constructing the DegradedUuid
|
||||
* @param TimeConverterInterface|null $timeConverter The time converter to use
|
||||
* for converting timestamps extracted from a UUID to Unix timestamps
|
||||
*/
|
||||
public function __construct(NumberConverterInterface $converter)
|
||||
{
|
||||
$this->converter = $converter;
|
||||
public function __construct(
|
||||
private NumberConverterInterface $numberConverter,
|
||||
?TimeConverterInterface $timeConverter = null
|
||||
) {
|
||||
$this->timeConverter = $timeConverter ?: new DegradedTimeConverter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a DegradedUuid
|
||||
* Builds and returns a DegradedUuid
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this DegradedUuid
|
||||
* @param array $fields An array of fields from which to construct the DegradedUuid;
|
||||
* see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
|
||||
* @return DegradedUuid
|
||||
* @param CodecInterface $codec The codec to use for building this DegradedUuid instance
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, array $fields)
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
return new DegradedUuid($fields, $this->converter, $codec);
|
||||
return new DegradedUuid(
|
||||
new Rfc4122Fields($bytes),
|
||||
$this->numberConverter,
|
||||
$codec,
|
||||
$this->timeConverter
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
68
vendor/ramsey/uuid/src/Builder/FallbackBuilder.php
vendored
Normal file
68
vendor/ramsey/uuid/src/Builder/FallbackBuilder.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Exception\BuilderNotFoundException;
|
||||
use Ramsey\Uuid\Exception\UnableToBuildUuidException;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* FallbackBuilder builds a UUID by stepping through a list of UUID builders
|
||||
* until a UUID can be constructed without exceptions
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
class FallbackBuilder implements UuidBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @param iterable<UuidBuilderInterface> $builders An array of UUID builders
|
||||
*/
|
||||
public function __construct(private iterable $builders)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and returns a UuidInterface instance using the first builder that
|
||||
* succeeds
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this instance
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface an instance of a UUID object
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface
|
||||
{
|
||||
$lastBuilderException = null;
|
||||
|
||||
foreach ($this->builders as $builder) {
|
||||
try {
|
||||
return $builder->build($codec, $bytes);
|
||||
} catch (UnableToBuildUuidException $exception) {
|
||||
$lastBuilderException = $exception;
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
throw new BuilderNotFoundException(
|
||||
'Could not find a suitable builder for the provided codec and fields',
|
||||
0,
|
||||
$lastBuilderException
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the ramsey/uuid library
|
||||
*
|
||||
@@ -7,28 +8,32 @@
|
||||
*
|
||||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com>
|
||||
* @license http://opensource.org/licenses/MIT MIT
|
||||
* @link https://benramsey.com/projects/ramsey-uuid/ Documentation
|
||||
* @link https://packagist.org/packages/ramsey/uuid Packagist
|
||||
* @link https://github.com/ramsey/uuid GitHub
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Builder;
|
||||
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* UuidBuilderInterface builds instances UuidInterface
|
||||
* A UUID builder builds instances of UuidInterface
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
interface UuidBuilderInterface
|
||||
{
|
||||
/**
|
||||
* Builds an instance of a UuidInterface
|
||||
* Builds and returns a UuidInterface
|
||||
*
|
||||
* @param CodecInterface $codec The codec to use for building this UuidInterface instance
|
||||
* @param array $fields An array of fields from which to construct a UuidInterface instance;
|
||||
* see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
|
||||
* @return UuidInterface
|
||||
* @param string $bytes The byte string from which to construct a UUID
|
||||
*
|
||||
* @return UuidInterface Implementations may choose to return more specific
|
||||
* instances of UUIDs that implement UuidInterface
|
||||
*
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function build(CodecInterface $codec, array $fields);
|
||||
public function build(CodecInterface $codec, string $bytes): UuidInterface;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user