Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge release 2.1.4 into 3.0.x #381

Merged
merged 10 commits into from
Oct 3, 2023
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
<file>src</file>
<file>tests</file>

<rule ref="Doctrine" />
<rule ref="Doctrine" >
<!-- https://github.com/doctrine/collections/pull/381#issuecomment-1745206747 -->
<exclude name="SlevomatCodingStandard.Commenting.UselessInheritDocComment" />
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>tests/*</exclude-pattern>
Expand Down
16 changes: 4 additions & 12 deletions src/AbstractLazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,9 @@ public function findFirst(Closure $p): mixed
}

/**
* @psalm-param Closure(T, TKey):bool $p
*
* @return ReadableCollection<mixed>
* @psalm-return ReadableCollection<TKey, T>
* {@inheritDoc}
*/
public function filter(Closure $p): ReadableCollection
public function filter(Closure $p): Collection
{
$this->initialize();

Expand All @@ -198,14 +195,9 @@ public function forAll(Closure $p): bool
}

/**
* @psalm-param Closure(T):U $func
*
* @return ReadableCollection<mixed>
* @psalm-return ReadableCollection<TKey, U>
*
* @psalm-template U
* {@inheritDoc}
*/
public function map(Closure $func): ReadableCollection
public function map(Closure $func): Collection
{
$this->initialize();

Expand Down
31 changes: 31 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Doctrine\Common\Collections;

use ArrayAccess;
use Closure;

/**
* The missing (SPL) Collection/Array/OrderedMap interface.
Expand Down Expand Up @@ -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<mixed>
* @psalm-return Collection<TKey, U>
*
* @psalm-template U
*/
public function map(Closure $func): self;

/**
* {@inheritDoc}
*
* @return Collection<mixed> A collection with the results of the filter operation.
* @psalm-return Collection<TKey, T>
*/
public function filter(Closure $p): self;

/**
* {@inheritDoc}

* @return Collection<mixed>[] An array with two elements. The first element contains the collection
* of elements where the predicate returned TRUE, the second element
* contains the collection of elements where the predicate returned FALSE.
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*/
public function partition(Closure $p): array;
}
Loading