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

Build/rector #126

Merged
merged 35 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b30ad7e
build: rector
priyadi Jul 17, 2024
6a2bad5
rector config
priyadi Jul 17, 2024
50d550e
apply php7.4 rule
priyadi Jul 17, 2024
1b7c83f
apply php80 rule
priyadi Jul 17, 2024
0b3f645
apply php81 rule
priyadi Jul 17, 2024
d8d7bba
apply php82 rule
priyadi Jul 17, 2024
e79e25a
type coverage level 3
priyadi Jul 17, 2024
f493658
type coverage level 45
priyadi Jul 17, 2024
8a6f690
dead code level 15
priyadi Jul 17, 2024
5daa9e2
dead code level 17
priyadi Jul 17, 2024
59c3a5d
exclude pageableinterface from RemoveUselessReturnTagRector
priyadi Jul 17, 2024
3ac056a
deadcode level 20
priyadi Jul 17, 2024
9d6ee12
code fixes
priyadi Jul 17, 2024
1f48c4d
dead code 30
priyadi Jul 17, 2024
8345b99
dead code 41
priyadi Jul 17, 2024
0ec8d76
dead code level 44
priyadi Jul 17, 2024
4bf439a
codequality level 3
priyadi Jul 17, 2024
8b158d0
code quality level 7
priyadi Jul 17, 2024
cf258d3
codequality level 17
priyadi Jul 17, 2024
e18c95b
code quality 21
priyadi Jul 17, 2024
112edba
codequality 22
priyadi Jul 17, 2024
32a6639
code quality 30
priyadi Jul 17, 2024
681c165
code quality 35
priyadi Jul 17, 2024
b0f4f2d
code quality 50
priyadi Jul 17, 2024
89d8fd8
code quality 57
priyadi Jul 17, 2024
c66da63
code quality 59
priyadi Jul 17, 2024
a433f16
code quality 70
priyadi Jul 17, 2024
ebfcd3e
NewlineAfterStatementRector
priyadi Jul 17, 2024
32f8b3c
codingstyle
priyadi Jul 17, 2024
00b1d43
strict booleans
priyadi Jul 17, 2024
ad5f052
instanceof, privatization
priyadi Jul 17, 2024
2206ffe
sets
priyadi Jul 17, 2024
bf84eed
cleanup
priyadi Jul 17, 2024
7e550bd
add ci
priyadi Jul 17, 2024
4fbff45
remove ci
priyadi Jul 17, 2024
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
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
- name: Validate monorepo
run: vendor/bin/monorepo-builder validate

# - name: Rector
# run: vendor/bin/rector process --no-progress-bar --no-diffs --dry-run --no-ansi

- name: Load fixtures
run: make fixtures

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ vendor
.phpunit.cache
tools
.php-cs-fixer.cache
.vscode
.vscode
rector.log
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ phpunit:
lint:
$(PHP) tests/bin/console lint:container

.PHONY: rector
rector:
$(PHP) vendor/bin/rector process > rector.log
make php-cs-fixer

.PHONY: php-cs-fixer
php-cs-fixer: tools/php-cs-fixer
$(PHP) $< fix --config=.php-cs-fixer.dist.php --verbose --allow-risky=yes
Expand Down Expand Up @@ -74,4 +79,4 @@ sqlite:

.PHONY: dump
dump:
$(PHP) tests/bin/console server:dump
$(PHP) tests/bin/console server:dump
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"psalm/plugin-symfony": "^5.1",
"psr/log": "^2.0 || ^3.0",
"ramsey/uuid": "^4.7",
"rector/rector": "^1.2",
"rekalogika/doctrine-collections-decorator": "^2.3",
"symfony/asset": "^6.4 || ^7.0",
"symfony/asset-mapper": "^6.4 || ^7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class ApiPageUrlGenerator implements PageUrlGeneratorInterface

