From 432873a9c1c7ac8e33067a1c90a821d5e7a9dfd2 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 24 Jul 2025 15:02:42 +0300 Subject: [PATCH 1/2] Rename `All` to `AndX`, `Any` to `OrX`. Remove `Group`. --- CHANGELOG.md | 1 + README.md | 12 +++---- composer.json | 4 +-- docs/guide/pt-BR/README.md | 12 +++---- src/Reader/Filter/All.php | 22 ------------ src/Reader/Filter/AndX.php | 36 +++++++++++++++++++ src/Reader/Filter/Any.php | 21 ----------- src/Reader/Filter/{Group.php => OrX.php} | 23 ++++++------ .../{AllHandler.php => AndXHandler.php} | 12 +++---- .../{AnyHandler.php => OrXHandler.php} | 12 +++---- src/Reader/Iterable/IterableDataReader.php | 8 ++--- ...ase.php => BaseReaderWithAndXTestCase.php} | 6 ++-- .../BaseReaderWithNotTestCase.php | 8 ++--- ...Case.php => BaseReaderWithOrXTestCase.php} | 12 +++---- ...AllHandlerTest.php => AndXHandlerTest.php} | 14 ++++---- .../Iterable/FilterHandler/AnyHandlerTest.php | 14 ++++---- .../Iterable/IterableDataReaderTest.php | 14 ++++---- ...WithAllTest.php => ReaderWithAndXTest.php} | 4 +-- ...rWithAnyTest.php => ReaderWithOrXTest.php} | 12 +++---- 19 files changed, 121 insertions(+), 126 deletions(-) delete mode 100644 src/Reader/Filter/All.php create mode 100644 src/Reader/Filter/AndX.php delete mode 100644 src/Reader/Filter/Any.php rename src/Reader/Filter/{Group.php => OrX.php} (56%) rename src/Reader/Iterable/FilterHandler/{AllHandler.php => AndXHandler.php} (70%) rename src/Reader/Iterable/FilterHandler/{AnyHandler.php => OrXHandler.php} (71%) rename tests/Common/Reader/ReaderWithFilter/{BaseReaderWithAllTestCase.php => BaseReaderWithAndXTestCase.php} (63%) rename tests/Common/Reader/ReaderWithFilter/{BaseReaderWithAnyTestCase.php => BaseReaderWithOrXTestCase.php} (70%) rename tests/Reader/Iterable/FilterHandler/{AllHandlerTest.php => AndXHandlerTest.php} (90%) rename tests/Reader/Iterable/ReaderWithFilter/{ReaderWithAllTest.php => ReaderWithAndXTest.php} (69%) rename tests/Reader/Iterable/ReaderWithFilter/{ReaderWithAnyTest.php => ReaderWithOrXTest.php} (67%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0880da8..1406806c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,7 @@ - Enh #223: `KeysetPaginator` now uses default order from `Sort` when no sort is set (@vjik) - Chg #224: Change `$iterableFilterHandlers` to context object in `IterableFilterHandlerInterface::match()` (@vjik) - New #224: Add filtering by nested values support in `IterableDataReader` (@vjik) +- Chg #225: Rename classes: `All` to `AndX`, `Any` to `OrX`. Remove `Group` class (@vjik) ## 1.0.1 January 25, 2023 diff --git a/README.md b/README.md index 4505b45d..74ecc553 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ To filter data in a data reader implementing `FilterableDataInterface` you need `withFilter()` method: ```php -$filter = new All( +$filter = new AndX( new GreaterThan('id', 3), new Like('name', 'agent') ); @@ -114,8 +114,7 @@ $data = $reader->read(); Filter could be composed with: -- `All` -- `Any` +- `AndX` - `Between` - `Equals` - `EqualsNull` @@ -127,13 +126,14 @@ Filter could be composed with: - `LessThanOrEqual` - `Like` - `Not` +- `OrX` #### Filtering with arrays -The `All` and `Any` filters have a `withCriteriaArray()` method, which allows you to define filters with arrays. +The `AndX` and `OrX` filters have a `withCriteriaArray()` method, which allows you to define filters with arrays. ```php -$dataReader->withFilter((new All())->withCriteriaArray([ +$dataReader->withFilter((new AndX())->withCriteriaArray([ ['=', 'id', 88], [ 'or', @@ -197,7 +197,7 @@ class OwnIterableNotTwoFilterHandler implements IterableFilterHandlerInterface } // and using it on a data reader -$filter = new All( +$filter = new AndX( new LessThan('id', 8), new OwnNotTwoFilter('id'), ); diff --git a/composer.json b/composer.json index 67d035c8..28c99fe0 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ }, "require-dev": { "maglnet/composer-require-checker": "^4.7.1", - "phpunit/phpunit": "^10.5.46", - "rector/rector": "^2.0.18", + "phpunit/phpunit": "^10.5.48", + "rector/rector": "^2.1.2", "roave/infection-static-analysis-plugin": "^1.35", "spatie/phpunit-watcher": "^1.24", "vimeo/psalm": "^5.26.1 || ^6.10.3" diff --git a/docs/guide/pt-BR/README.md b/docs/guide/pt-BR/README.md index a89ba9e2..2367f8d8 100644 --- a/docs/guide/pt-BR/README.md +++ b/docs/guide/pt-BR/README.md @@ -65,7 +65,7 @@ Para filtrar dados em um leitor de dados implementando `FilterableDataInterface` método `withFilter()`: ```php -$filter = new All( +$filter = new AndX( new GreaterThan('id', 3), new Like('name', 'agent') ); @@ -78,8 +78,7 @@ $data = $reader->read(); O filtro pode ser composto por: -- `All` -- `Any` +- `AndX` - `Between` - `Equals` - `EqualsNull` @@ -91,13 +90,14 @@ O filtro pode ser composto por: - `LessThanOrEqual` - `Like` - `Not` +- `OrX` #### Filtrando com matrizes -Os filtros `All` e `Any` possuem um método `withCriteriaArray()`, que permite definir filtros com arrays. +Os filtros `AndX` e `OrX` possuem um método `withCriteriaArray()`, que permite definir filtros com arrays. ```php -$dataReader->withFilter((new All())->withCriteriaArray([ +$dataReader->withFilter((new AndX())->withCriteriaArray([ ['=', 'id', 88], [ 'or', @@ -161,7 +161,7 @@ class OwnIterableNotTwoFilterHandler implements IterableFilterHandlerInterface } // and using it on a data reader -$filter = new All( +$filter = new AndX( new LessThan('id', 8), new OwnNotTwoFilter('id'), ); diff --git a/src/Reader/Filter/All.php b/src/Reader/Filter/All.php deleted file mode 100644 index 0e971d4a..00000000 --- a/src/Reader/Filter/All.php +++ /dev/null @@ -1,22 +0,0 @@ -withFilter( - * new All( - * new GreaterThan('id', 88), - * new Equals('state', 2), - * new Like('name', 'eva'), - * ) - * ); - * ``` - */ -final class All extends Group -{ -} diff --git a/src/Reader/Filter/AndX.php b/src/Reader/Filter/AndX.php new file mode 100644 index 00000000..e605f7c8 --- /dev/null +++ b/src/Reader/Filter/AndX.php @@ -0,0 +1,36 @@ +withFilter( + * new AndX( + * new GreaterThan('id', 88), + * new Equals('state', 2), + * new Like('name', 'eva'), + * ) + * ); + * ``` + */ +final class AndX implements FilterInterface +{ + /** + * @var FilterInterface[] Sub-filters to use. + */ + public readonly array $filters; + + /** + * @param FilterInterface ...$filters Sub-filters to use. + */ + public function __construct(FilterInterface ...$filters) + { + $this->filters = $filters; + } +} diff --git a/src/Reader/Filter/Any.php b/src/Reader/Filter/Any.php deleted file mode 100644 index 08a92a41..00000000 --- a/src/Reader/Filter/Any.php +++ /dev/null @@ -1,21 +0,0 @@ -withFilter( - * new Any( - * new GreaterThan('id', 88), - * new Equals('state', 2), - * ) - * ); - * ``` - */ -final class Any extends Group -{ -} diff --git a/src/Reader/Filter/Group.php b/src/Reader/Filter/OrX.php similarity index 56% rename from src/Reader/Filter/Group.php rename to src/Reader/Filter/OrX.php index 903ee18c..3034d2f1 100644 --- a/src/Reader/Filter/Group.php +++ b/src/Reader/Filter/OrX.php @@ -7,14 +7,23 @@ use Yiisoft\Data\Reader\FilterInterface; /** - * `Group` filter is an abstract class that allows combining multiple sub-filters. + * `OrX` filter allows combining multiple sub-filters using "OR" operator. + * + * ```php + * $dataReader->withFilter( + * new OrX( + * new GreaterThan('id', 88), + * new Equals('state', 2), + * ) + * ); + * ``` */ -abstract class Group implements FilterInterface +final class OrX implements FilterInterface { /** * @var FilterInterface[] Sub-filters to use. */ - private array $filters; + public readonly array $filters; /** * @param FilterInterface ...$filters Sub-filters to use. @@ -23,12 +32,4 @@ public function __construct(FilterInterface ...$filters) { $this->filters = $filters; } - - /** - * @return FilterInterface[] - */ - public function getFilters(): array - { - return $this->filters; - } } diff --git a/src/Reader/Iterable/FilterHandler/AllHandler.php b/src/Reader/Iterable/FilterHandler/AndXHandler.php similarity index 70% rename from src/Reader/Iterable/FilterHandler/AllHandler.php rename to src/Reader/Iterable/FilterHandler/AndXHandler.php index b13ddce2..444f0704 100644 --- a/src/Reader/Iterable/FilterHandler/AllHandler.php +++ b/src/Reader/Iterable/FilterHandler/AndXHandler.php @@ -4,27 +4,27 @@ namespace Yiisoft\Data\Reader\Iterable\FilterHandler; -use Yiisoft\Data\Reader\Filter\All; +use Yiisoft\Data\Reader\Filter\AndX; use Yiisoft\Data\Reader\FilterInterface; use Yiisoft\Data\Reader\Iterable\Context; use Yiisoft\Data\Reader\Iterable\IterableFilterHandlerInterface; /** - * `All` iterable filter handler allows combining multiple sub-filters. + * `AndX` iterable filter handler allows combining multiple sub-filters. * The filter matches only if all the sub-filters match. */ -final class AllHandler implements IterableFilterHandlerInterface +final class AndXHandler implements IterableFilterHandlerInterface { public function getFilterClass(): string { - return All::class; + return AndX::class; } public function match(object|array $item, FilterInterface $filter, Context $context): bool { - /** @var All $filter */ + /** @var AndX $filter */ - foreach ($filter->getFilters() as $subFilter) { + foreach ($filter->filters as $subFilter) { $filterHandler = $context->getFilterHandler($subFilter::class); if (!$filterHandler->match($item, $subFilter, $context)) { return false; diff --git a/src/Reader/Iterable/FilterHandler/AnyHandler.php b/src/Reader/Iterable/FilterHandler/OrXHandler.php similarity index 71% rename from src/Reader/Iterable/FilterHandler/AnyHandler.php rename to src/Reader/Iterable/FilterHandler/OrXHandler.php index 4657762e..c03b28b8 100644 --- a/src/Reader/Iterable/FilterHandler/AnyHandler.php +++ b/src/Reader/Iterable/FilterHandler/OrXHandler.php @@ -4,27 +4,27 @@ namespace Yiisoft\Data\Reader\Iterable\FilterHandler; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\FilterInterface; use Yiisoft\Data\Reader\Iterable\Context; use Yiisoft\Data\Reader\Iterable\IterableFilterHandlerInterface; /** - * `Any` iterable filter handler allows combining multiple sub-filters. + * `OrX` iterable filter handler allows combining multiple sub-filters. * The filter matches if any of the sub-filters match. */ -final class AnyHandler implements IterableFilterHandlerInterface +final class OrXHandler implements IterableFilterHandlerInterface { public function getFilterClass(): string { - return Any::class; + return OrX::class; } public function match(object|array $item, FilterInterface $filter, Context $context): bool { - /** @var Any $filter */ + /** @var OrX $filter */ - foreach ($filter->getFilters() as $subFilter) { + foreach ($filter->filters as $subFilter) { $filterHandler = $context->getFilterHandler($subFilter::class); if ($filterHandler->match($item, $subFilter, $context)) { return true; diff --git a/src/Reader/Iterable/IterableDataReader.php b/src/Reader/Iterable/IterableDataReader.php index 07d6049a..8891b556 100644 --- a/src/Reader/Iterable/IterableDataReader.php +++ b/src/Reader/Iterable/IterableDataReader.php @@ -12,8 +12,8 @@ use Yiisoft\Data\Reader\DataReaderInterface; use Yiisoft\Data\Reader\FilterHandlerInterface; use Yiisoft\Data\Reader\FilterInterface; -use Yiisoft\Data\Reader\Iterable\FilterHandler\AllHandler; -use Yiisoft\Data\Reader\Iterable\FilterHandler\AnyHandler; +use Yiisoft\Data\Reader\Iterable\FilterHandler\AndXHandler; +use Yiisoft\Data\Reader\Iterable\FilterHandler\OrXHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\BetweenHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\EqualsHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\EqualsNullHandler; @@ -75,8 +75,8 @@ public function __construct( private readonly ValueReaderInterface $valueReader = new FlatValueReader(), ) { $this->coreFilterHandlers = $this->prepareFilterHandlers([ - new AllHandler(), - new AnyHandler(), + new AndXHandler(), + new OrXHandler(), new BetweenHandler(), new EqualsHandler(), new EqualsNullHandler(), diff --git a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php similarity index 63% rename from tests/Common/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php rename to tests/Common/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php index 4169942e..6ff53592 100644 --- a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAllTestCase.php +++ b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAndXTestCase.php @@ -4,17 +4,17 @@ namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter; -use Yiisoft\Data\Reader\Filter\All; +use Yiisoft\Data\Reader\Filter\AndX; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase; -abstract class BaseReaderWithAllTestCase extends BaseReaderTestCase +abstract class BaseReaderWithAndXTestCase extends BaseReaderTestCase { public function testWithReader(): void { $reader = $this ->getReader() - ->withFilter(new All(new Equals('balance', 100), new Equals('email', 'seed@beat'))); + ->withFilter(new AndX(new Equals('balance', 100), new Equals('email', 'seed@beat'))); $this->assertFixtures([2], $reader->read()); } } diff --git a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithNotTestCase.php b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithNotTestCase.php index 923abb44..9baf6fb7 100644 --- a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithNotTestCase.php +++ b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithNotTestCase.php @@ -5,8 +5,8 @@ namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter; use PHPUnit\Framework\Attributes\DataProvider; -use Yiisoft\Data\Reader\Filter\All; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\AndX; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\Filter\Between; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\EqualsNull; @@ -24,8 +24,8 @@ abstract class BaseReaderWithNotTestCase extends BaseReaderTestCase public static function dataWithReader(): array { return [ - 'all' => [new Not(new All(new Equals('number', 1), new Equals('number', 2))), range(1, 5)], - 'any' => [new Not(new Any(new Equals('number', 1), new Equals('number', 2))), range(3, 5)], + 'all' => [new Not(new AndX(new Equals('number', 1), new Equals('number', 2))), range(1, 5)], + 'any' => [new Not(new OrX(new Equals('number', 1), new Equals('number', 2))), range(3, 5)], 'between' => [new Not(new Between('balance', 10.25, 100.0)), [2, 4]], 'equals' => [new Not(new Equals('number', 1)), range(2, 5)], 'equals null' => [new Not(new EqualsNull('born_at')), [5]], diff --git a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php similarity index 70% rename from tests/Common/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php rename to tests/Common/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php index ca00a1ca..dfe2fc94 100644 --- a/tests/Common/Reader/ReaderWithFilter/BaseReaderWithAnyTestCase.php +++ b/tests/Common/Reader/ReaderWithFilter/BaseReaderWithOrXTestCase.php @@ -4,21 +4,21 @@ namespace Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter; -use Yiisoft\Data\Reader\Filter\All; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\AndX; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\GreaterThan; use Yiisoft\Data\Reader\Filter\LessThan; use Yiisoft\Data\Reader\Filter\Like; use Yiisoft\Data\Tests\Common\Reader\BaseReaderTestCase; -abstract class BaseReaderWithAnyTestCase extends BaseReaderTestCase +abstract class BaseReaderWithOrXTestCase extends BaseReaderTestCase { public function testWithReader(): void { $reader = $this ->getReader() - ->withFilter(new Any(new Equals('number', 2), new Equals('number', 3))); + ->withFilter(new OrX(new Equals('number', 2), new Equals('number', 3))); $this->assertFixtures([1, 2], $reader->read()); } @@ -27,8 +27,8 @@ public function testNested(): void $reader = $this ->getReader() ->withFilter( - new Any( - new All(new GreaterThan('balance', 500), new LessThan('number', 5)), + new OrX( + new AndX(new GreaterThan('balance', 500), new LessThan('number', 5)), new Like('email', 'st'), ) ); diff --git a/tests/Reader/Iterable/FilterHandler/AllHandlerTest.php b/tests/Reader/Iterable/FilterHandler/AndXHandlerTest.php similarity index 90% rename from tests/Reader/Iterable/FilterHandler/AllHandlerTest.php rename to tests/Reader/Iterable/FilterHandler/AndXHandlerTest.php index 597b6390..2c399749 100644 --- a/tests/Reader/Iterable/FilterHandler/AllHandlerTest.php +++ b/tests/Reader/Iterable/FilterHandler/AndXHandlerTest.php @@ -6,12 +6,12 @@ use LogicException; use PHPUnit\Framework\Attributes\DataProvider; -use Yiisoft\Data\Reader\Filter\All; +use Yiisoft\Data\Reader\Filter\AndX; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\GreaterThanOrEqual; use Yiisoft\Data\Reader\Filter\LessThanOrEqual; use Yiisoft\Data\Reader\Iterable\Context; -use Yiisoft\Data\Reader\Iterable\FilterHandler\AllHandler; +use Yiisoft\Data\Reader\Iterable\FilterHandler\AndXHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\EqualsHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\GreaterThanOrEqualHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\LessThanOrEqualHandler; @@ -19,7 +19,7 @@ use Yiisoft\Data\Tests\Support\CustomFilter\FilterWithoutHandler; use Yiisoft\Data\Tests\TestCase; -final class AllHandlerTest extends TestCase +final class AndXHandlerTest extends TestCase { public static function matchDataProvider(): array { @@ -66,7 +66,7 @@ public static function matchDataProvider(): array #[DataProvider('matchDataProvider')] public function testMatch(bool $expected, array $filters, array $filterHandlers): void { - $handler = new AllHandler(); + $handler = new AndXHandler(); $item = [ 'id' => 1, @@ -75,14 +75,14 @@ public function testMatch(bool $expected, array $filters, array $filterHandlers) $context = new Context($filterHandlers, new FlatValueReader()); - $this->assertSame($expected, $handler->match($item, new All(...$filters), $context)); + $this->assertSame($expected, $handler->match($item, new AndX(...$filters), $context)); } public function testMatchFailIfFilterOperatorIsNotSupported(): void { - $handler = new AllHandler(); + $handler = new AndXHandler(); $item = ['id' => 1]; - $filter = new All(new FilterWithoutHandler()); + $filter = new AndX(new FilterWithoutHandler()); $context = new Context([], new FlatValueReader()); $this->expectException(LogicException::class); diff --git a/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php b/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php index deaed0d1..25c923b3 100644 --- a/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php +++ b/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php @@ -6,12 +6,12 @@ use LogicException; use PHPUnit\Framework\Attributes\DataProvider; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\GreaterThanOrEqual; use Yiisoft\Data\Reader\Filter\LessThanOrEqual; use Yiisoft\Data\Reader\Iterable\Context; -use Yiisoft\Data\Reader\Iterable\FilterHandler\AnyHandler; +use Yiisoft\Data\Reader\Iterable\FilterHandler\OrXHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\EqualsHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\GreaterThanOrEqualHandler; use Yiisoft\Data\Reader\Iterable\FilterHandler\LessThanOrEqualHandler; @@ -19,7 +19,7 @@ use Yiisoft\Data\Tests\Support\CustomFilter\FilterWithoutHandler; use Yiisoft\Data\Tests\TestCase; -final class AnyHandlerTest extends TestCase +final class OrXHandlerTest extends TestCase { public static function matchDataProvider(): array { @@ -65,7 +65,7 @@ public static function matchDataProvider(): array #[DataProvider('matchDataProvider')] public function testMatch(bool $expected, array $filters, array $filterHandlers): void { - $handler = new AnyHandler(); + $handler = new OrXHandler(); $item = [ 'id' => 1, @@ -74,14 +74,14 @@ public function testMatch(bool $expected, array $filters, array $filterHandlers) $context = new Context($filterHandlers, new FlatValueReader()); - $this->assertSame($expected, $handler->match($item, new Any(...$filters), $context)); + $this->assertSame($expected, $handler->match($item, new OrX(...$filters), $context)); } public function testMatchFailIfFilterOperatorIsNotSupported(): void { - $handler = new AnyHandler(); + $handler = new OrXHandler(); $item = ['id' => 1]; - $filter = new Any(new FilterWithoutHandler()); + $filter = new OrX(new FilterWithoutHandler()); $context = new Context([], new FlatValueReader()); $this->expectException(LogicException::class); diff --git a/tests/Reader/Iterable/IterableDataReaderTest.php b/tests/Reader/Iterable/IterableDataReaderTest.php index e633ac03..06c49bca 100644 --- a/tests/Reader/Iterable/IterableDataReaderTest.php +++ b/tests/Reader/Iterable/IterableDataReaderTest.php @@ -9,8 +9,8 @@ use InvalidArgumentException; use LogicException; use Yiisoft\Data\Reader\DataReaderException; -use Yiisoft\Data\Reader\Filter\All; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\AndX; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\Filter\Equals; use Yiisoft\Data\Reader\Filter\GreaterThan; use Yiisoft\Data\Reader\Filter\GreaterThanOrEqual; @@ -307,9 +307,9 @@ public function testNotFiltering(): void ], $reader->read()); } - public function testAnyFiltering(): void + public function testOrXFiltering(): void { - $filter = new Any( + $filter = new OrX( new Equals('id', 1), new Equals('id', 2) ); @@ -322,9 +322,9 @@ public function testAnyFiltering(): void ], $reader->read()); } - public function testAllFiltering(): void + public function testAndXFiltering(): void { - $filter = new All( + $filter = new AndX( new GreaterThan('id', 3), new Like('name', 'Agent') ); @@ -401,7 +401,7 @@ public function testGeneratorAsDataSet(): void public function testCustomFilter(): void { - $filter = new All(new GreaterThan('id', 0), new Digital('name')); + $filter = new AndX(new GreaterThan('id', 0), new Digital('name')); $reader = (new IterableDataReader(self::DEFAULT_DATASET)) ->withAddedFilterHandlers(new DigitalHandler()) ->withFilter($filter); diff --git a/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAllTest.php b/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAndXTest.php similarity index 69% rename from tests/Reader/Iterable/ReaderWithFilter/ReaderWithAllTest.php rename to tests/Reader/Iterable/ReaderWithFilter/ReaderWithAndXTest.php index 30bca5da..fe5babd8 100644 --- a/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAllTest.php +++ b/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAndXTest.php @@ -4,9 +4,9 @@ namespace Yiisoft\Data\Tests\Reader\Iterable\ReaderWithFilter; -use Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAllTestCase; +use Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAndXTestCase; -final class ReaderWithAllTest extends BaseReaderWithAllTestCase +final class ReaderWithAndXTest extends BaseReaderWithAndXTestCase { use ReaderTrait; } diff --git a/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAnyTest.php b/tests/Reader/Iterable/ReaderWithFilter/ReaderWithOrXTest.php similarity index 67% rename from tests/Reader/Iterable/ReaderWithFilter/ReaderWithAnyTest.php rename to tests/Reader/Iterable/ReaderWithFilter/ReaderWithOrXTest.php index 70955681..8345bb5e 100644 --- a/tests/Reader/Iterable/ReaderWithFilter/ReaderWithAnyTest.php +++ b/tests/Reader/Iterable/ReaderWithFilter/ReaderWithOrXTest.php @@ -4,14 +4,14 @@ namespace Yiisoft\Data\Tests\Reader\Iterable\ReaderWithFilter; -use Yiisoft\Data\Reader\Filter\All; -use Yiisoft\Data\Reader\Filter\Any; +use Yiisoft\Data\Reader\Filter\AndX; +use Yiisoft\Data\Reader\Filter\OrX; use Yiisoft\Data\Reader\Filter\GreaterThan; use Yiisoft\Data\Reader\Filter\LessThan; use Yiisoft\Data\Reader\Filter\Like; -use Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithAnyTestCase; +use Yiisoft\Data\Tests\Common\Reader\ReaderWithFilter\BaseReaderWithOrXTestCase; -final class ReaderWithAnyTest extends BaseReaderWithAnyTestCase +final class ReaderWithOrXTest extends BaseReaderWithOrXTestCase { use ReaderTrait; @@ -20,8 +20,8 @@ public function testNested(): void $reader = $this ->getReader() ->withFilter( - new Any( - new All(new GreaterThan('balance', 500), new LessThan('number', 5)), + new OrX( + new AndX(new GreaterThan('balance', 500), new LessThan('number', 5)), new Like('email', 'st'), ) ); From 7d6da816c20cb1c7ef3488626735a64b843448d2 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 24 Jul 2025 12:03:04 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php b/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php index 25c923b3..fb2f06d8 100644 --- a/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php +++ b/tests/Reader/Iterable/FilterHandler/AnyHandlerTest.php @@ -19,7 +19,7 @@ use Yiisoft\Data\Tests\Support\CustomFilter\FilterWithoutHandler; use Yiisoft\Data\Tests\TestCase; -final class OrXHandlerTest extends TestCase +final class AnyHandlerTest extends TestCase { public static function matchDataProvider(): array {