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

Raise minimal PHP version to 8.1 #42

Merged
merged 2 commits into from
Feb 14, 2024
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -29,4 +31,4 @@ jobs:
os: >-
['ubuntu-latest', 'windows-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2', '8.3']
4 changes: 3 additions & 1 deletion .github/workflows/composer-require-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -30,4 +32,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1']
['8.1', '8.2', '8.3']
4 changes: 3 additions & 1 deletion .github/workflows/mutation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
- 'psalm.xml'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -26,6 +28,6 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.2']
['8.3']
secrets:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.2']
['8.3']
4 changes: 3 additions & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
- 'phpunit.xml.dist'

push:
branches:
- master
paths-ignore:
- 'docs/**'
- 'README.md'
Expand All @@ -28,4 +30,4 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.0', '8.1', '8.2']
['8.1', '8.2', '8.3']
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:

environment:
php:
version: 8.0.18
version: 8.1.25
ini:
xdebug.mode: coverage

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ The package provides `Yiisoft\Db\Query\Query` bindings for generic data abstract

## Requirements

- PHP 7.4 or higher.
- PHP 8.1 or higher.

## Installation

The package could be installed with composer:

```shell
composer require yiisoft/data-db --prefer-dist
composer require yiisoft/data-db
```

## General usage
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^8.0",
"php": "^8.1",
"yiisoft/db": "^1.0",
"yiisoft/data": "dev-master"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
"phpunit/phpunit": "^9.5",
"rector/rector": "^0.19.0",
"phpunit/phpunit": "^9.6",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.14"
"vimeo/psalm": "^5.21"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<file name="src/Filter/*.php" />
Expand Down
4 changes: 3 additions & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Rector\Config\RectorConfig;
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
Expand All @@ -19,11 +20,12 @@

// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_80,
LevelSetList::UP_TO_PHP_81,
]);

$rectorConfig->skip([
ClosureToArrowFunctionRector::class,
JsonThrowOnErrorRector::class,
NullToStrictStringFuncCallArgRector::class,
]);
};
5 changes: 5 additions & 0 deletions src/AbstractQueryDataReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
private ?FilterInterface $having = null;
private int $limit = 0;
private int $offset = 0;

/**
* @psalm-var non-negative-int|null
*/
private ?int $count = null;

/**
Expand Down Expand Up @@ -125,15 +129,16 @@
if ($this->count === null) {
$q = $this->countParam ?? '*';

if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) {

Check warning on line 132 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "Identical": --- Original +++ New @@ @@ { if ($this->count === null) { $q = $this->countParam ?? '*'; - if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) { + if ($q !== '*' && is_array($this->data) && !$this->limit && !$this->offset) { $this->count = count($this->data); } else { $query = $this->getPreparedQuery();

Check warning on line 132 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "LogicalNot": --- Original +++ New @@ @@ { if ($this->count === null) { $q = $this->countParam ?? '*'; - if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) { + if ($q === '*' && is_array($this->data) && $this->limit && !$this->offset) { $this->count = count($this->data); } else { $query = $this->getPreparedQuery();

Check warning on line 132 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "LogicalNot": --- Original +++ New @@ @@ { if ($this->count === null) { $q = $this->countParam ?? '*'; - if ($q === '*' && is_array($this->data) && !$this->limit && !$this->offset) { + if ($q === '*' && is_array($this->data) && !$this->limit && $this->offset) { $this->count = count($this->data); } else { $query = $this->getPreparedQuery();
$this->count = count($this->data);
} else {
$query = $this->getPreparedQuery();
$query->offset(null);

Check warning on line 136 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $this->count = count($this->data); } else { $query = $this->getPreparedQuery(); - $query->offset(null); + $query->limit(null); $query->orderBy(''); /** @psalm-var non-negative-int */
$query->limit(null);

Check warning on line 137 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } else { $query = $this->getPreparedQuery(); $query->offset(null); - $query->limit(null); + $query->orderBy(''); /** @psalm-var non-negative-int */ $this->count = (int) $query->count($q);
$query->orderBy('');

Check warning on line 138 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $query = $this->getPreparedQuery(); $query->offset(null); $query->limit(null); - $query->orderBy(''); + /** @psalm-var non-negative-int */ $this->count = (int) $query->count($q); }

/** @psalm-var non-negative-int */
$this->count = (int) $query->count($q);

Check warning on line 141 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-ubuntu-latest

Escaped Mutant for Mutator "CastInt": --- Original +++ New @@ @@ $query->limit(null); $query->orderBy(''); /** @psalm-var non-negative-int */ - $this->count = (int) $query->count($q); + $this->count = $query->count($q); } } return $this->count;
}
}

Expand All @@ -142,15 +147,15 @@

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

Check warning on line 150 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-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 154 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-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 158 in src/AbstractQueryDataReader.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.3-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 Down
10 changes: 1 addition & 9 deletions src/Filter/CompareFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ abstract class CompareFilter implements FilterInterface
protected bool $ignoreNull = false;
protected ?string $dateTimeFormat = null;

/**
* @param ExpressionInterface|string $column
* @param mixed $value
* @param string|null $table
*/
public function __construct(string|ExpressionInterface $column, protected mixed $value, ?string $table = null)
{
$this->setColumn($column, $table);
Expand All @@ -44,9 +39,6 @@ public function withDateTimeFormat(?string $format): static
return $new;
}

/**
* @return mixed
*/
protected function formatValue(mixed $value): mixed
{
$format = $this->dateTimeFormat ?? static::$mainDateTimeFormat;
Expand All @@ -60,7 +52,7 @@ protected function formatValue(mixed $value): mixed

protected function formatValues(array $values): array
{
return array_map([$this, 'formatValue'], $values);
return array_map($this->formatValue(...), $values);
}

public function toCriteriaArray(): array
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/Exists.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class Exists implements FilterInterface
{
public function __construct(private QueryInterface $query)
public function __construct(private readonly QueryInterface $query)
{
}

Expand Down
Loading