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

Use dev version of Yii Data + increase psalm level to 1 #35

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"url": "https://github.com/sponsors/yiisoft"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0",
"yiisoft/db": "^1.0",
"yiisoft/data": "^1.0"
"yiisoft/data": "dev-master"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand Down
2 changes: 2 additions & 0 deletions src/AbstractQueryDataReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@

public function getPreparedQuery(): QueryInterface
{
$query = $this->applyFilter(clone $this->query);

Check warning on line 143 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ } public function getPreparedQuery() : QueryInterface { - $query = $this->applyFilter(clone $this->query); + $query = $this->applyFilter($this->query); $query = $this->applyHaving($query); if ($this->limit) { $query->limit($this->limit);

Check warning on line 143 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ } public function getPreparedQuery() : QueryInterface { - $query = $this->applyFilter(clone $this->query); + $query = $this->applyFilter($this->query); $query = $this->applyHaving($query); if ($this->limit) { $query->limit($this->limit);
$query = $this->applyHaving($query);

if ($this->limit) {
$query->limit($this->limit);

Check warning on line 147 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $query = $this->applyFilter(clone $this->query); $query = $this->applyHaving($query); if ($this->limit) { - $query->limit($this->limit); + } if ($this->offset) { $query->offset($this->offset);

Check warning on line 147 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $query = $this->applyFilter(clone $this->query); $query = $this->applyHaving($query); if ($this->limit) { - $query->limit($this->limit); + } if ($this->offset) { $query->offset($this->offset);
}

if ($this->offset) {
$query->offset($this->offset);

Check warning on line 151 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $query->limit($this->limit); } if ($this->offset) { - $query->offset($this->offset); + } if ($criteria = $this->sort?->getCriteria()) { $query->addOrderBy($criteria);

Check warning on line 151 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $query->limit($this->limit); } if ($this->offset) { - $query->offset($this->offset); + } if ($criteria = $this->sort?->getCriteria()) { $query->addOrderBy($criteria);
}

if ($criteria = $this->sort?->getCriteria()) {
Expand All @@ -158,7 +158,7 @@
return $query;
}

protected function getHandlerByOperation(string $operation): QueryHandlerInterface

Check warning on line 161 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $query; } - protected function getHandlerByOperation(string $operation) : QueryHandlerInterface + private function getHandlerByOperation(string $operation) : QueryHandlerInterface { if (!isset($this->filterHandlers[$operation])) { throw new RuntimeException(sprintf('Operation "%s" is not supported', $operation));

Check warning on line 161 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $query; } - protected function getHandlerByOperation(string $operation) : QueryHandlerInterface + private function getHandlerByOperation(string $operation) : QueryHandlerInterface { if (!isset($this->filterHandlers[$operation])) { throw new RuntimeException(sprintf('Operation "%s" is not supported', $operation));
{
if (!isset($this->filterHandlers[$operation])) {
throw new RuntimeException(sprintf('Operation "%s" is not supported', $operation));
Expand All @@ -167,7 +167,7 @@
return $this->filterHandlers[$operation];
}

protected function applyFilter(QueryInterface $query): QueryInterface

Check warning on line 170 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $this->filterHandlers[$operation]; } - protected function applyFilter(QueryInterface $query) : QueryInterface + private function applyFilter(QueryInterface $query) : QueryInterface { if ($this->filter !== null) { $query = $this->getHandlerByOperation($this->filter::getOperator())->applyFilter($query, $this->filter);

Check warning on line 170 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $this->filterHandlers[$operation]; } - protected function applyFilter(QueryInterface $query) : QueryInterface + private function applyFilter(QueryInterface $query) : QueryInterface { if ($this->filter !== null) { $query = $this->getHandlerByOperation($this->filter::getOperator())->applyFilter($query, $this->filter);
{
if ($this->filter !== null) {
$query = $this->getHandlerByOperation($this->filter::getOperator())
Expand All @@ -177,7 +177,7 @@
return $query;
}

protected function applyHaving(QueryInterface $query): QueryInterface

Check warning on line 180 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $query; } - protected function applyHaving(QueryInterface $query) : QueryInterface + private function applyHaving(QueryInterface $query) : QueryInterface { if ($this->having !== null) { $query = $this->getHandlerByOperation($this->having::getOperator())->applyHaving($query, $this->having);

Check warning on line 180 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ } return $query; } - protected function applyHaving(QueryInterface $query) : QueryInterface + private function applyHaving(QueryInterface $query) : QueryInterface { if ($this->having !== null) { $query = $this->getHandlerByOperation($this->having::getOperator())->applyHaving($query, $this->having);
{
if ($this->having !== null) {
$query = $this->getHandlerByOperation($this->having::getOperator())
Expand Down Expand Up @@ -206,7 +206,7 @@
*/
public function withLimit(int $limit): static
{
if ($limit < 0) {

Check warning on line 209 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "LessThan": --- Original +++ New @@ @@ */ public function withLimit(int $limit) : static { - if ($limit < 0) { + if ($limit <= 0) { throw new InvalidArgumentException('$limit must not be less than 0.'); } $new = clone $this;

Check warning on line 209 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "LessThan": --- Original +++ New @@ @@ */ public function withLimit(int $limit) : static { - if ($limit < 0) { + if ($limit <= 0) { throw new InvalidArgumentException('$limit must not be less than 0.'); } $new = clone $this;
throw new InvalidArgumentException('$limit must not be less than 0.');
}

Expand Down Expand Up @@ -310,6 +310,7 @@

/**
* @return QueryHandlerInterface[]
* @psalm-return array<string, QueryHandlerInterface>
*/
private function prepareHandlers(QueryHandlerInterface ...$queryHandlers): array
{
Expand Down Expand Up @@ -337,6 +338,7 @@
public function read(): array
{
if ($this->data === null) {
/** @psalm-var array<TKey, TValue> */
$this->data = $this->getPreparedQuery()->all();
}

Expand Down
4 changes: 0 additions & 4 deletions src/Filter/CompareFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

public function withIgnoreNull(bool $ignoreNull = true): static
{
$new = clone $this;

Check warning on line 33 in src/Filter/CompareFilter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ } public function withIgnoreNull(bool $ignoreNull = true) : static { - $new = clone $this; + $new = $this; $new->ignoreNull = $ignoreNull; return $new; }

Check warning on line 33 in src/Filter/CompareFilter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "CloneRemoval": --- Original +++ New @@ @@ } public function withIgnoreNull(bool $ignoreNull = true) : static { - $new = clone $this; + $new = $this; $new->ignoreNull = $ignoreNull; return $new; }
$new->ignoreNull = $ignoreNull;

return $new;
Expand Down Expand Up @@ -58,13 +58,9 @@
return $value;
}

/**
* @psalm-param array<int, mixed> $values
* @return array
*/
protected function formatValues(array $values): array
{
return array_map([$this, 'formatValue'], $values);

Check warning on line 63 in src/Filter/CompareFilter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ } protected function formatValues(array $values) : array { - return array_map([$this, 'formatValue'], $values); + return $values; } public function toCriteriaArray() : array {

Check warning on line 63 in src/Filter/CompareFilter.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.2-ubuntu-latest

Escaped Mutant for Mutator "UnwrapArrayMap": --- Original +++ New @@ @@ } protected function formatValues(array $values) : array { - return array_map([$this, 'formatValue'], $values); + return $values; } public function toCriteriaArray() : array {
}

public function toCriteriaArray(): array
Expand Down
Loading