From 6a823ee0498286cd8d16c66dd3ee8a7cf2ff1521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Wed, 4 Jun 2025 13:07:37 +0300 Subject: [PATCH 1/3] Fixed Readme.md example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ebb9a7..139e803 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ Alternatively, you can manually include the files from the `src/` directory. Here is a basic example of how to use the Criteria library: ```php -use Imponeer\Criteria\CriteriaItem; -use Imponeer\Criteria\CriteriaCompo; +use Imponeer\Database\Criteria\CriteriaItem; +use Imponeer\Database\Criteria\CriteriaCompo; $criteria = new CriteriaCompo(); $criteria->add(new CriteriaItem('status', 'active')); From b9789e13a67fb31ba7a761dfc670033ad24b1bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Wed, 4 Jun 2025 13:08:45 +0300 Subject: [PATCH 2/3] Improvement visible column in tests --- src/CriteriaCompo.php | 9 --------- src/CriteriaElement.php | 9 +++++++++ src/CriteriaItem.php | 8 -------- src/Traits/PartialResultsTrait.php | 2 -- tests/CriteriaItemTest.php | 4 ++-- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/CriteriaCompo.php b/src/CriteriaCompo.php index 10a9590..68d7242 100644 --- a/src/CriteriaCompo.php +++ b/src/CriteriaCompo.php @@ -5,7 +5,6 @@ use Exception; use Imponeer\Database\Criteria\Enum\Condition; use IteratorAggregate; -use Stringable; use Traversable; /** @@ -109,12 +108,4 @@ public function render(bool $withBindVariables = false): ?string return $ret; } - - /** - * @throws Exception - */ - public function __toString(): string - { - return $this->render() . 'A'; - } } diff --git a/src/CriteriaElement.php b/src/CriteriaElement.php index 35c58f1..086102e 100644 --- a/src/CriteriaElement.php +++ b/src/CriteriaElement.php @@ -2,6 +2,7 @@ namespace Imponeer\Database\Criteria; +use Exception; use Imponeer\Database\Criteria\Traits\GroupByTrait; use Imponeer\Database\Criteria\Traits\OrderByTrait; use Imponeer\Database\Criteria\Traits\PartialResultsTrait; @@ -89,4 +90,12 @@ public function __isset(string $name): bool default => false, }; } + + /** + * @throws Exception + */ + public function __toString(): string + { + return $this->render(true); + } } diff --git a/src/CriteriaItem.php b/src/CriteriaItem.php index d911944..1a6db60 100644 --- a/src/CriteriaItem.php +++ b/src/CriteriaItem.php @@ -232,12 +232,4 @@ private function isEmptyArrayButNotNullComparison(mixed $value): bool ComparisonOperator::NOT_BETWEEN, ], true); } - - /** - * @throws JsonException - */ - public function __toString(): string - { - return $this->render(); - } } diff --git a/src/Traits/PartialResultsTrait.php b/src/Traits/PartialResultsTrait.php index 4cae2f6..1b34b62 100644 --- a/src/Traits/PartialResultsTrait.php +++ b/src/Traits/PartialResultsTrait.php @@ -40,7 +40,6 @@ public function setLimit(int $limit = 0): self * Gets from what record number to return results (counting starts from 0) * * @noinspection MethodShouldBeFinalInspection - * @noinspection PhpDocSignatureInspection */ public function getStart(): int { @@ -53,7 +52,6 @@ public function getStart(): int * @param int $start Sets start position * * @noinspection MethodShouldBeFinalInspection - * @noinspection PhpDocSignatureInspection */ public function setStart(int $start = 0): self { diff --git a/tests/CriteriaItemTest.php b/tests/CriteriaItemTest.php index 78b24b7..6a867f2 100644 --- a/tests/CriteriaItemTest.php +++ b/tests/CriteriaItemTest.php @@ -19,14 +19,14 @@ class CriteriaItemTest extends TestCase * Gets all possible comparison operators enums * * @return array - * @throws RandomException + * * @throws JsonException */ final public static function provideComparisonOperators(): array { $faker = Factory::create(); - $column = $faker->sha1(); + $column = 'field_' . $faker->word(); $specialOperators = [ ComparisonOperator::BETWEEN->name, ComparisonOperator::NOT_BETWEEN->name, From ce1ed3adaf843160cab9ec203f9a32f2d7b54d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimondas=20Rimkevi=C4=8Dius?= Date: Wed, 4 Jun 2025 13:16:01 +0300 Subject: [PATCH 3/3] @coderabbitai suggested change --- src/CriteriaElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CriteriaElement.php b/src/CriteriaElement.php index 086102e..1d45cda 100644 --- a/src/CriteriaElement.php +++ b/src/CriteriaElement.php @@ -96,6 +96,6 @@ public function __isset(string $name): bool */ public function __toString(): string { - return $this->render(true); + return $this->render(true) ?? ''; } }