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 2.3.x into 3.0.x #423

Merged
merged 19 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "CI"
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ on:
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.5.0"
uses: "doctrine/.github/.github/workflows/[email protected].1"
with:
php-version: "8.1"
2 changes: 1 addition & 1 deletion .github/workflows/composer-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ on:
jobs:
composer-lint:
name: "Composer Lint"
uses: "doctrine/.github/.github/workflows/composer-lint.yml@1.5.0"
uses: "doctrine/.github/.github/workflows/[email protected].1"
with:
php-version: "8.1"
4 changes: 3 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
jobs:
phpunit:
name: "PHPUnit"
uses: "doctrine/.github/.github/workflows/continuous-integration.yml@1.5.0"
uses: "doctrine/.github/.github/workflows/[email protected].1"
with:
php-versions: '["8.1"]'
secrets:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
4 changes: 2 additions & 2 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
Expand All @@ -36,7 +36,7 @@ jobs:
run: "composer require --dev phpdocumentor/guides-cli --no-update"

- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
uses: "ramsey/composer-install@v3"
with:
dependency-versions: "highest"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-on-milestone-closed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@1.5.0"
uses: "doctrine/.github/.github/workflows/[email protected].1"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ on:
jobs:
static-analysis:
name: "Static Analysis"
uses: "doctrine/.github/.github/workflows/static-analysis.yml@1.5.0"
uses: "doctrine/.github/.github/workflows/[email protected].1"
with:
php-version: "8.1"
10 changes: 10 additions & 0 deletions docs/en/expression-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ isNull

$collection->matching(new Criteria($expression));

isNotNull
---------

.. code-block:: php
$expressionBuilder = Criteria::expr();

$expression = $expressionBuilder->isNotNull('foo');

$collection->matching(new Criteria($expression));

in
---

Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ parameters:
level: 8
paths:
- src
- tests/StaticAnalysis

ignoreErrors:
# https://github.com/phpstan/phpstan-src/pull/1289
Expand Down
1 change: 1 addition & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
>
<projectFiles>
<directory name="src" />
<directory name="tests/StaticAnalysis" />
<ignoreFiles>
<directory name="vendor" />
<directory name="src/Expr"/>
Expand Down
2 changes: 2 additions & 0 deletions src/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ public function reduce(Closure $func, $initial = null): mixed
/**
* {@inheritDoc}
*
* @psalm-param Closure(T, TKey):bool $p
*
* @return static
* @psalm-return static<TKey,T>
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,18 @@ public function map(Closure $func): self;
/**
* {@inheritDoc}
*
* @psalm-param Closure(T, TKey):bool $p
*
* @return Collection<mixed> A collection with the results of the filter operation.
* @psalm-return Collection<TKey, T>
*/
public function filter(Closure $p): self;

/**
* {@inheritDoc}

*
* @psalm-param Closure(TKey, T):bool $p
*
* @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.
Expand Down
5 changes: 5 additions & 0 deletions src/ExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function isNull(string $field): Comparison
return new Comparison($field, Comparison::EQ, new Value(null));
}

public function isNotNull(string $field): Comparison
{
return new Comparison($field, Comparison::NEQ, new Value(null));
}

/** @param mixed[] $values */
public function in(string $field, array $values): Comparison
{
Expand Down
8 changes: 8 additions & 0 deletions tests/ExpressionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public function testIsNull(): void
self::assertEquals(Comparison::EQ, $expr->getOperator());
}

public function testIsNotNull(): void
{
$expr = $this->builder->isNotNull('a');

self::assertInstanceOf(Comparison::class, $expr);
self::assertEquals(Comparison::NEQ, $expr->getOperator());
}

public function testContains(): void
{
$expr = $this->builder->contains('a', 'b');
Expand Down
46 changes: 46 additions & 0 deletions tests/StaticAnalysis/CustomCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\Common\Collections\StaticAnalysis;

use Closure;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;

/**
* @phpstan-template TKey of array-key
* @phpstan-template T of object
* @phpstan-implements Collection<TKey, T>
*/
abstract class CustomCollection implements Collection
{
/** @var ArrayCollection<TKey, T> */
private ArrayCollection $collection;

/** @param ArrayCollection<TKey, T> $arrayCollection */
public function __construct(ArrayCollection $arrayCollection)
{
$this->collection = $arrayCollection;
}

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

/**
* @psalm-param Closure(TKey, T):bool $p
*
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*/
public function partition(Closure $p): array
{
return $this->collection->partition($p);
}
}