diff --git a/.gitattributes b/.gitattributes index eead063b..e5239788 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,6 @@ /tests export-ignore /.github export-ignore +.doctrine-project.json export-ignore .gitattributes export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore diff --git a/composer.json b/composer.json index 36ad7f1a..ff939f36 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "require-dev": { "ext-json": "*", - "doctrine/coding-standard": "^10.0", + "doctrine/coding-standard": "^12", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5", diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 10f6681b..6ace1e36 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -14,7 +14,10 @@ src tests - + + + + tests/* diff --git a/src/AbstractLazyCollection.php b/src/AbstractLazyCollection.php index 222bbe1b..c926b6d8 100644 --- a/src/AbstractLazyCollection.php +++ b/src/AbstractLazyCollection.php @@ -178,12 +178,9 @@ public function findFirst(Closure $p): mixed } /** - * @psalm-param Closure(T, TKey):bool $p - * - * @return ReadableCollection - * @psalm-return ReadableCollection + * {@inheritDoc} */ - public function filter(Closure $p): ReadableCollection + public function filter(Closure $p): Collection { $this->initialize(); @@ -198,14 +195,9 @@ public function forAll(Closure $p): bool } /** - * @psalm-param Closure(T):U $func - * - * @return ReadableCollection - * @psalm-return ReadableCollection - * - * @psalm-template U + * {@inheritDoc} */ - public function map(Closure $func): ReadableCollection + public function map(Closure $func): Collection { $this->initialize(); diff --git a/src/Collection.php b/src/Collection.php index fb3b5baf..3dc56ac3 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -5,6 +5,7 @@ namespace Doctrine\Common\Collections; use ArrayAccess; +use Closure; /** * The missing (SPL) Collection/Array/OrderedMap interface. @@ -73,4 +74,34 @@ public function removeElement(mixed $element): bool; * @psalm-param T $value */ public function set(string|int $key, mixed $value): void; + + /** + * {@inheritDoc} + * + * @psalm-param Closure(T):U $func + * + * @return Collection + * @psalm-return Collection + * + * @psalm-template U + */ + public function map(Closure $func): self; + + /** + * {@inheritDoc} + * + * @return Collection A collection with the results of the filter operation. + * @psalm-return Collection + */ + public function filter(Closure $p): self; + + /** + * {@inheritDoc} + + * @return Collection[] An array with two elements. The first element contains the collection + * of elements where the predicate returned TRUE, the second element + * contains the collection of elements where the predicate returned FALSE. + * @psalm-return array{0: Collection, 1: Collection} + */ + public function partition(Closure $p): array; }