From 55097c47c5534d4453f7494f8a1542f7beb4d588 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 14 Mar 2024 10:13:22 +0000 Subject: Revert "composer update and use the fixed streams php-jcs library until the floats issue will be fixed upstream. see here for reference https://codeberg.org/streams/streams/issues/151" This reverts commit 6bf61dfa6b585db01b607a79bd64ec9c583a9c10. --- vendor/ramsey/collection/LICENSE | 2 +- vendor/ramsey/collection/README.md | 22 +- vendor/ramsey/collection/SECURITY.md | 70 +------ vendor/ramsey/collection/composer.json | 117 +++++------ vendor/ramsey/collection/conventional-commits.json | 22 -- vendor/ramsey/collection/src/AbstractArray.php | 60 +++++- .../ramsey/collection/src/AbstractCollection.php | 223 +++++++-------------- vendor/ramsey/collection/src/AbstractSet.php | 10 +- vendor/ramsey/collection/src/ArrayInterface.php | 4 +- vendor/ramsey/collection/src/Collection.php | 15 +- .../ramsey/collection/src/CollectionInterface.php | 112 +++-------- vendor/ramsey/collection/src/DoubleEndedQueue.php | 129 +++++++----- .../collection/src/DoubleEndedQueueInterface.php | 41 ++-- .../src/Exception/CollectionException.php | 21 -- .../src/Exception/CollectionMismatchException.php | 4 +- .../src/Exception/InvalidArgumentException.php | 4 +- .../src/Exception/InvalidPropertyOrMethod.php | 26 --- .../src/Exception/InvalidSortOrderException.php | 22 ++ .../src/Exception/NoSuchElementException.php | 4 +- .../src/Exception/OutOfBoundsException.php | 4 +- .../Exception/UnsupportedOperationException.php | 4 +- .../src/Exception/ValueExtractionException.php | 22 ++ vendor/ramsey/collection/src/Map/AbstractMap.php | 109 ++++------ .../ramsey/collection/src/Map/AbstractTypedMap.php | 23 ++- .../collection/src/Map/AssociativeArrayMap.php | 3 +- vendor/ramsey/collection/src/Map/MapInterface.php | 57 +++--- .../collection/src/Map/NamedParameterMap.php | 22 +- vendor/ramsey/collection/src/Map/TypedMap.php | 39 +++- .../collection/src/Map/TypedMapInterface.php | 3 +- vendor/ramsey/collection/src/Queue.php | 101 ++++++---- vendor/ramsey/collection/src/QueueInterface.php | 21 +- vendor/ramsey/collection/src/Set.php | 16 +- vendor/ramsey/collection/src/Sort.php | 31 --- vendor/ramsey/collection/src/Tool/TypeTrait.php | 48 +++-- .../collection/src/Tool/ValueExtractorTrait.php | 57 ++---- .../collection/src/Tool/ValueToStringTrait.php | 13 +- 36 files changed, 675 insertions(+), 806 deletions(-) delete mode 100644 vendor/ramsey/collection/conventional-commits.json delete mode 100644 vendor/ramsey/collection/src/Exception/CollectionException.php delete mode 100644 vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php create mode 100644 vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php create mode 100644 vendor/ramsey/collection/src/Exception/ValueExtractionException.php delete mode 100644 vendor/ramsey/collection/src/Sort.php (limited to 'vendor/ramsey') diff --git a/vendor/ramsey/collection/LICENSE b/vendor/ramsey/collection/LICENSE index a7fcf1201..ae15f590c 100644 --- a/vendor/ramsey/collection/LICENSE +++ b/vendor/ramsey/collection/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2015-2022 Ben Ramsey +Copyright (c) 2015-2021 Ben Ramsey Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/vendor/ramsey/collection/README.md b/vendor/ramsey/collection/README.md index c77ffcb18..9124dd77e 100644 --- a/vendor/ramsey/collection/README.md +++ b/vendor/ramsey/collection/README.md @@ -9,7 +9,7 @@ Download Package PHP Programming Language Read License - Build Status + Build Status Codecov Code Coverage Psalm Type Coverage