public function __construct(
string $iri,
private string $pageParameterName,
private int $urlGenerationStrategy,
private readonly string $pageParameterName,
private readonly int $urlGenerationStrategy,
) {
$this->parsed = IriHelper::parseIri($iri, $this->pageParameterName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
* @template T of object
* @implements QueryResultCollectionExtensionInterface<T>
*/
final class RekapagerExtension implements QueryResultCollectionExtensionInterface
final readonly class RekapagerExtension implements QueryResultCollectionExtensionInterface
{
public function __construct(
private readonly PagerFactory $pagerFactory,
private readonly Pagination $pagination,
private PagerFactory $pagerFactory,
private Pagination $pagination,
) {
}

Expand Down Expand Up @@ -91,8 +91,7 @@ public function getResult(
array $context = []
): iterable {
$pageable = new KeysetPageable(new QueryBuilderAdapter($queryBuilder));
$pager = $this->pagerFactory->createPager($pageable, $operation, $context);

return $pager;
return $this->pagerFactory->createPager($pageable, $operation, $context);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
class RekapagerOpenApiFactoryDecorator implements OpenApiFactoryInterface
{
public function __construct(
private OpenApiFactoryInterface $decorated,
private readonly OpenApiFactoryInterface $decorated,
) {
}

/**
* @param array<array-key,mixed> $context
* @return OpenApi
*/
public function __invoke(array $context = []): OpenApi
{
Expand Down
3 changes: 2 additions & 1 deletion packages/rekapager-api-platform/src/Util/IriHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public static function createIri(array $parts, array $parameters, ?string $pageP
} else {
$scheme = 'http';
}
$url .= UrlGeneratorInterface::NET_PATH === $urlGenerationStrategy ? '//' : "$scheme://";

$url .= UrlGeneratorInterface::NET_PATH === $urlGenerationStrategy ? '//' : $scheme . '://';

if (isset($parts['user'])) {
$url .= $parts['user'];
Expand Down
8 changes: 4 additions & 4 deletions packages/rekapager-bundle/src/PagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public function createPager(

try {
/** @psalm-suppress NoValue */
foreach ($pager->getCurrentPage() as $i);
foreach ($pager->getCurrentPage() as $i) {
// noop
}
} catch (ContractsOutOfBoundsException $e) {
throw new OutOfBoundsException($e, $pager, $options);
}
Expand All @@ -142,9 +144,7 @@ private function getPageIdentifier(
return null;
}

$pageIdentifier = $this->pageIdentifierEncoderResolver
return $this->pageIdentifierEncoderResolver
->decode($pageable, $pageIdentifier);

return $pageIdentifier;
}
}
1 change: 0 additions & 1 deletion packages/rekapager-bundle/src/Twig/RekapagerRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(
/**
* @param PagerInterface<array-key,mixed> $pager
* @param int<0,max>|null $proximity
* @return string
*/
public function renderPager(
PagerInterface $pager,
Expand Down
1 change: 0 additions & 1 deletion packages/rekapager-core/src/Batch/BatchProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ final class BatchProcess

/**
* @param PageableInterface<TKey,T> $pageable
* @param PageIdentifierEncoderResolverInterface $pageableIdentifierResolver
* @param BatchProcessorInterface<TKey,T> $batchProcessor
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class BatchProcessorDecorator implements BatchProcessorInterface
/**
* @param BatchProcessorInterface<TKey,T> $decorated
*/
public function __construct(private BatchProcessorInterface $decorated)
public function __construct(private readonly BatchProcessorInterface $decorated)
{
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Batch/Event/AfterPageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* @template TKey of array-key
* @template T
*/
final class AfterPageEvent
final readonly class AfterPageEvent
{
/**
* @param BeforePageEvent<TKey,T> $beforePageEvent
*/
public function __construct(
private readonly BeforePageEvent $beforePageEvent,
private BeforePageEvent $beforePageEvent,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Batch/Event/AfterProcessEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
* @template TKey of array-key
* @template T
*/
final class AfterProcessEvent
final readonly class AfterProcessEvent
{
/**
* @param PageableInterface<TKey,T> $pageable
*/
public function __construct(
private readonly PageableInterface $pageable,
private PageableInterface $pageable,
) {
}

Expand Down
7 changes: 3 additions & 4 deletions packages/rekapager-core/src/Batch/Event/BeforePageEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
* @template TKey of array-key
* @template T
*/
final class BeforePageEvent
final readonly class BeforePageEvent
{
/**
* @param PageInterface<TKey,T> $page
* @param string $encodedPageIdentifier
*/
public function __construct(
private readonly PageInterface $page,
private readonly string $encodedPageIdentifier,
private PageInterface $page,
private string $encodedPageIdentifier,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* @template TKey of array-key
* @template T
*/
final class BeforeProcessEvent
final readonly class BeforeProcessEvent
{
/**
* @param PageableInterface<TKey,T> $pageable
*/
public function __construct(
private readonly PageableInterface $pageable,
private readonly ?string $startPageIdentifier,
private PageableInterface $pageable,
private ?string $startPageIdentifier,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions packages/rekapager-core/src/Batch/Event/InterruptEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* @template TKey of array-key
* @template T
*/
final class InterruptEvent
final readonly class InterruptEvent
{
/**
* @param PageableInterface<TKey,T> $pageable
*/
public function __construct(
private readonly PageableInterface $pageable,
private readonly ?string $nextPageIdentifier,
private PageableInterface $pageable,
private ?string $nextPageIdentifier,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions packages/rekapager-core/src/Batch/Event/ItemEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* @template TKey of array-key
* @template T
*/
final class ItemEvent
final readonly class ItemEvent
{
/**
* @param TKey $key
* @param T $item
*/
public function __construct(
private readonly int|string $key,
private readonly mixed $item,
private int|string $key,
private mixed $item,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions packages/rekapager-core/src/Batch/Event/TimeLimitEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* @template TKey of array-key
* @template T
*/
final class TimeLimitEvent
final readonly class TimeLimitEvent
{
/**
* @param PageableInterface<TKey,T> $pageable
*/
public function __construct(
private readonly PageableInterface $pageable,
private readonly ?string $nextPageIdentifier,
private PageableInterface $pageable,
private ?string $nextPageIdentifier,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
use Rekalogika\Rekapager\Batch\BatchProcessorInterface;
use Rekalogika\Rekapager\Contracts\PageIdentifierEncoderResolverInterface;

final class DefaultBatchProcessFactory implements BatchProcessFactoryInterface
final readonly class DefaultBatchProcessFactory implements BatchProcessFactoryInterface
{
public function __construct(
private readonly PageIdentifierEncoderResolverInterface $pageableIdentifierResolver,
private PageIdentifierEncoderResolverInterface $pageableIdentifierResolver,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class PageIdentifierEncoderResolver implements PageIdentifierEncoderResolverInterface
{
public function __construct(
private PageIdentifierEncoderLocatorInterface $locator
private readonly PageIdentifierEncoderLocatorInterface $locator
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
* @implements \IteratorAggregate<TKey,T>
* @internal
*/
final class NullPageDecorator implements NullPageInterface, \IteratorAggregate
final readonly class NullPageDecorator implements NullPageInterface, \IteratorAggregate
{
/**
* @param PageInterface<TKey,T> $page
*/
public function __construct(
private readonly PageInterface $page,
private PageInterface $page,
) {
}

Expand All @@ -47,7 +47,7 @@ public function getPageNumber(): ?int

public function withPageNumber(?int $pageNumber): static
{
return new static($this->page->withPageNumber($pageNumber));
return new self($this->page->withPageNumber($pageNumber));
}

public function getPageable(): PageableInterface
Expand Down
2 changes: 1 addition & 1 deletion packages/rekapager-core/src/Pager/Internal/PagerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*
* @internal
*/
final class PagerItem implements PagerItemInterface, \IteratorAggregate
final readonly class PagerItem implements PagerItemInterface, \IteratorAggregate
{
private int|null|NullPageNumber $pageNumber;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface PagerUrlGeneratorInterface
* @template TKey of array-key
* @template T
* @param PageInterface<TKey,T> $page
* @return string|null
*/
public function generateUrl(PageInterface $page): ?string;
}
Loading