Skip to content

Commit

Permalink
chore: drop support for php < 8.1, drop chronos requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
alekitto committed Sep 25, 2023
1 parent 591d744 commit 7c9fcf4
Show file tree
Hide file tree
Showing 31 changed files with 98 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cscheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "7.4"
php-version: "8.1"
tools: cs2pr

- name: Install dependencies with composer
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: "8.1"
php-version: "8.2"
tools: cs2pr

- name: Install dependencies with composer
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
- ''

php_version:
- '7.4'
- '8.0'
- '8.1'
- '8.2'

name: PHP ${{ matrix.php_version }}
steps:
Expand Down
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
"csfix": "vendor/bin/phpcbf --standard=Solido src/"
},
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-pdo": "*"
},
"require-dev": {
"composer-runtime-api": "^2",
"cakephp/chronos": "^1.2",
"doctrine/dbal": "^3.2",
"doctrine/mongodb-odm": "^2.0",
"doctrine/mongodb-odm": ">=2.0,<2.5",
"doctrine/orm": "^2.7",
"doctrine/phpcr-odm": "^1.5",
"giggsey/libphonenumber-for-php": "^8.10",
Expand All @@ -41,7 +40,7 @@
"refugis/elastica-odm": "^2.0@dev",
"roave/security-advisories": "dev-master",
"solido/php-coding-standards": "dev-master",
"symfony/cache": "^4.2 || ^5.0 || ^6.0"
"symfony/cache": "^5.4 || ^6.0"
},
"autoload": {
"psr-4": {
Expand All @@ -54,8 +53,8 @@
}
},
"conflict": {
"doctrine/orm": "<2.9",
"doctrine/dbal": "<3.0 || >=4.0"
"doctrine/dbal": "<3.0 || >=4.0",
"doctrine/orm": "<2.9"
},
"config": {
"sort-packages": true,
Expand Down
18 changes: 4 additions & 14 deletions src/DBAL/DummyResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@
use function count;
use function reset;

/**
* @internal The class is internal to the caching layer implementation.
*/
/** @internal The class is internal to the caching layer implementation. */
final class DummyResult implements Result
{
/** @var mixed[] */
private array $data;
private int $columnCount = 0;
private int $num = 0;

/**
* @param mixed[] $data
*/
public function __construct(array $data, ?int $columnCount = null)
/** @param mixed[] $data */
public function __construct(private array $data, int|null $columnCount = null)
{
$this->data = $data;
if (count($data) === 0) {
return;
}
Expand Down Expand Up @@ -109,10 +102,7 @@ public function free(): void
$this->data = [];
}

/**
* @return false|mixed
*/
private function fetch()
private function fetch(): mixed
{
if (! isset($this->data[$this->num])) {
return false;
Expand Down
14 changes: 3 additions & 11 deletions src/DBAL/DummyStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,12 @@
*/
class DummyStatement implements IteratorAggregate, Statement, Result
{
/** @var mixed[] */
private array $data;
private int $columnCount;
private int $num;

/**
* @param mixed[] $data
*/
public function __construct(array $data, ?int $columnCount = null)
/** @param mixed[] $data */
public function __construct(private array $data, int|null $columnCount = null)
{
$this->data = $data;
$this->columnCount = $columnCount ?? count($data[0] ?? []);
$this->num = 0;
}
Expand Down Expand Up @@ -155,10 +150,7 @@ public function rowCount(): int
return count($this->data);
}

/**
* @return mixed|false
*/
private function doFetch()
private function doFetch(): mixed
{
if (! isset($this->data[$this->num])) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/DBAL/IteratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait IteratorTrait
use BaseIteratorTrait;

private QueryBuilder $queryBuilder;
private ?int $totalCount;
private int|null $totalCount;

public function count(): int
{
Expand Down
10 changes: 3 additions & 7 deletions src/IteratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ trait IteratorTrait

/**
* The current element from the underlying iterator.
*
* @var mixed
*/
private $currentElement;
private mixed $currentElement;

/**
* The current element, which results by the application
* of the apply function.
*
* @var mixed
*/
private $current;
private mixed $current;

public function apply(?callable $callable = null): ObjectIteratorInterface
public function apply(callable|null $callable = null): ObjectIteratorInterface
{
if ($callable === null) {
$callable = static function ($val) {
Expand Down
8 changes: 3 additions & 5 deletions src/ODM/MongoDB/Document/TimeSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Refugis\DoctrineExtra\TimeSpan\TimeSpanTrait;

/**
* @ODM\EmbeddedDocument()
*/
/** @ODM\EmbeddedDocument() */
class TimeSpan
{
use TimeSpanTrait;

/** @ODM\Field(type="date") */
private ?DateTimeImmutable $start; // phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
private DateTimeImmutable|null $start; // phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty

/** @ODM\Field(type="date") */
private ?DateTimeImmutable $end; // phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
private DateTimeImmutable|null $end; // phpcs:ignore SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty
}
6 changes: 2 additions & 4 deletions src/ODM/MongoDB/DocumentIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DocumentIterator implements ObjectIteratorInterface
/** @var Iterator<object> */
private Iterator $internalIterator;
private Builder $queryBuilder;
private ?int $totalCount;
private int|null $totalCount;

public function __construct(Builder $queryBuilder)
{
Expand Down Expand Up @@ -71,9 +71,7 @@ public function rewind(): void
$this->currentElement = $this->internalIterator->current();
}

/**
* @return Iterator<object>
*/
/** @return Iterator<object> */
private function getIterator(): Iterator
{
if (isset($this->internalIterator)) {
Expand Down
21 changes: 11 additions & 10 deletions src/ODM/MongoDB/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Refugis\DoctrineExtra\ODM\MongoDB;

use Doctrine\ODM\MongoDB\LockMode;
use Doctrine\ODM\MongoDB\Query\Builder;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository as BaseRepository;
use Refugis\DoctrineExtra\ObjectIteratorInterface;
Expand Down Expand Up @@ -41,7 +42,7 @@ public function count(array $criteria = []): int
/**
* {@inheritdoc}
*/
public function findOneByCached(array $criteria, ?array $orderBy = null, int $ttl = 28800): ?object
public function findOneByCached(array $criteria, array|null $orderBy = null, int $ttl = 28800): object|null
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->limit(1);
Expand All @@ -58,10 +59,10 @@ public function findOneByCached(array $criteria, ?array $orderBy = null, int $tt
*/
public function findByCached(
array $criteria,
?array $orderBy = null,
?int $limit = null,
?int $offset = null,
int $ttl = 28800
array|null $orderBy = null,
int|null $limit = null,
int|null $offset = null,
int $ttl = 28800,
): array {
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
// This is commented due to the missing cache part in doctrine/mongo-odm
Expand All @@ -73,9 +74,9 @@ public function findByCached(
/**
* {@inheritdoc}
*/
public function get($id, $lockMode = 0, $lockVersion = null): object
public function get(mixed $id, int|null $lockMode = null, int|null $lockVersion = null): object
{
$document = $this->find($id, $lockMode, $lockVersion);
$document = $this->find($id, $lockMode ?? LockMode::NONE, $lockVersion);
if ($document === null) {
throw new Exception\NoResultException();
}
Expand All @@ -86,7 +87,7 @@ public function get($id, $lockMode = 0, $lockVersion = null): object
/**
* {@inheritdoc}
*/
public function getOneBy(array $criteria, ?array $orderBy = null): object
public function getOneBy(array $criteria, array|null $orderBy = null): object
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->limit(1);
Expand All @@ -105,7 +106,7 @@ public function getOneBy(array $criteria, ?array $orderBy = null): object
/**
* {@inheritdoc}
*/
public function getOneByCached(array $criteria, ?array $orderBy = null, int $ttl = 28800): object
public function getOneByCached(array $criteria, array|null $orderBy = null, int $ttl = 28800): object
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->limit(1);
Expand All @@ -128,7 +129,7 @@ public function getOneByCached(array $criteria, ?array $orderBy = null, int $ttl
* @param array<string, mixed> $criteria
* @param array<string, string>|null $orderBy
*/
private function buildQueryBuilderForCriteria(array $criteria, ?array $orderBy = null): Builder
private function buildQueryBuilderForCriteria(array $criteria, array|null $orderBy = null): Builder
{
$qb = $this->createQueryBuilder();

Expand Down
2 changes: 1 addition & 1 deletion src/ODM/MongoDB/Exception/NonUniqueResultException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NonUniqueResultException extends MongoDBException implements NonUniqueResu
{
private const DEFAULT_MESSAGE = 'More than one result was found for query although one document or none was expected.';

public function __construct(?string $message = null)
public function __construct(string|null $message = null)
{
parent::__construct($message ?? self::DEFAULT_MESSAGE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ODM/PhpCr/DocumentIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private function getIterator(): Iterator
try {
/* @phpstan-ignore-next-line */
$this->internalIterator = $query->iterate();
} catch (QueryException $e) {
} catch (QueryException) {
$result = $query->getResult();

/* @phpstan-ignore-next-line */
Expand Down
20 changes: 10 additions & 10 deletions src/ODM/PhpCr/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function count(array $criteria = []): int
/**
* {@inheritdoc}
*/
public function find($id): ?object
public function find(mixed $id): object|null
{
return parent::find($id);
}

/**
* {@inheritdoc}
*/
public function findOneByCached(array $criteria, ?array $orderBy = null, int $ttl = 28800): ?object
public function findOneByCached(array $criteria, array|null $orderBy = null, int $ttl = 28800): object|null
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->setMaxResults(1);
Expand All @@ -72,10 +72,10 @@ public function findOneByCached(array $criteria, ?array $orderBy = null, int $tt
*/
public function findByCached(
array $criteria,
?array $orderBy = null,
?int $limit = null,
?int $offset = null,
int $ttl = 28800
array|null $orderBy = null,
int|null $limit = null,
int|null $offset = null,
int $ttl = 28800,
): iterable {
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);

Expand All @@ -88,7 +88,7 @@ public function findByCached(
/**
* {@inheritdoc}
*/
public function get($id, $lockMode = null, $lockVersion = null): object
public function get(mixed $id, int|null $lockMode = null, int|null $lockVersion = null): object
{
/** @var T | null $document */ // phpcs:ignore
$document = $this->find($id);
Expand All @@ -102,7 +102,7 @@ public function get($id, $lockMode = null, $lockVersion = null): object
/**
* {@inheritdoc}
*/
public function getOneBy(array $criteria, ?array $orderBy = null): object
public function getOneBy(array $criteria, array|null $orderBy = null): object
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->setMaxResults(1);
Expand All @@ -119,7 +119,7 @@ public function getOneBy(array $criteria, ?array $orderBy = null): object
/**
* {@inheritdoc}
*/
public function getOneByCached(array $criteria, ?array $orderBy = null, int $ttl = 28800): object
public function getOneByCached(array $criteria, array|null $orderBy = null, int $ttl = 28800): object
{
$query = $this->buildQueryBuilderForCriteria($criteria, $orderBy);
$query->setMaxResults(1);
Expand All @@ -140,7 +140,7 @@ public function getOneByCached(array $criteria, ?array $orderBy = null, int $ttl
* @param array<string, mixed> $criteria
* @param array<string, string> $orderBy
*/
private function buildQueryBuilderForCriteria(array $criteria, ?array $orderBy = null): QueryBuilder
private function buildQueryBuilderForCriteria(array $criteria, array|null $orderBy = null): QueryBuilder
{
$qb = $this->createQueryBuilder('a');
if (count($criteria) === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/ODM/PhpCr/Exception/NonUniqueResultException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NonUniqueResultException extends RuntimeException implements NonUniqueResu
{
private const DEFAULT_MESSAGE = 'More than one result was found for query although one document or none was expected.';

public function __construct(?string $message = null)
public function __construct(string|null $message = null)
{
parent::__construct($message ?? self::DEFAULT_MESSAGE);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ODM/PhpCr/IteratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait IteratorTrait
use BaseIteratorTrait;

private QueryBuilder $queryBuilder;
private ?int $totalCount;
private int|null $totalCount;

public function count(): int
{
Expand Down
Loading

0 comments on commit 7c9fcf4

Please sign in to comment.