Skip to content
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
27 changes: 27 additions & 0 deletions .github/workflows/rector-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Rector + PHP CS Fixer

on:
pull_request_target:
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/rector-cs.yml'
- 'composer.json'
- 'rector.php'
- '.php-cs-fixer.dist.php'

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
rector:
uses: yiisoft/actions/.github/workflows/rector-cs.yml@master
secrets:
token: ${{ secrets.YIISOFT_GITHUB_TOKEN }}
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
php: '8.1'
24 changes: 0 additions & 24 deletions .github/workflows/rector.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ composer.phar
/phpunit.phar
/phpunit.xml
/.phpunit.cache

# PHP CS Fixer
/.php-cs-fixer.cache
/.php-cs-fixer.php
34 changes: 34 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = (new Finder())->in([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

return (new Config())
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@PER-CS3.0' => true,
'no_unused_imports' => true,
'ordered_class_elements' => true,
'class_attributes_separation' => ['elements' => ['method' => 'one']],
'declare_strict_types' => true,
'native_function_invocation' => true,
'native_constant_invocation' => true,
'fully_qualified_strict_types' => [
'import_symbols' => true
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
])
->setFinder($finder);
85 changes: 0 additions & 85 deletions .styleci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## 1.0.1 under development

- no changes in this release.
- Enh #50: Explicitly import classes, functions, and constants in "use" section (@mspirkov)

## 1.0.0 December 21, 2025

- Initial release.
- Initial release.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"yiisoft/data": "^2.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.92.5",
"maglnet/composer-require-checker": "^4.7",
"phpunit/phpunit": "^10.5",
"rector/rector": "^2.1.5",
Expand Down
4 changes: 3 additions & 1 deletion src/Reader/Cache/CachedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Yiisoft\Data\Cycle\Reader\Cache;

use Generator;

final class CachedCollection
{
private ?iterable $collection = null;
Expand All @@ -26,7 +28,7 @@ public function getCollection(): ?iterable
return $this->collection;
}

public function getGenerator(): \Generator
public function getGenerator(): Generator
{
if ($this->collection !== null) {
yield from $this->collection;
Expand Down
4 changes: 1 addition & 3 deletions src/Reader/Cache/CachedCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ final class CachedCount
*/
private ?int $count = null;

public function __construct(private ?Countable $collection)
{
}
public function __construct(private ?Countable $collection) {}

/**
* @psalm-internal Yiisoft\Data\Cycle\Reader
Expand Down
64 changes: 35 additions & 29 deletions src/Reader/EntityReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
use Yiisoft\Data\Reader\Sort;
use Yiisoft\Data\Cycle\Reader\Cache\CachedCollection;
use Yiisoft\Data\Cycle\Reader\Cache\CachedCount;
use Override;

use function array_key_exists;
use function is_int;

use const SORT_DESC;

/**
* @template TKey as array-key
Expand Down Expand Up @@ -78,7 +84,7 @@ public function __construct(Select|SelectQuery $query, array $extraFilterHandler
$this->filter = new All();
}

#[\Override]
#[Override]
public function getSort(): ?Sort
{
return $this->sorting;
Expand All @@ -87,7 +93,7 @@ public function getSort(): ?Sort
/**
* @psalm-mutation-free
*/
#[\Override]
#[Override]
public function withLimit(?int $limit): static
{
/** @psalm-suppress DocblockTypeContradiction */
Expand All @@ -105,7 +111,7 @@ public function withLimit(?int $limit): static
/**
* @psalm-mutation-free
*/
#[\Override]
#[Override]
public function withOffset(int $offset): static
{
$new = clone $this;
Expand All @@ -119,7 +125,7 @@ public function withOffset(int $offset): static
/**
* @psalm-mutation-free
*/
#[\Override]
#[Override]
public function withSort(?Sort $sort): static
{
$new = clone $this;
Expand All @@ -134,7 +140,7 @@ public function withSort(?Sort $sort): static
/**
* @psalm-mutation-free
*/
#[\Override]
#[Override]
public function withFilter(FilterInterface $filter): static
{
$new = clone $this;
Expand All @@ -148,13 +154,13 @@ public function withFilter(FilterInterface $filter): static
return $new;
}

#[\Override]
#[Override]
public function count(): int
{
return $this->countCache->getCount();
}

#[\Override]
#[Override]
public function read(): iterable
{
if ($this->itemsCache->getCollection() === null) {
Expand All @@ -164,8 +170,8 @@ public function read(): iterable
return $this->itemsCache->getCollection();
}

#[\Override]
public function readOne(): null|array|object
#[Override]
public function readOne(): array|object|null
{
if (!$this->oneItemCache->isCollected()) {
$item = $this->itemsCache->isCollected()
Expand All @@ -182,7 +188,7 @@ public function readOne(): null|array|object
/**
* Get Iterator without caching
*/
#[\Override]
#[Override]
public function getIterator(): Generator
{
yield from $this->itemsCache->getCollection() ?? $this->buildSelectQuery()->getIterator();
Expand All @@ -191,7 +197,25 @@ public function getIterator(): Generator
public function getSql(): string
{
$query = $this->buildSelectQuery();
return (string)($query instanceof Select ? $query->buildQuery() : $query);
return (string) ($query instanceof Select ? $query->buildQuery() : $query);
}

#[Override]
public function getFilter(): FilterInterface
{
return $this->filter;
}

#[Override]
public function getLimit(): ?int
{
return $this->limit;
}

#[Override]
public function getOffset(): int
{
return $this->offset;
}

private function setFilterHandlers(QueryBuilderFilterHandler ...$filterHandlers): void
Expand Down Expand Up @@ -254,22 +278,4 @@ private function normalizeSortingCriteria(array $criteria): array

return $criteria;
}

#[\Override]
public function getFilter(): FilterInterface
{
return $this->filter;
}

#[\Override]
public function getLimit(): ?int
{
return $this->limit;
}

#[\Override]
public function getOffset(): int
{
return $this->offset;
}
}
5 changes: 3 additions & 2 deletions src/Reader/FilterHandler/AllHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
use Yiisoft\Data\Cycle\Reader\QueryBuilderFilterHandler;
use Yiisoft\Data\Reader\Filter\All;
use Yiisoft\Data\Reader\FilterInterface;
use Override;

final class AllHandler implements QueryBuilderFilterHandler
{
#[\Override]
#[Override]
public function getFilterClass(): string
{
return All::class;
}

#[\Override]
#[Override]
public function getAsWhereArguments(FilterInterface $filter, array $handlers): array
{
/** @var All $filter */
Expand Down
Loading
Loading