@@ -34,13 +34,25 @@ composer require ramsey/collection ## Usage -Examples of how to use this library may be found in the +Examples of how to use this framework can be found in the [Wiki pages](https://github.com/ramsey/collection/wiki/Examples). ## Contributing -Contributions are welcome! To contribute, please familiarize yourself with -[CONTRIBUTING.md](CONTRIBUTING.md). +Contributions are welcome! Before contributing to this project, familiarize +yourself with [CONTRIBUTING.md](CONTRIBUTING.md). + +To develop this project, you will need [PHP](https://www.php.net) 7.3 or greater +and [Composer](https://getcomposer.org). + +After cloning this repository locally, execute the following commands: + +``` bash +cd /path/to/repository +composer install +``` + +Now, you are ready to develop! ## Coordinated Disclosure @@ -67,4 +79,4 @@ MIT License (MIT). Please see [LICENSE](LICENSE) for more information. [java]: http://docs.oracle.com/javase/8/docs/technotes/guides/collections/index.html -[security.md]: https://github.com/ramsey/collection/blob/main/SECURITY.md +[security.md]: https://github.com/ramsey/collection/blob/master/SECURITY.md diff --git a/vendor/ramsey/collection/SECURITY.md b/vendor/ramsey/collection/SECURITY.md index 3de4c0cbd..b052f3b65 100644 --- a/vendor/ramsey/collection/SECURITY.md +++ b/vendor/ramsey/collection/SECURITY.md @@ -1,59 +1,29 @@ -# Vulnerability Disclosure Policy (VDP) - -## Brand Promise - - +# Vulnerability Disclosure Policy Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. ## Scope - - If you believe you've found a security issue in software that is maintained in this repository, we encourage you to notify us. | Version | In scope | Source code | -| ------- | :------: | ----------- | +| :-----: | :------: | :---------- | | latest | ✅ | https://github.com/ramsey/collection | ## How to Submit a Report - - -To submit a vulnerability report, please contact us at security@ramsey.dev. +To submit a vulnerability report, please contact us at . Your submission will be reviewed and validated by a member of our team. ## Safe Harbor - - We support safe harbor for security researchers who: * Make a good faith effort to avoid privacy violations, destruction of data, and @@ -63,7 +33,7 @@ We support safe harbor for security researchers who: us immediately, do not proceed with access, and immediately purge any local information. * Provide us with a reasonable amount of time to resolve vulnerabilities prior - to any disclosure to the public or a third party. + to any disclosure to the public or a third-party. We will consider activities conducted consistent with this policy to constitute "authorized" conduct and will not pursue civil action or initiate a complaint to @@ -75,41 +45,15 @@ with or unaddressed by this policy. ## Preferences - - * Please provide detailed reports with reproducible steps and a clearly defined impact. * Include the version number of the vulnerable package in your report * Social engineering (e.g. phishing, vishing, smishing) is prohibited. - - ## Encryption Key for security@ramsey.dev For increased privacy when reporting sensitive issues, you may encrypt your -message using the following public key: +messages using the following key: ``` -----BEGIN PGP PUBLIC KEY BLOCK----- diff --git a/vendor/ramsey/collection/composer.json b/vendor/ramsey/collection/composer.json index 56709015a..98862ee46 100644 --- a/vendor/ramsey/collection/composer.json +++ b/vendor/ramsey/collection/composer.json @@ -1,8 +1,7 @@ { "name": "ramsey/collection", - "description": "A PHP library for representing and manipulating collections.", - "license": "MIT", "type": "library", + "description": "A PHP library for representing and manipulating collections.", "keywords": [ "array", "collection", @@ -11,6 +10,7 @@ "queue", "set" ], + "license": "MIT", "authors": [ { "name": "Ben Ramsey", @@ -19,32 +19,31 @@ } ], "require": { - "php": "^8.1" + "php": "^7.3 || ^8", + "symfony/polyfill-php81": "^1.23" }, "require-dev": { - "captainhook/plugin-composer": "^5.3", - "ergebnis/composer-normalize": "^2.28.3", - "fakerphp/faker": "^1.21", - "hamcrest/hamcrest-php": "^2.0", - "jangregor/phpstan-prophecy": "^1.0", - "mockery/mockery": "^1.5", - "php-parallel-lint/php-console-highlighter": "^1.0", - "php-parallel-lint/php-parallel-lint": "^1.3", - "phpcsstandards/phpcsutils": "^1.0.0-rc1", + "captainhook/captainhook": "^5.3", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "ergebnis/composer-normalize": "^2.6", + "fakerphp/faker": "^1.5", + "hamcrest/hamcrest-php": "^2", + "jangregor/phpstan-prophecy": "^0.8", + "mockery/mockery": "^1.3", "phpspec/prophecy-phpunit": "^2.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan": "^1.9", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.5", - "psalm/plugin-mockery": "^1.1", - "psalm/plugin-phpunit": "^0.18.4", - "ramsey/coding-standard": "^2.0.3", - "ramsey/conventional-commits": "^1.3", - "vimeo/psalm": "^5.4" + "phpstan/extension-installer": "^1", + "phpstan/phpstan": "^0.12.32", + "phpstan/phpstan-mockery": "^0.12.5", + "phpstan/phpstan-phpunit": "^0.12.11", + "phpunit/phpunit": "^8.5 || ^9", + "psy/psysh": "^0.10.4", + "slevomat/coding-standard": "^6.3", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.4" + }, + "config": { + "sort-packages": true }, - "minimum-stability": "RC", - "prefer-stable": true, "autoload": { "psr-4": { "Ramsey\\Collection\\": "src/" @@ -52,6 +51,7 @@ }, "autoload-dev": { "psr-4": { + "Ramsey\\Console\\": "resources/console/", "Ramsey\\Collection\\Test\\": "tests/", "Ramsey\\Test\\Generics\\": "tests/generics/" }, @@ -59,61 +59,44 @@ "vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php" ] }, - "config": { - "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, - "ergebnis/composer-normalize": true, - "phpstan/extension-installer": true, - "captainhook/plugin-composer": true - }, - "sort-packages": true - }, - "extra": { - "captainhook": { - "force-install": true - }, - "ramsey/conventional-commits": { - "configFile": "conventional-commits.json" - } - }, "scripts": { + "post-autoload-dump": "captainhook install --ansi -f -s", "dev:analyze": [ "@dev:analyze:phpstan", "@dev:analyze:psalm" ], - "dev:analyze:phpstan": "phpstan analyse --ansi --memory-limit=1G", - "dev:analyze:psalm": "psalm", - "dev:build:clean": "git clean -fX build/", - "dev:lint": [ - "@dev:lint:syntax", - "@dev:lint:style" + "dev:analyze:phpstan": "phpstan --memory-limit=1G analyse", + "dev:analyze:psalm": "psalm --diff --config=psalm.xml", + "dev:build:clean": "git clean -fX build/.", + "dev:build:clear-cache": "git clean -fX build/cache/.", + "dev:lint": "phpcs --cache=build/cache/phpcs.cache", + "dev:lint:fix": "./bin/lint-fix.sh", + "dev:repl": [ + "echo ; echo 'Type ./bin/repl to start the REPL.'" ], - "dev:lint:fix": "phpcbf", - "dev:lint:style": "phpcs --colors", - "dev:lint:syntax": "parallel-lint --colors src/ tests/", - "dev:test": [ + "dev:test": "phpunit", + "dev:test:all": [ "@dev:lint", "@dev:analyze", - "@dev:test:unit" + "@dev:test" ], - "dev:test:coverage:ci": "phpunit --colors=always --coverage-text --coverage-clover build/coverage/clover.xml --coverage-cobertura build/coverage/cobertura.xml --coverage-crap4j build/coverage/crap4j.xml --coverage-xml build/coverage/coverage-xml --log-junit build/junit.xml", - "dev:test:coverage:html": "phpunit --colors=always --coverage-html build/coverage/coverage-html/", - "dev:test:unit": "phpunit --colors=always", - "test": "@dev:test" + "dev:test:coverage:ci": "phpunit --coverage-clover build/logs/clover.xml", + "dev:test:coverage:html": "phpunit --coverage-html build/coverage", + "test": "@dev:test:all" }, "scripts-descriptions": { - "dev:analyze": "Runs all static analysis checks.", + "dev:analyze": "Performs static analysis on the code base.", "dev:analyze:phpstan": "Runs the PHPStan static analyzer.", "dev:analyze:psalm": "Runs the Psalm static analyzer.", - "dev:build:clean": "Cleans the build/ directory.", - "dev:lint": "Runs all linting checks.", - "dev:lint:fix": "Auto-fixes coding standards issues, if possible.", - "dev:lint:style": "Checks for coding standards issues.", - "dev:lint:syntax": "Checks for syntax errors.", - "dev:test": "Runs linting, static analysis, and unit tests.", - "dev:test:coverage:ci": "Runs unit tests and generates CI coverage reports.", - "dev:test:coverage:html": "Runs unit tests and generates HTML coverage report.", - "dev:test:unit": "Runs unit tests.", - "test": "Runs linting, static analysis, and unit tests." + "dev:build:clean": "Removes everything not under version control from the build directory.", + "dev:build:clear-cache": "Removes everything not under version control from build/cache/.", + "dev:lint": "Checks all source code for coding standards issues.", + "dev:lint:fix": "Checks source code for coding standards issues and fixes them, if possible.", + "dev:repl": "Note: Use ./bin/repl to run the REPL.", + "dev:test": "Runs the full unit test suite.", + "dev:test:all": "Runs linting, static analysis, and unit tests.", + "dev:test:coverage:ci": "Runs the unit test suite and generates a Clover coverage report.", + "dev:test:coverage:html": "Runs the unit tests suite and generates an HTML coverage report.", + "test": "Shortcut to run the full test suite." } } diff --git a/vendor/ramsey/collection/conventional-commits.json b/vendor/ramsey/collection/conventional-commits.json deleted file mode 100644 index 5fe21d2fa..000000000 --- a/vendor/ramsey/collection/conventional-commits.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "typeCase": "kebab", - "types": [ - "chore", - "ci", - "docs", - "feat", - "fix", - "refactor", - "security", - "style", - "test" - ], - "scopeCase": "kebab", - "scopeRequired": false, - "scopes": [], - "descriptionCase": null, - "descriptionEndMark": "", - "bodyRequired": false, - "bodyWrapWidth": 72, - "requiredFooters": [] -} diff --git a/vendor/ramsey/collection/src/AbstractArray.php b/vendor/ramsey/collection/src/AbstractArray.php index 5ce622aa7..d72dbe697 100644 --- a/vendor/ramsey/collection/src/AbstractArray.php +++ b/vendor/ramsey/collection/src/AbstractArray.php @@ -17,7 +17,8 @@ namespace Ramsey\Collection; use ArrayIterator; use Traversable; -use function count; +use function serialize; +use function unserialize; /** * This class provides a basic implementation of `ArrayInterface`, to minimize @@ -33,7 +34,7 @@ abstract class AbstractArray implements ArrayInterface * * @var array */ - protected array $data = []; + protected $data = []; /** * Constructs a new array object. @@ -68,7 +69,7 @@ abstract class AbstractArray implements ArrayInterface * * @param array-key $offset The offset to check. */ - public function offsetExists(mixed $offset): bool + public function offsetExists($offset): bool { return isset($this->data[$offset]); } @@ -80,12 +81,15 @@ abstract class AbstractArray implements ArrayInterface * * @param array-key $offset The offset for which a value should be returned. * - * @return T the value stored at the offset, or null if the offset + * @return T|null the value stored at the offset, or null if the offset * does not exist. + * + * @psalm-suppress InvalidAttribute */ - public function offsetGet(mixed $offset): mixed + #[\ReturnTypeWillChange] // phpcs:ignore + public function offsetGet($offset) { - return $this->data[$offset]; + return $this->data[$offset] ?? null; } /** @@ -93,11 +97,12 @@ abstract class AbstractArray implements ArrayInterface * * @link http://php.net/manual/en/arrayaccess.offsetset.php ArrayAccess::offsetSet() * - * @param array-key | null $offset The offset to set. If `null`, the value - * may be set at a numerically-indexed offset. + * @param array-key|null $offset The offset to set. If `null`, the value may be + * set at a numerically-indexed offset. * @param T $value The value to set at the given offset. */ - public function offsetSet(mixed $offset, mixed $value): void + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function offsetSet($offset, $value): void { if ($offset === null) { $this->data[] = $value; @@ -113,11 +118,25 @@ abstract class AbstractArray implements ArrayInterface * * @param array-key $offset The offset to remove from the array. */ - public function offsetUnset(mixed $offset): void + public function offsetUnset($offset): void { unset($this->data[$offset]); } + /** + * Returns a serialized string representation of this array object. + * + * @deprecated The Serializable interface will go away in PHP 9. + * + * @link http://php.net/manual/en/serializable.serialize.php Serializable::serialize() + * + * @return string a PHP serialized string. + */ + public function serialize(): string + { + return serialize($this->data); + } + /** * Returns data suitable for PHP serialization. * @@ -131,6 +150,25 @@ abstract class AbstractArray implements ArrayInterface return $this->data; } + /** + * Converts a serialized string representation into an instance object. + * + * @deprecated The Serializable interface will go away in PHP 9. + * + * @link http://php.net/manual/en/serializable.unserialize.php Serializable::unserialize() + * + * @param string $serialized A PHP serialized string to unserialize. + * + * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + */ + public function unserialize($serialized): void + { + /** @var array $data */ + $data = unserialize($serialized, ['allowed_classes' => false]); + + $this->data = $data; + } + /** * Adds unserialized data to the object. * @@ -166,6 +204,6 @@ abstract class AbstractArray implements ArrayInterface public function isEmpty(): bool { - return $this->data === []; + return count($this->data) === 0; } } diff --git a/vendor/ramsey/collection/src/AbstractCollection.php b/vendor/ramsey/collection/src/AbstractCollection.php index 8cb21ec02..d2cd1151c 100644 --- a/vendor/ramsey/collection/src/AbstractCollection.php +++ b/vendor/ramsey/collection/src/AbstractCollection.php @@ -17,27 +17,25 @@ namespace Ramsey\Collection; use Closure; use Ramsey\Collection\Exception\CollectionMismatchException; use Ramsey\Collection\Exception\InvalidArgumentException; -use Ramsey\Collection\Exception\InvalidPropertyOrMethod; -use Ramsey\Collection\Exception\NoSuchElementException; -use Ramsey\Collection\Exception\UnsupportedOperationException; +use Ramsey\Collection\Exception\InvalidSortOrderException; +use Ramsey\Collection\Exception\OutOfBoundsException; use Ramsey\Collection\Tool\TypeTrait; use Ramsey\Collection\Tool\ValueExtractorTrait; use Ramsey\Collection\Tool\ValueToStringTrait; use function array_filter; -use function array_key_first; -use function array_key_last; use function array_map; use function array_merge; -use function array_reduce; use function array_search; use function array_udiff; use function array_uintersect; +use function current; +use function end; use function in_array; use function is_int; -use function is_object; -use function spl_object_id; +use function reset; use function sprintf; +use function unserialize; use function usort; /** @@ -55,29 +53,32 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt use ValueExtractorTrait; /** - * @throws InvalidArgumentException if $element is of the wrong type. + * @inheritDoc */ - public function add(mixed $element): bool + public function add($element): bool { $this[] = $element; return true; } - public function contains(mixed $element, bool $strict = true): bool + /** + * @inheritDoc + */ + public function contains($element, bool $strict = true): bool { return in_array($element, $this->data, $strict); } /** - * @throws InvalidArgumentException if $element is of the wrong type. + * @inheritDoc */ - public function offsetSet(mixed $offset, mixed $value): void + public function offsetSet($offset, $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' - . $this->toolValueToString($value), + . $this->toolValueToString($value) ); } @@ -88,10 +89,13 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt } } - public function remove(mixed $element): bool + /** + * @inheritDoc + */ + public function remove($element): bool { if (($position = array_search($element, $this->data, true)) !== false) { - unset($this[$position]); + unset($this->data[$position]); return true; } @@ -100,11 +104,6 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt } /** - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call column() on this - * collection. - * * @inheritDoc */ public function column(string $propertyOrMethod): array @@ -112,55 +111,55 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt $temp = []; foreach ($this->data as $item) { + /** @var mixed $value */ + $value = $this->extractValue($item, $propertyOrMethod); + /** @psalm-suppress MixedAssignment */ - $temp[] = $this->extractValue($item, $propertyOrMethod); + $temp[] = $value; } return $temp; } /** - * @return T - * - * @throws NoSuchElementException if this collection is empty. + * @inheritDoc */ - public function first(): mixed + public function first() { - $firstIndex = array_key_first($this->data); - - if ($firstIndex === null) { - throw new NoSuchElementException('Can\'t determine first item. Collection is empty'); + if ($this->isEmpty()) { + throw new OutOfBoundsException('Can\'t determine first item. Collection is empty'); } - return $this->data[$firstIndex]; + reset($this->data); + + /** @var T $first */ + $first = current($this->data); + + return $first; } /** - * @return T - * - * @throws NoSuchElementException if this collection is empty. + * @inheritDoc */ - public function last(): mixed + public function last() { - $lastIndex = array_key_last($this->data); - - if ($lastIndex === null) { - throw new NoSuchElementException('Can\'t determine last item. Collection is empty'); + if ($this->isEmpty()) { + throw new OutOfBoundsException('Can\'t determine last item. Collection is empty'); } - return $this->data[$lastIndex]; + /** @var T $item */ + $item = end($this->data); + reset($this->data); + + return $item; } - /** - * @return CollectionInterface - * - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call sort() on this - * collection. - */ - public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending): CollectionInterface + public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): CollectionInterface { + if (!in_array($order, [self::SORT_ASC, self::SORT_DESC], true)) { + throw new InvalidSortOrderException('Invalid sort order given: ' . $order); + } + $collection = clone $this; usort( @@ -169,25 +168,20 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt * @param T $a * @param T $b */ - function (mixed $a, mixed $b) use ($propertyOrMethod, $order): int { + function ($a, $b) use ($propertyOrMethod, $order): int { /** @var mixed $aValue */ $aValue = $this->extractValue($a, $propertyOrMethod); /** @var mixed $bValue */ $bValue = $this->extractValue($b, $propertyOrMethod); - return ($aValue <=> $bValue) * ($order === Sort::Descending ? -1 : 1); - }, + return ($aValue <=> $bValue) * ($order === self::SORT_DESC ? -1 : 1); + } ); return $collection; } - /** - * @param callable(T): bool $callback A callable to use for filtering elements. - * - * @return CollectionInterface - */ public function filter(callable $callback): CollectionInterface { $collection = clone $this; @@ -197,66 +191,23 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt } /** - * @return CollectionInterface - * - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call where() on this - * collection. + * {@inheritdoc} */ - public function where(?string $propertyOrMethod, mixed $value): CollectionInterface + public function where(string $propertyOrMethod, $value): CollectionInterface { - return $this->filter( - /** - * @param T $item - */ - function (mixed $item) use ($propertyOrMethod, $value): bool { - /** @var mixed $accessorValue */ - $accessorValue = $this->extractValue($item, $propertyOrMethod); + return $this->filter(function ($item) use ($propertyOrMethod, $value) { + /** @var mixed $accessorValue */ + $accessorValue = $this->extractValue($item, $propertyOrMethod); - return $accessorValue === $value; - }, - ); + return $accessorValue === $value; + }); } - /** - * @param callable(T): TCallbackReturn $callback A callable to apply to each - * item of the collection. - * - * @return CollectionInterface - * - * @template TCallbackReturn - */ public function map(callable $callback): CollectionInterface { - /** @var Collection */ return new Collection('mixed', array_map($callback, $this->data)); } - /** - * @param callable(TCarry, T): TCarry $callback A callable to apply to each - * item of the collection to reduce it to a single value. - * @param TCarry $initial This is the initial value provided to the callback. - * - * @return TCarry - * - * @template TCarry - */ - public function reduce(callable $callback, mixed $initial): mixed - { - /** @var TCarry */ - return array_reduce($this->data, $callback, $initial); - } - - /** - * @param CollectionInterface $other The collection to check for divergent - * items. - * - * @return CollectionInterface - * - * @throws CollectionMismatchException if the compared collections are of - * differing types. - */ public function diff(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); @@ -273,15 +224,6 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt return $collection; } - /** - * @param CollectionInterface $other The collection to check for - * intersecting items. - * - * @return CollectionInterface - * - * @throws CollectionMismatchException if the compared collections are of - * differing types. - */ public function intersect(CollectionInterface $other): CollectionInterface { $this->compareCollectionTypes($other); @@ -295,15 +237,6 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt return $collection; } - /** - * @param CollectionInterface ...$collections The collections to merge. - * - * @return CollectionInterface - * - * @throws CollectionMismatchException if unable to merge any of the given - * collections or items within the given collections due to type - * mismatch errors. - */ public function merge(CollectionInterface ...$collections): CollectionInterface { $mergedCollection = clone $this; @@ -311,19 +244,15 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt foreach ($collections as $index => $collection) { if (!$collection instanceof static) { throw new CollectionMismatchException( - sprintf('Collection with index %d must be of type %s', $index, static::class), + sprintf('Collection with index %d must be of type %s', $index, static::class) ); } // When using generics (Collection.php, Set.php, etc), // we also need to make sure that the internal types match each other - if ($this->getUniformType($collection) !== $this->getUniformType($this)) { + if ($collection->getType() !== $this->getType()) { throw new CollectionMismatchException( - sprintf( - 'Collection items in collection with index %d must be of type %s', - $index, - $this->getType(), - ), + sprintf('Collection items in collection with index %d must be of type %s', $index, $this->getType()) ); } @@ -339,10 +268,19 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt return $mergedCollection; } + /** + * @inheritDoc + */ + public function unserialize($serialized): void + { + /** @var array $data */ + $data = unserialize($serialized, ['allowed_classes' => [$this->getType()]]); + + $this->data = $data; + } + /** * @param CollectionInterface $other - * - * @throws CollectionMismatchException */ private function compareCollectionTypes(CollectionInterface $other): void { @@ -352,7 +290,7 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt // When using generics (Collection.php, Set.php, etc), // we also need to make sure that the internal types match each other - if ($this->getUniformType($other) !== $this->getUniformType($this)) { + if ($other->getType() !== $this->getType()) { throw new CollectionMismatchException('Collection items must be of type ' . $this->getType()); } } @@ -363,7 +301,7 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt * @param T $a * @param T $b */ - function (mixed $a, mixed $b): int { + function ($a, $b): int { // If the two values are object, we convert them to unique scalars. // If the collection contains mixed values (unlikely) where some are objects // and some are not, we leave them as they are. @@ -377,17 +315,4 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt return $a === $b ? 0 : ($a < $b ? 1 : -1); }; } - - /** - * @param CollectionInterface $collection - */ - private function getUniformType(CollectionInterface $collection): string - { - return match ($collection->getType()) { - 'integer' => 'int', - 'boolean' => 'bool', - 'double' => 'float', - default => $collection->getType(), - }; - } } diff --git a/vendor/ramsey/collection/src/AbstractSet.php b/vendor/ramsey/collection/src/AbstractSet.php index 7186939d7..1126ccb0a 100644 --- a/vendor/ramsey/collection/src/AbstractSet.php +++ b/vendor/ramsey/collection/src/AbstractSet.php @@ -24,7 +24,10 @@ namespace Ramsey\Collection; */ abstract class AbstractSet extends AbstractCollection { - public function add(mixed $element): bool + /** + * @inheritDoc + */ + public function add($element): bool { if ($this->contains($element)) { return false; @@ -33,7 +36,10 @@ abstract class AbstractSet extends AbstractCollection return parent::add($element); } - public function offsetSet(mixed $offset, mixed $value): void + /** + * @inheritDoc + */ + public function offsetSet($offset, $value): void { if ($this->contains($value)) { return; diff --git a/vendor/ramsey/collection/src/ArrayInterface.php b/vendor/ramsey/collection/src/ArrayInterface.php index bc7f6f424..27af6102b 100644 --- a/vendor/ramsey/collection/src/ArrayInterface.php +++ b/vendor/ramsey/collection/src/ArrayInterface.php @@ -17,6 +17,7 @@ namespace Ramsey\Collection; use ArrayAccess; use Countable; use IteratorAggregate; +use Serializable; /** * `ArrayInterface` provides traversable array functionality to data types. @@ -28,7 +29,8 @@ use IteratorAggregate; interface ArrayInterface extends ArrayAccess, Countable, - IteratorAggregate + IteratorAggregate, + Serializable { /** * Removes all items from this array. diff --git a/vendor/ramsey/collection/src/Collection.php b/vendor/ramsey/collection/src/Collection.php index 44d26bf2e..1299c12c2 100644 --- a/vendor/ramsey/collection/src/Collection.php +++ b/vendor/ramsey/collection/src/Collection.php @@ -75,16 +75,27 @@ namespace Ramsey\Collection; */ class Collection extends AbstractCollection { + /** + * The type of elements stored in this collection. + * + * A collection's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string + */ + private $collectionType; + /** * Constructs a collection object of the specified type, optionally with the * specified data. * - * @param string $collectionType The type or class name associated with this + * @param string $collectionType The type (FQCN) associated with this * collection. * @param array $data The initial items to store in the collection. */ - public function __construct(private readonly string $collectionType, array $data = []) + public function __construct(string $collectionType, array $data = []) { + $this->collectionType = $collectionType; parent::__construct($data); } diff --git a/vendor/ramsey/collection/src/CollectionInterface.php b/vendor/ramsey/collection/src/CollectionInterface.php index e3ad01470..aa86feb04 100644 --- a/vendor/ramsey/collection/src/CollectionInterface.php +++ b/vendor/ramsey/collection/src/CollectionInterface.php @@ -14,14 +14,8 @@ declare(strict_types=1); namespace Ramsey\Collection; -use Ramsey\Collection\Exception\CollectionMismatchException; -use Ramsey\Collection\Exception\InvalidArgumentException; -use Ramsey\Collection\Exception\InvalidPropertyOrMethod; -use Ramsey\Collection\Exception\NoSuchElementException; -use Ramsey\Collection\Exception\UnsupportedOperationException; - /** - * A collection represents a group of values, known as its elements. + * A collection represents a group of objects, known as its elements. * * Some collections allow duplicate elements and others do not. Some are ordered * and others unordered. @@ -31,6 +25,16 @@ use Ramsey\Collection\Exception\UnsupportedOperationException; */ interface CollectionInterface extends ArrayInterface { + /** + * Ascending sort type. + */ + public const SORT_ASC = 'asc'; + + /** + * Descending sort type. + */ + public const SORT_DESC = 'desc'; + /** * Ensures that this collection contains the specified element (optional * operation). @@ -54,11 +58,9 @@ interface CollectionInterface extends ArrayInterface * @param T $element The element to add to the collection. * * @return bool `true` if this collection changed as a result of the call. - * - * @throws InvalidArgumentException if the collection refuses to add the - * $element for any reason other than that it already contains the element. */ - public function add(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function add($element): bool; /** * Returns `true` if this collection contains the specified element. @@ -66,7 +68,8 @@ interface CollectionInterface extends ArrayInterface * @param T $element The element to check whether the collection contains. * @param bool $strict Whether to perform a strict type check on the value. */ - public function contains(mixed $element, bool $strict = true): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function contains($element, bool $strict = true): bool; /** * Returns the type associated with this collection. @@ -81,20 +84,15 @@ interface CollectionInterface extends ArrayInterface * * @return bool `true` if an element was removed as a result of this call. */ - public function remove(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function remove($element): bool; /** - * Returns the values from the given property, method, or array key. - * - * @param string $propertyOrMethod The name of the property, method, or - * array key to evaluate and return. + * Returns the values from the given property or method. * - * @return array + * @param string $propertyOrMethod The property or method name to filter by. * - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call column() on this - * collection. + * @return list */ public function column(string $propertyOrMethod): array; @@ -102,41 +100,29 @@ interface CollectionInterface extends ArrayInterface * Returns the first item of the collection. * * @return T - * - * @throws NoSuchElementException if this collection is empty. */ - public function first(): mixed; + public function first(); /** * Returns the last item of the collection. * * @return T - * - * @throws NoSuchElementException if this collection is empty. */ - public function last(): mixed; + public function last(); /** - * Sort the collection by a property, method, or array key with the given - * sort order. - * - * If $propertyOrMethod is `null`, this will sort by comparing each element. + * Sort the collection by a property or method with the given sort order. * * This will always leave the original collection untouched and will return * a new one. * - * @param string | null $propertyOrMethod The property, method, or array key - * to sort by. - * @param Sort $order The sort order for the resulting collection. + * @param string $propertyOrMethod The property or method to sort by. + * @param string $order The sort order for the resulting collection (one of + * this interface's `SORT_*` constants). * * @return CollectionInterface - * - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call sort() on this - * collection. */ - public function sort(?string $propertyOrMethod = null, Sort $order = Sort::Ascending): self; + public function sort(string $propertyOrMethod, string $order = self::SORT_ASC): self; /** * Filter out items of the collection which don't match the criteria of @@ -148,31 +134,24 @@ interface CollectionInterface extends ArrayInterface * See the {@link http://php.net/manual/en/function.array-filter.php PHP array_filter() documentation} * for examples of how the `$callback` parameter works. * - * @param callable(T): bool $callback A callable to use for filtering elements. + * @param callable(T):bool $callback A callable to use for filtering elements. * * @return CollectionInterface */ public function filter(callable $callback): self; /** - * Create a new collection where the result of the given property, method, - * or array key of each item in the collection equals the given value. + * Create a new collection where items match the criteria of given callback. * * This will always leave the original collection untouched and will return * a new one. * - * @param string | null $propertyOrMethod The property, method, or array key - * to evaluate. If `null`, the element itself is compared to $value. + * @param string $propertyOrMethod The property or method to evaluate. * @param mixed $value The value to match. * * @return CollectionInterface - * - * @throws InvalidPropertyOrMethod if the $propertyOrMethod does not exist - * on the elements in this collection. - * @throws UnsupportedOperationException if unable to call where() on this - * collection. */ - public function where(?string $propertyOrMethod, mixed $value): self; + public function where(string $propertyOrMethod, $value): self; /** * Apply a given callback method on each item of the collection. @@ -184,7 +163,7 @@ interface CollectionInterface extends ArrayInterface * See the {@link http://php.net/manual/en/function.array-map.php PHP array_map() documentation} * for examples of how the `$callback` parameter works. * - * @param callable(T): TCallbackReturn $callback A callable to apply to each + * @param callable(T):TCallbackReturn $callback A callable to apply to each * item of the collection. * * @return CollectionInterface @@ -193,23 +172,6 @@ interface CollectionInterface extends ArrayInterface */ public function map(callable $callback): self; - /** - * Apply a given callback method on each item of the collection - * to reduce it to a single value. - * - * See the {@link http://php.net/manual/en/function.array-reduce.php PHP array_reduce() documentation} - * for examples of how the `$callback` and `$initial` parameters work. - * - * @param callable(TCarry, T): TCarry $callback A callable to apply to each - * item of the collection to reduce it to a single value. - * @param TCarry $initial This is the initial value provided to the callback. - * - * @return TCarry - * - * @template TCarry - */ - public function reduce(callable $callback, mixed $initial): mixed; - /** * Create a new collection with divergent items between current and given * collection. @@ -218,9 +180,6 @@ interface CollectionInterface extends ArrayInterface * items. * * @return CollectionInterface - * - * @throws CollectionMismatchException if the compared collections are of - * differing types. */ public function diff(CollectionInterface $other): self; @@ -232,9 +191,6 @@ interface CollectionInterface extends ArrayInterface * intersecting items. * * @return CollectionInterface - * - * @throws CollectionMismatchException if the compared collections are of - * differing types. */ public function intersect(CollectionInterface $other): self; @@ -244,10 +200,6 @@ interface CollectionInterface extends ArrayInterface * @param CollectionInterface ...$collections The collections to merge. * * @return CollectionInterface - * - * @throws CollectionMismatchException if unable to merge any of the given - * collections or items within the given collections due to type - * mismatch errors. */ public function merge(CollectionInterface ...$collections): self; } diff --git a/vendor/ramsey/collection/src/DoubleEndedQueue.php b/vendor/ramsey/collection/src/DoubleEndedQueue.php index 62947a24f..c9c59502d 100644 --- a/vendor/ramsey/collection/src/DoubleEndedQueue.php +++ b/vendor/ramsey/collection/src/DoubleEndedQueue.php @@ -17,10 +17,6 @@ namespace Ramsey\Collection; use Ramsey\Collection\Exception\InvalidArgumentException; use Ramsey\Collection\Exception\NoSuchElementException; -use function array_key_last; -use function array_pop; -use function array_unshift; - /** * This class provides a basic implementation of `DoubleEndedQueueInterface`, to * minimize the effort required to implement this interface. @@ -32,135 +28,160 @@ use function array_unshift; class DoubleEndedQueue extends Queue implements DoubleEndedQueueInterface { /** - * Constructs a double-ended queue (dequeue) object of the specified type, - * optionally with the specified data. + * Index of the last element in the queue. * - * @param string $queueType The type or class name associated with this dequeue. - * @param array $data The initial items to store in the dequeue. + * @var int + */ + private $tail = -1; + + /** + * @inheritDoc */ - public function __construct(private readonly string $queueType, array $data = []) + public function offsetSet($offset, $value): void { - parent::__construct($this->queueType, $data); + if ($this->checkType($this->getType(), $value) === false) { + throw new InvalidArgumentException( + 'Value must be of type ' . $this->getType() . '; value is ' + . $this->toolValueToString($value) + ); + } + + $this->tail++; + + $this->data[$this->tail] = $value; } /** - * @throws InvalidArgumentException if $element is of the wrong type + * @inheritDoc */ - public function addFirst(mixed $element): bool + public function addFirst($element): bool { if ($this->checkType($this->getType(), $element) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' - . $this->toolValueToString($element), + . $this->toolValueToString($element) ); } - array_unshift($this->data, $element); + $this->index--; + + $this->data[$this->index] = $element; return true; } /** - * @throws InvalidArgumentException if $element is of the wrong type + * @inheritDoc */ - public function addLast(mixed $element): bool + public function addLast($element): bool { return $this->add($element); } - public function offerFirst(mixed $element): bool + /** + * @inheritDoc + */ + public function offerFirst($element): bool { try { return $this->addFirst($element); - } catch (InvalidArgumentException) { + } catch (InvalidArgumentException $e) { return false; } } - public function offerLast(mixed $element): bool + /** + * @inheritDoc + */ + public function offerLast($element): bool { return $this->offer($element); } /** - * @return T the first element in this queue. - * - * @throws NoSuchElementException if the queue is empty + * @inheritDoc */ - public function removeFirst(): mixed + public function removeFirst() { return $this->remove(); } /** - * @return T the last element in this queue. - * - * @throws NoSuchElementException if this queue is empty. + * @inheritDoc */ - public function removeLast(): mixed + public function removeLast() { - return $this->pollLast() ?? throw new NoSuchElementException( - 'Can\'t return element from Queue. Queue is empty.', - ); + $tail = $this->pollLast(); + + if ($tail === null) { + throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); + } + + return $tail; } /** - * @return T | null the head of this queue, or `null` if this queue is empty. + * @inheritDoc */ - public function pollFirst(): mixed + public function pollFirst() { return $this->poll(); } /** - * @return T | null the tail of this queue, or `null` if this queue is empty. + * @inheritDoc */ - public function pollLast(): mixed + public function pollLast() { - return array_pop($this->data); + if ($this->count() === 0) { + return null; + } + + $tail = $this[$this->tail]; + + unset($this[$this->tail]); + $this->tail--; + + return $tail; } /** - * @return T the head of this queue. - * - * @throws NoSuchElementException if this queue is empty. + * @inheritDoc */ - public function firstElement(): mixed + public function firstElement() { return $this->element(); } /** - * @return T the tail of this queue. - * - * @throws NoSuchElementException if this queue is empty. + * @inheritDoc */ - public function lastElement(): mixed + public function lastElement() { - return $this->peekLast() ?? throw new NoSuchElementException( - 'Can\'t return element from Queue. Queue is empty.', - ); + if ($this->count() === 0) { + throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); + } + + return $this->data[$this->tail]; } /** - * @return T | null the head of this queue, or `null` if this queue is empty. + * @inheritDoc */ - public function peekFirst(): mixed + public function peekFirst() { return $this->peek(); } /** - * @return T | null the tail of this queue, or `null` if this queue is empty. + * @inheritDoc */ - public function peekLast(): mixed + public function peekLast() { - $lastIndex = array_key_last($this->data); - - if ($lastIndex === null) { + if ($this->count() === 0) { return null; } - return $this->data[$lastIndex]; + return $this->data[$this->tail]; } } diff --git a/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php b/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php index 15cc0e97b..d7df53469 100644 --- a/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php +++ b/vendor/ramsey/collection/src/DoubleEndedQueueInterface.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Ramsey\Collection; use Ramsey\Collection\Exception\NoSuchElementException; -use RuntimeException; /** * A linear collection that supports element insertion and removal at both ends. @@ -176,12 +175,13 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @return bool `true` if this queue changed as a result of the call. * - * @throws RuntimeException if a queue refuses to add a particular element + * @throws \RuntimeException if a queue refuses to add a particular element * for any reason other than that it already contains the element. * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - public function addFirst(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function addFirst($element): bool; /** * Inserts the specified element at the end of this queue if it is possible @@ -196,12 +196,13 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @return bool `true` if this queue changed as a result of the call. * - * @throws RuntimeException if a queue refuses to add a particular element + * @throws \RuntimeException if a queue refuses to add a particular element * for any reason other than that it already contains the element. * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - public function addLast(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function addLast($element): bool; /** * Inserts the specified element at the front of this queue if it is @@ -215,7 +216,8 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @return bool `true` if the element was added to this queue, else `false`. */ - public function offerFirst(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function offerFirst($element): bool; /** * Inserts the specified element at the end of this queue if it is possible @@ -229,7 +231,8 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @return bool `true` if the element was added to this queue, else `false`. */ - public function offerLast(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function offerLast($element): bool; /** * Retrieves and removes the head of this queue. @@ -241,7 +244,7 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @throws NoSuchElementException if this queue is empty. */ - public function removeFirst(): mixed; + public function removeFirst(); /** * Retrieves and removes the tail of this queue. @@ -253,23 +256,23 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @throws NoSuchElementException if this queue is empty. */ - public function removeLast(): mixed; + public function removeLast(); /** * Retrieves and removes the head of this queue, or returns `null` if this * queue is empty. * - * @return T | null the head of this queue, or `null` if this queue is empty. + * @return T|null the head of this queue, or `null` if this queue is empty. */ - public function pollFirst(): mixed; + public function pollFirst(); /** * Retrieves and removes the tail of this queue, or returns `null` if this * queue is empty. * - * @return T | null the tail of this queue, or `null` if this queue is empty. + * @return T|null the tail of this queue, or `null` if this queue is empty. */ - public function pollLast(): mixed; + public function pollLast(); /** * Retrieves, but does not remove, the head of this queue. @@ -281,7 +284,7 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @throws NoSuchElementException if this queue is empty. */ - public function firstElement(): mixed; + public function firstElement(); /** * Retrieves, but does not remove, the tail of this queue. @@ -293,21 +296,21 @@ interface DoubleEndedQueueInterface extends QueueInterface * * @throws NoSuchElementException if this queue is empty. */ - public function lastElement(): mixed; + public function lastElement(); /** * Retrieves, but does not remove, the head of this queue, or returns `null` * if this queue is empty. * - * @return T | null the head of this queue, or `null` if this queue is empty. + * @return T|null the head of this queue, or `null` if this queue is empty. */ - public function peekFirst(): mixed; + public function peekFirst(); /** * Retrieves, but does not remove, the tail of this queue, or returns `null` * if this queue is empty. * - * @return T | null the tail of this queue, or `null` if this queue is empty. + * @return T|null the tail of this queue, or `null` if this queue is empty. */ - public function peekLast(): mixed; + public function peekLast(); } diff --git a/vendor/ramsey/collection/src/Exception/CollectionException.php b/vendor/ramsey/collection/src/Exception/CollectionException.php deleted file mode 100644 index 4aa92bed8..000000000 --- a/vendor/ramsey/collection/src/Exception/CollectionException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Collection\Exception; - -use Throwable; - -interface CollectionException extends Throwable -{ -} diff --git a/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php b/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php index 42f5be2df..d4b335f45 100644 --- a/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php +++ b/vendor/ramsey/collection/src/Exception/CollectionMismatchException.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Exception; -use RuntimeException; - /** * Thrown when attempting to operate on collections of differing types. */ -class CollectionMismatchException extends RuntimeException implements CollectionException +class CollectionMismatchException extends \RuntimeException { } diff --git a/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php b/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php index 7b41b4a7c..dcc3eac60 100644 --- a/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php +++ b/vendor/ramsey/collection/src/Exception/InvalidArgumentException.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Exception; -use InvalidArgumentException as PhpInvalidArgumentException; - /** * Thrown to indicate an argument is not of the expected type. */ -class InvalidArgumentException extends PhpInvalidArgumentException implements CollectionException +class InvalidArgumentException extends \InvalidArgumentException { } diff --git a/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php b/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php deleted file mode 100644 index a53be14aa..000000000 --- a/vendor/ramsey/collection/src/Exception/InvalidPropertyOrMethod.php +++ /dev/null @@ -1,26 +0,0 @@ - - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Collection\Exception; - -use RuntimeException; - -/** - * Thrown when attempting to evaluate a property, method, or array key - * that doesn't exist on an element or cannot otherwise be evaluated in the - * current context. - */ -class InvalidPropertyOrMethod extends RuntimeException implements CollectionException -{ -} diff --git a/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php b/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php new file mode 100644 index 000000000..9337ccc66 --- /dev/null +++ b/vendor/ramsey/collection/src/Exception/InvalidSortOrderException.php @@ -0,0 +1,22 @@ + + * @license http://opensource.org/licenses/MIT MIT + */ + +declare(strict_types=1); + +namespace Ramsey\Collection\Exception; + +/** + * Thrown when attempting to use a sort order that is not recognized. + */ +class InvalidSortOrderException extends \RuntimeException +{ +} diff --git a/vendor/ramsey/collection/src/Exception/NoSuchElementException.php b/vendor/ramsey/collection/src/Exception/NoSuchElementException.php index cd98f0c0f..9debe8f66 100644 --- a/vendor/ramsey/collection/src/Exception/NoSuchElementException.php +++ b/vendor/ramsey/collection/src/Exception/NoSuchElementException.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Exception; -use RuntimeException; - /** * Thrown when attempting to access an element that does not exist. */ -class NoSuchElementException extends RuntimeException implements CollectionException +class NoSuchElementException extends \RuntimeException { } diff --git a/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php b/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php index c75294e53..4e9d16fa3 100644 --- a/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php +++ b/vendor/ramsey/collection/src/Exception/OutOfBoundsException.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Exception; -use OutOfBoundsException as PhpOutOfBoundsException; - /** * Thrown when attempting to access an element out of the range of the collection. */ -class OutOfBoundsException extends PhpOutOfBoundsException implements CollectionException +class OutOfBoundsException extends \OutOfBoundsException { } diff --git a/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php b/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php index d074f45fd..8f45e5836 100644 --- a/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php +++ b/vendor/ramsey/collection/src/Exception/UnsupportedOperationException.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Exception; -use RuntimeException; - /** * Thrown to indicate that the requested operation is not supported. */ -class UnsupportedOperationException extends RuntimeException implements CollectionException +class UnsupportedOperationException extends \RuntimeException { } diff --git a/vendor/ramsey/collection/src/Exception/ValueExtractionException.php b/vendor/ramsey/collection/src/Exception/ValueExtractionException.php new file mode 100644 index 000000000..f6c6cb4ec --- /dev/null +++ b/vendor/ramsey/collection/src/Exception/ValueExtractionException.php @@ -0,0 +1,22 @@ + + * @license http://opensource.org/licenses/MIT MIT + */ + +declare(strict_types=1); + +namespace Ramsey\Collection\Exception; + +/** + * Thrown when attempting to extract a value for a method or property that does not exist. + */ +class ValueExtractionException extends \RuntimeException +{ +} diff --git a/vendor/ramsey/collection/src/Map/AbstractMap.php b/vendor/ramsey/collection/src/Map/AbstractMap.php index 7a851a80f..ae9f2fe61 100644 --- a/vendor/ramsey/collection/src/Map/AbstractMap.php +++ b/vendor/ramsey/collection/src/Map/AbstractMap.php @@ -16,65 +16,48 @@ namespace Ramsey\Collection\Map; use Ramsey\Collection\AbstractArray; use Ramsey\Collection\Exception\InvalidArgumentException; -use Traversable; use function array_key_exists; use function array_keys; use function in_array; -use function var_export; /** * This class provides a basic implementation of `MapInterface`, to minimize the * effort required to implement this interface. * - * @template K of array-key * @template T * @extends AbstractArray - * @implements MapInterface + * @implements MapInterface */ abstract class AbstractMap extends AbstractArray implements MapInterface { /** - * @param array $data The initial items to add to this map. - */ - public function __construct(array $data = []) - { - parent::__construct($data); - } - - /** - * @return Traversable - */ - public function getIterator(): Traversable - { - return parent::getIterator(); - } - - /** - * @param K $offset The offset to set - * @param T $value The value to set at the given offset. - * * @inheritDoc - * @psalm-suppress MoreSpecificImplementedParamType,DocblockTypeContradiction */ - public function offsetSet(mixed $offset, mixed $value): void + public function offsetSet($offset, $value): void { if ($offset === null) { throw new InvalidArgumentException( 'Map elements are key/value pairs; a key must be provided for ' - . 'value ' . var_export($value, true), + . 'value ' . var_export($value, true) ); } $this->data[$offset] = $value; } - public function containsKey(int | string $key): bool + /** + * @inheritDoc + */ + public function containsKey($key): bool { return array_key_exists($key, $this->data); } - public function containsValue(mixed $value): bool + /** + * @inheritDoc + */ + public function containsValue($value): bool { return in_array($value, $this->data, true); } @@ -88,24 +71,21 @@ abstract class AbstractMap extends AbstractArray implements MapInterface } /** - * @param K $key The key to return from the map. - * @param T | null $defaultValue The default value to use if `$key` is not found. - * - * @return T | null the value or `null` if the key could not be found. + * @inheritDoc */ - public function get(int | string $key, mixed $defaultValue = null): mixed + public function get($key, $defaultValue = null) { - return $this[$key] ?? $defaultValue; + if (!$this->containsKey($key)) { + return $defaultValue; + } + + return $this[$key]; } /** - * @param K $key The key to put or replace in the map. - * @param T $value The value to store at `$key`. - * - * @return T | null the previous value associated with key, or `null` if - * there was no mapping for `$key`. + * @inheritDoc */ - public function put(int | string $key, mixed $value): mixed + public function put($key, $value) { $previousValue = $this->get($key); $this[$key] = $value; @@ -114,13 +94,9 @@ abstract class AbstractMap extends AbstractArray implements MapInterface } /** - * @param K $key The key to put in the map. - * @param T $value The value to store at `$key`. - * - * @return T | null the previous value associated with key, or `null` if - * there was no mapping for `$key`. + * @inheritDoc */ - public function putIfAbsent(int | string $key, mixed $value): mixed + public function putIfAbsent($key, $value) { $currentValue = $this->get($key); @@ -132,12 +108,9 @@ abstract class AbstractMap extends AbstractArray implements MapInterface } /** - * @param K $key The key to remove from the map. - * - * @return T | null the previous value associated with key, or `null` if - * there was no mapping for `$key`. + * @inheritDoc */ - public function remove(int | string $key): mixed + public function remove($key) { $previousValue = $this->get($key); unset($this[$key]); @@ -145,7 +118,10 @@ abstract class AbstractMap extends AbstractArray implements MapInterface return $previousValue; } - public function removeIf(int | string $key, mixed $value): bool + /** + * @inheritDoc + */ + public function removeIf($key, $value): bool { if ($this->get($key) === $value) { unset($this[$key]); @@ -157,13 +133,9 @@ abstract class AbstractMap extends AbstractArray implements MapInterface } /** - * @param K $key The key to replace. - * @param T $value The value to set at `$key`. - * - * @return T | null the previous value associated with key, or `null` if - * there was no mapping for `$key`. + * @inheritDoc */ - public function replace(int | string $key, mixed $value): mixed + public function replace($key, $value) { $currentValue = $this->get($key); @@ -174,7 +146,10 @@ abstract class AbstractMap extends AbstractArray implements MapInterface return $currentValue; } - public function replaceIf(int | string $key, mixed $oldValue, mixed $newValue): bool + /** + * @inheritDoc + */ + public function replaceIf($key, $oldValue, $newValue): bool { if ($this->get($key) === $oldValue) { $this[$key] = $newValue; @@ -184,20 +159,4 @@ abstract class AbstractMap extends AbstractArray implements MapInterface return false; } - - /** - * @return array - */ - public function __serialize(): array - { - return parent::__serialize(); - } - - /** - * @return array - */ - public function toArray(): array - { - return parent::toArray(); - } } diff --git a/vendor/ramsey/collection/src/Map/AbstractTypedMap.php b/vendor/ramsey/collection/src/Map/AbstractTypedMap.php index 92fdcd54c..551d2e6c6 100644 --- a/vendor/ramsey/collection/src/Map/AbstractTypedMap.php +++ b/vendor/ramsey/collection/src/Map/AbstractTypedMap.php @@ -22,10 +22,10 @@ use Ramsey\Collection\Tool\ValueToStringTrait; * This class provides a basic implementation of `TypedMapInterface`, to * minimize the effort required to implement this interface. * - * @template K of array-key + * @template K * @template T - * @extends AbstractMap - * @implements TypedMapInterface + * @extends AbstractMap + * @implements TypedMapInterface */ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface { @@ -33,28 +33,37 @@ abstract class AbstractTypedMap extends AbstractMap implements TypedMapInterface use ValueToStringTrait; /** - * @param K $offset + * @param K|null $offset * @param T $value * * @inheritDoc + * * @psalm-suppress MoreSpecificImplementedParamType */ - public function offsetSet(mixed $offset, mixed $value): void + public function offsetSet($offset, $value): void { + if ($offset === null) { + throw new InvalidArgumentException( + 'Map elements are key/value pairs; a key must be provided for ' + . 'value ' . var_export($value, true) + ); + } + if ($this->checkType($this->getKeyType(), $offset) === false) { throw new InvalidArgumentException( 'Key must be of type ' . $this->getKeyType() . '; key is ' - . $this->toolValueToString($offset), + . $this->toolValueToString($offset) ); } if ($this->checkType($this->getValueType(), $value) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getValueType() . '; value is ' - . $this->toolValueToString($value), + . $this->toolValueToString($value) ); } + /** @psalm-suppress MixedArgumentTypeCoercion */ parent::offsetSet($offset, $value); } } diff --git a/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php b/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php index 34e4e853b..79a314d96 100644 --- a/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php +++ b/vendor/ramsey/collection/src/Map/AssociativeArrayMap.php @@ -17,7 +17,8 @@ namespace Ramsey\Collection\Map; /** * `AssociativeArrayMap` represents a standard associative array object. * - * @extends AbstractMap + * @template T + * @extends AbstractMap */ class AssociativeArrayMap extends AbstractMap { diff --git a/vendor/ramsey/collection/src/Map/MapInterface.php b/vendor/ramsey/collection/src/Map/MapInterface.php index 22ba1bdd1..6ed0b2967 100644 --- a/vendor/ramsey/collection/src/Map/MapInterface.php +++ b/vendor/ramsey/collection/src/Map/MapInterface.php @@ -21,7 +21,6 @@ use Ramsey\Collection\ArrayInterface; * * A map cannot contain duplicate keys; each key can map to at most one value. * - * @template K of array-key * @template T * @extends ArrayInterface */ @@ -30,9 +29,9 @@ interface MapInterface extends ArrayInterface /** * Returns `true` if this map contains a mapping for the specified key. * - * @param K $key The key to check in the map. + * @param array-key $key The key to check in the map. */ - public function containsKey(int | string $key): bool; + public function containsKey($key): bool; /** * Returns `true` if this map maps one or more keys to the specified value. @@ -41,12 +40,13 @@ interface MapInterface extends ArrayInterface * * @param T $value The value to check in the map. */ - public function containsValue(mixed $value): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function containsValue($value): bool; /** * Return an array of the keys contained in this map. * - * @return list + * @return list */ public function keys(): array; @@ -55,12 +55,13 @@ interface MapInterface extends ArrayInterface * map contains no mapping for the key, or (optionally) `$defaultValue` if * this map contains no mapping for the key. * - * @param K $key The key to return from the map. - * @param T | null $defaultValue The default value to use if `$key` is not found. + * @param array-key $key The key to return from the map. + * @param T|null $defaultValue The default value to use if `$key` is not found. * - * @return T | null the value or `null` if the key could not be found. + * @return T|null the value or `null` if the key could not be found. */ - public function get(int | string $key, mixed $defaultValue = null): mixed; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function get($key, $defaultValue = null); /** * Associates the specified value with the specified key in this map. @@ -68,13 +69,14 @@ interface MapInterface extends ArrayInterface * If the map previously contained a mapping for the key, the old value is * replaced by the specified value. * - * @param K $key The key to put or replace in the map. + * @param array-key $key The key to put or replace in the map. * @param T $value The value to store at `$key`. * - * @return T | null the previous value associated with key, or `null` if + * @return T|null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - public function put(int | string $key, mixed $value): mixed; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function put($key, $value); /** * Associates the specified value with the specified key in this map only if @@ -83,23 +85,25 @@ interface MapInterface extends ArrayInterface * If there is already a value associated with `$key`, this returns that * value without replacing it. * - * @param K $key The key to put in the map. + * @param array-key $key The key to put in the map. * @param T $value The value to store at `$key`. * - * @return T | null the previous value associated with key, or `null` if + * @return T|null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - public function putIfAbsent(int | string $key, mixed $value): mixed; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function putIfAbsent($key, $value); /** * Removes the mapping for a key from this map if it is present. * - * @param K $key The key to remove from the map. + * @param array-key $key The key to remove from the map. * - * @return T | null the previous value associated with key, or `null` if + * @return T|null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - public function remove(int | string $key): mixed; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function remove($key); /** * Removes the entry for the specified key only if it is currently mapped to @@ -107,24 +111,26 @@ interface MapInterface extends ArrayInterface * * This performs a strict type check on the value. * - * @param K $key The key to remove from the map. + * @param array-key $key The key to remove from the map. * @param T $value The value to match. * * @return bool true if the value was removed. */ - public function removeIf(int | string $key, mixed $value): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function removeIf($key, $value): bool; /** * Replaces the entry for the specified key only if it is currently mapped * to some value. * - * @param K $key The key to replace. + * @param array-key $key The key to replace. * @param T $value The value to set at `$key`. * - * @return T | null the previous value associated with key, or `null` if + * @return T|null the previous value associated with key, or `null` if * there was no mapping for `$key`. */ - public function replace(int | string $key, mixed $value): mixed; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function replace($key, $value); /** * Replaces the entry for the specified key only if currently mapped to the @@ -132,11 +138,12 @@ interface MapInterface extends ArrayInterface * * This performs a strict type check on the value. * - * @param K $key The key to remove from the map. + * @param array-key $key The key to remove from the map. * @param T $oldValue The value to match. * @param T $newValue The value to use as a replacement. * * @return bool true if the value was replaced. */ - public function replaceIf(int | string $key, mixed $oldValue, mixed $newValue): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function replaceIf($key, $oldValue, $newValue): bool; } diff --git a/vendor/ramsey/collection/src/Map/NamedParameterMap.php b/vendor/ramsey/collection/src/Map/NamedParameterMap.php index f948e476c..9926ddd8c 100644 --- a/vendor/ramsey/collection/src/Map/NamedParameterMap.php +++ b/vendor/ramsey/collection/src/Map/NamedParameterMap.php @@ -26,7 +26,7 @@ use function is_int; * `NamedParameterMap` represents a mapping of values to a set of named keys * that may optionally be typed * - * @extends AbstractMap + * @extends AbstractMap */ class NamedParameterMap extends AbstractMap { @@ -38,13 +38,13 @@ class NamedParameterMap extends AbstractMap * * @var array */ - private readonly array $namedParameters; + protected $namedParameters; /** * Constructs a new `NamedParameterMap`. * * @param array $namedParameters The named parameters defined for this map. - * @param array $data An initial set of data to set on this map. + * @param array $data An initial set of data to set on this map. */ public function __construct(array $namedParameters, array $data = []) { @@ -62,12 +62,22 @@ class NamedParameterMap extends AbstractMap return $this->namedParameters; } - public function offsetSet(mixed $offset, mixed $value): void + /** + * @inheritDoc + */ + public function offsetSet($offset, $value): void { + if ($offset === null) { + throw new InvalidArgumentException( + 'Map elements are key/value pairs; a key must be provided for ' + . 'value ' . var_export($value, true) + ); + } + if (!array_key_exists($offset, $this->namedParameters)) { throw new InvalidArgumentException( 'Attempting to set value for unconfigured parameter \'' - . $this->toolValueToString($offset) . '\'', + . $offset . '\'' ); } @@ -75,7 +85,7 @@ class NamedParameterMap extends AbstractMap throw new InvalidArgumentException( 'Value for \'' . $offset . '\' must be of type ' . $this->namedParameters[$offset] . '; value is ' - . $this->toolValueToString($value), + . $this->toolValueToString($value) ); } diff --git a/vendor/ramsey/collection/src/Map/TypedMap.php b/vendor/ramsey/collection/src/Map/TypedMap.php index f914d9c70..2e796377a 100644 --- a/vendor/ramsey/collection/src/Map/TypedMap.php +++ b/vendor/ramsey/collection/src/Map/TypedMap.php @@ -14,11 +14,13 @@ declare(strict_types=1); namespace Ramsey\Collection\Map; +use Ramsey\Collection\Tool\TypeTrait; + /** * A `TypedMap` represents a map of elements where key and value are typed. * * Each element is identified by a key with defined type and a value of defined - * type. The keys of the map must be unique. The values on the map can be + * type. The keys of the map must be unique. The values on the map can be= * repeated but each with its own different key. * * The most common case is to use a string type key, but it's not limited to @@ -78,12 +80,34 @@ namespace Ramsey\Collection\Map; * } * ``` * - * @template K of array-key + * @template K * @template T * @extends AbstractTypedMap */ class TypedMap extends AbstractTypedMap { + use TypeTrait; + + /** + * The data type of keys stored in this collection. + * + * A map key's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string data type of the map key. + */ + private $keyType; + + /** + * The data type of values stored in this collection. + * + * A map value's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string data type of the map value. + */ + private $valueType; + /** * Constructs a map object of the specified key and value types, * optionally with the specified data. @@ -92,11 +116,12 @@ class TypedMap extends AbstractTypedMap * @param string $valueType The data type of the map's values. * @param array $data The initial data to set for this map. */ - public function __construct( - private readonly string $keyType, - private readonly string $valueType, - array $data = [], - ) { + public function __construct(string $keyType, string $valueType, array $data = []) + { + $this->keyType = $keyType; + $this->valueType = $valueType; + + /** @psalm-suppress MixedArgumentTypeCoercion */ parent::__construct($data); } diff --git a/vendor/ramsey/collection/src/Map/TypedMapInterface.php b/vendor/ramsey/collection/src/Map/TypedMapInterface.php index 5a44f0647..0308109cc 100644 --- a/vendor/ramsey/collection/src/Map/TypedMapInterface.php +++ b/vendor/ramsey/collection/src/Map/TypedMapInterface.php @@ -18,9 +18,8 @@ namespace Ramsey\Collection\Map; * A `TypedMapInterface` represents a map of elements where key and value are * typed. * - * @template K of array-key * @template T - * @extends MapInterface + * @extends MapInterface */ interface TypedMapInterface extends MapInterface { diff --git a/vendor/ramsey/collection/src/Queue.php b/vendor/ramsey/collection/src/Queue.php index 0f5b33740..93e032b43 100644 --- a/vendor/ramsey/collection/src/Queue.php +++ b/vendor/ramsey/collection/src/Queue.php @@ -19,8 +19,6 @@ use Ramsey\Collection\Exception\NoSuchElementException; use Ramsey\Collection\Tool\TypeTrait; use Ramsey\Collection\Tool\ValueToStringTrait; -use function array_key_first; - /** * This class provides a basic implementation of `QueueInterface`, to minimize * the effort required to implement this interface. @@ -34,15 +32,33 @@ class Queue extends AbstractArray implements QueueInterface use TypeTrait; use ValueToStringTrait; + /** + * The type of elements stored in this queue. + * + * A queue's type is immutable once it is set. For this reason, this + * property is set private. + * + * @var string + */ + private $queueType; + + /** + * The index of the head of the queue. + * + * @var int + */ + protected $index = 0; + /** * Constructs a queue object of the specified type, optionally with the * specified data. * - * @param string $queueType The type or class name associated with this queue. - * @param array $data The initial items to store in the queue. + * @param string $queueType The type (FQCN) associated with this queue. + * @param array $data The initial items to store in the collection. */ - public function __construct(private readonly string $queueType, array $data = []) + public function __construct(string $queueType, array $data = []) { + $this->queueType = $queueType; parent::__construct($data); } @@ -52,15 +68,13 @@ class Queue extends AbstractArray implements QueueInterface * Since arbitrary offsets may not be manipulated in a queue, this method * serves only to fulfill the `ArrayAccess` interface requirements. It is * invoked by other operations when adding values to the queue. - * - * @throws InvalidArgumentException if $value is of the wrong type. */ - public function offsetSet(mixed $offset, mixed $value): void + public function offsetSet($offset, $value): void { if ($this->checkType($this->getType(), $value) === false) { throw new InvalidArgumentException( 'Value must be of type ' . $this->getType() . '; value is ' - . $this->toolValueToString($value), + . $this->toolValueToString($value) ); } @@ -68,9 +82,9 @@ class Queue extends AbstractArray implements QueueInterface } /** - * @throws InvalidArgumentException if $value is of the wrong type. + * @inheritDoc */ - public function add(mixed $element): bool + public function add($element): bool { $this[] = $element; @@ -78,67 +92,74 @@ class Queue extends AbstractArray implements QueueInterface } /** - * @return T - * - * @throws NoSuchElementException if this queue is empty. + * @inheritDoc */ - public function element(): mixed + public function element() { - return $this->peek() ?? throw new NoSuchElementException( - 'Can\'t return element from Queue. Queue is empty.', - ); + $element = $this->peek(); + + if ($element === null) { + throw new NoSuchElementException( + 'Can\'t return element from Queue. Queue is empty.' + ); + } + + return $element; } - public function offer(mixed $element): bool + /** + * @inheritDoc + */ + public function offer($element): bool { try { return $this->add($element); - } catch (InvalidArgumentException) { + } catch (InvalidArgumentException $e) { return false; } } /** - * @return T | null + * @inheritDoc */ - public function peek(): mixed + public function peek() { - $index = array_key_first($this->data); - - if ($index === null) { + if ($this->count() === 0) { return null; } - return $this[$index]; + return $this[$this->index]; } /** - * @return T | null + * @inheritDoc */ - public function poll(): mixed + public function poll() { - $index = array_key_first($this->data); - - if ($index === null) { + if ($this->count() === 0) { return null; } - $head = $this[$index]; - unset($this[$index]); + $head = $this[$this->index]; + + unset($this[$this->index]); + $this->index++; return $head; } /** - * @return T - * - * @throws NoSuchElementException if this queue is empty. + * @inheritDoc */ - public function remove(): mixed + public function remove() { - return $this->poll() ?? throw new NoSuchElementException( - 'Can\'t return element from Queue. Queue is empty.', - ); + $head = $this->poll(); + + if ($head === null) { + throw new NoSuchElementException('Can\'t return element from Queue. Queue is empty.'); + } + + return $head; } public function getType(): string diff --git a/vendor/ramsey/collection/src/QueueInterface.php b/vendor/ramsey/collection/src/QueueInterface.php index f29ce43ab..8c7383df8 100644 --- a/vendor/ramsey/collection/src/QueueInterface.php +++ b/vendor/ramsey/collection/src/QueueInterface.php @@ -15,7 +15,6 @@ declare(strict_types=1); namespace Ramsey\Collection; use Ramsey\Collection\Exception\NoSuchElementException; -use RuntimeException; /** * A queue is a collection in which the entities in the collection are kept in @@ -124,12 +123,13 @@ interface QueueInterface extends ArrayInterface * * @return bool `true` if this queue changed as a result of the call. * - * @throws RuntimeException if a queue refuses to add a particular element + * @throws \RuntimeException if a queue refuses to add a particular element * for any reason other than that it already contains the element. * Implementations should use a more-specific exception that extends * `\RuntimeException`. */ - public function add(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function add($element): bool; /** * Retrieves, but does not remove, the head of this queue. @@ -143,7 +143,7 @@ interface QueueInterface extends ArrayInterface * * @throws NoSuchElementException if this queue is empty. */ - public function element(): mixed; + public function element(); /** * Inserts the specified element into this queue if it is possible to do so @@ -159,7 +159,8 @@ interface QueueInterface extends ArrayInterface * * @return bool `true` if the element was added to this queue, else `false`. */ - public function offer(mixed $element): bool; + // phpcs:ignore SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint + public function offer($element): bool; /** * Retrieves, but does not remove, the head of this queue, or returns `null` @@ -167,9 +168,9 @@ interface QueueInterface extends ArrayInterface * * @see self::element() * - * @return T | null the head of this queue, or `null` if this queue is empty. + * @return T|null the head of this queue, or `null` if this queue is empty. */ - public function peek(): mixed; + public function peek(); /** * Retrieves and removes the head of this queue, or returns `null` @@ -177,9 +178,9 @@ interface QueueInterface extends ArrayInterface * * @see self::remove() * - * @return T | null the head of this queue, or `null` if this queue is empty. + * @return T|null the head of this queue, or `null` if this queue is empty. */ - public function poll(): mixed; + public function poll(); /** * Retrieves and removes the head of this queue. @@ -193,7 +194,7 @@ interface QueueInterface extends ArrayInterface * * @throws NoSuchElementException if this queue is empty. */ - public function remove(): mixed; + public function remove(); /** * Returns the type associated with this queue. diff --git a/vendor/ramsey/collection/src/Set.php b/vendor/ramsey/collection/src/Set.php index aa93351c4..6932f247a 100644 --- a/vendor/ramsey/collection/src/Set.php +++ b/vendor/ramsey/collection/src/Set.php @@ -28,7 +28,7 @@ namespace Ramsey\Collection; * $foo = new \My\Foo(); * $set = new Set(\My\Foo::class); * - * $set->add($foo); // returns TRUE, the element doesn't exist + * $set->add($foo); // returns TRUE, the element don't exists * $set->add($foo); // returns FALSE, the element already exists * * $bar = new \My\Foo(); @@ -40,15 +40,25 @@ namespace Ramsey\Collection; */ class Set extends AbstractSet { + /** + * The type of elements stored in this set + * + * A set's type is immutable. For this reason, this property is private. + * + * @var string + */ + private $setType; + /** * Constructs a set object of the specified type, optionally with the * specified data. * - * @param string $setType The type or class name associated with this set. + * @param string $setType The type (FQCN) associated with this set. * @param array $data The initial items to store in the set. */ - public function __construct(private readonly string $setType, array $data = []) + public function __construct(string $setType, array $data = []) { + $this->setType = $setType; parent::__construct($data); } diff --git a/vendor/ramsey/collection/src/Sort.php b/vendor/ramsey/collection/src/Sort.php deleted file mode 100644 index 0c3c19213..000000000 --- a/vendor/ramsey/collection/src/Sort.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @license http://opensource.org/licenses/MIT MIT - */ - -declare(strict_types=1); - -namespace Ramsey\Collection; - -/** - * Collection sorting - */ -enum Sort: string -{ - /** - * Sort items in a collection in ascending order. - */ - case Ascending = 'asc'; - - /** - * Sort items in a collection in descending order. - */ - case Descending = 'desc'; -} diff --git a/vendor/ramsey/collection/src/Tool/TypeTrait.php b/vendor/ramsey/collection/src/Tool/TypeTrait.php index ac51b7f10..8214e9654 100644 --- a/vendor/ramsey/collection/src/Tool/TypeTrait.php +++ b/vendor/ramsey/collection/src/Tool/TypeTrait.php @@ -36,22 +36,38 @@ trait TypeTrait * @param string $type The type to check the value against. * @param mixed $value The value to check. */ - protected function checkType(string $type, mixed $value): bool + protected function checkType(string $type, $value): bool { - return match ($type) { - 'array' => is_array($value), - 'bool', 'boolean' => is_bool($value), - 'callable' => is_callable($value), - 'float', 'double' => is_float($value), - 'int', 'integer' => is_int($value), - 'null' => $value === null, - 'numeric' => is_numeric($value), - 'object' => is_object($value), - 'resource' => is_resource($value), - 'scalar' => is_scalar($value), - 'string' => is_string($value), - 'mixed' => true, - default => $value instanceof $type, - }; + switch ($type) { + case 'array': + return is_array($value); + case 'bool': + case 'boolean': + return is_bool($value); + case 'callable': + return is_callable($value); + case 'float': + case 'double': + return is_float($value); + case 'int': + case 'integer': + return is_int($value); + case 'null': + return $value === null; + case 'numeric': + return is_numeric($value); + case 'object': + return is_object($value); + case 'resource': + return is_resource($value); + case 'scalar': + return is_scalar($value); + case 'string': + return is_string($value); + case 'mixed': + return true; + default: + return $value instanceof $type; + } } } diff --git a/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php b/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php index 44c422252..f9be1be28 100644 --- a/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php +++ b/vendor/ramsey/collection/src/Tool/ValueExtractorTrait.php @@ -14,11 +14,9 @@ declare(strict_types=1); namespace Ramsey\Collection\Tool; -use Ramsey\Collection\Exception\InvalidPropertyOrMethod; -use Ramsey\Collection\Exception\UnsupportedOperationException; +use Ramsey\Collection\Exception\ValueExtractionException; -use function is_array; -use function is_object; +use function get_class; use function method_exists; use function property_exists; use function sprintf; @@ -29,53 +27,32 @@ use function sprintf; trait ValueExtractorTrait { /** - * Extracts the value of the given property, method, or array key from the - * element. + * Extracts the value of the given property or method from the object. * - * If `$propertyOrMethod` is `null`, we return the element as-is. - * - * @param mixed $element The element to extract the value from. - * @param string | null $propertyOrMethod The property or method for which the + * @param mixed $object The object to extract the value from. + * @param string $propertyOrMethod The property or method for which the * value should be extracted. * - * @return mixed the value extracted from the specified property, method, - * or array key, or the element itself. + * @return mixed the value extracted from the specified property or method. * - * @throws InvalidPropertyOrMethod - * @throws UnsupportedOperationException + * @throws ValueExtractionException if the method or property is not defined. */ - protected function extractValue(mixed $element, ?string $propertyOrMethod): mixed + protected function extractValue($object, string $propertyOrMethod) { - if ($propertyOrMethod === null) { - return $element; - } - - if (!is_object($element) && !is_array($element)) { - throw new UnsupportedOperationException(sprintf( - 'The collection type "%s" does not support the $propertyOrMethod parameter', - $this->getType(), - )); - } - - if (is_array($element)) { - return $element[$propertyOrMethod] ?? throw new InvalidPropertyOrMethod(sprintf( - 'Key or index "%s" not found in collection elements', - $propertyOrMethod, - )); + if (!is_object($object)) { + throw new ValueExtractionException('Unable to extract a value from a non-object'); } - if (property_exists($element, $propertyOrMethod)) { - return $element->$propertyOrMethod; + if (property_exists($object, $propertyOrMethod)) { + return $object->$propertyOrMethod; } - if (method_exists($element, $propertyOrMethod)) { - return $element->{$propertyOrMethod}(); + if (method_exists($object, $propertyOrMethod)) { + return $object->{$propertyOrMethod}(); } - throw new InvalidPropertyOrMethod(sprintf( - 'Method or property "%s" not defined in %s', - $propertyOrMethod, - $element::class, - )); + throw new ValueExtractionException( + sprintf('Method or property "%s" not defined in %s', $propertyOrMethod, get_class($object)) + ); } } diff --git a/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php b/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php index 64fc5fa42..721ade002 100644 --- a/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php +++ b/vendor/ramsey/collection/src/Tool/ValueToStringTrait.php @@ -16,12 +16,11 @@ namespace Ramsey\Collection\Tool; use DateTimeInterface; -use function assert; +use function get_class; use function get_resource_type; use function is_array; use function is_bool; use function is_callable; -use function is_object; use function is_resource; use function is_scalar; @@ -45,7 +44,7 @@ trait ValueToStringTrait * * @param mixed $value the value to return as a string. */ - protected function toolValueToString(mixed $value): string + protected function toolValueToString($value): string { // null if ($value === null) { @@ -72,8 +71,12 @@ trait ValueToStringTrait return '(' . get_resource_type($value) . ' resource #' . (int) $value . ')'; } + // If we don't know what it is, use var_export(). + if (!is_object($value)) { + return '(' . var_export($value, true) . ')'; + } + // From here, $value should be an object. - assert(is_object($value)); // __toString() is implemented if (is_callable([$value, '__toString'])) { @@ -86,6 +89,6 @@ trait ValueToStringTrait } // unknown type - return '(' . $value::class . ' Object)'; + return '(' . get_class($value) . ' Object)'; } } -- cgit v1.2.3