Skip to content

Commit

Permalink
revert: "chore: change coding style to @PhpCsFixer:risky (#188)"
Browse files Browse the repository at this point in the history
This reverts commit 1be1326.
  • Loading branch information
priyadi committed Sep 4, 2024
1 parent 1be1326 commit 28e5d96
Show file tree
Hide file tree
Showing 50 changed files with 152 additions and 138 deletions.
24 changes: 21 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,28 @@

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PhpCsFixer:risky' => true,
'declare_strict_types' => true,
'php_unit_strict' => false,
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],

// imports
'fully_qualified_strict_types' => true,
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
'import_functions' => false,
],
'no_leading_import_slash' => true,
'no_unneeded_import_alias' => true,
'no_unused_imports' => true,
'ordered_imports' => [
'sort_algorithm' => 'alpha',
'imports_order' => ['const', 'class', 'function']
],
'single_line_after_imports' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'declare_strict_types' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized']],
'header_comment' => [
'header' => <<<EOF
This file is part of rekalogika/rekapager package.
Expand Down
4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Changelog

# 0.17.1

* chore: change coding style to @PhpCsFixer:risky

# 0.17.0

* feat: DBAL adapter
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0",
"symplify/monorepo-builder": "^11.2.20 || ^11.3",
"vimeo/psalm": "^5.25",
"vimeo/psalm": "^5.15",
"zenstruck/foundry": "1.37.*"
},
"replace": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
) {
}

/** @phpstan-ignore missingType.iterableValue */
// @phpstan-ignore missingType.iterableValue
public function getSupportedTypes(?string $format): array
{
return $this->collectionNormalizer->getSupportedTypes($format);
Expand Down
2 changes: 1 addition & 1 deletion packages/rekapager-api-platform/src/Util/IriHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function createIri(array $parts, array $parameters, ?string $pageP
$parameters[$pageParameterName] = $encodedPageIdentifier;
}

$query = http_build_query($parameters, '', '&', PHP_QUERY_RFC3986);
$query = http_build_query($parameters, '', '&', \PHP_QUERY_RFC3986);
$parts['query'] = preg_replace('/%5B\d+%5D/', '%5B%5D', $query);

$url = '';
Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-contracts/src/PageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ public function getItemsPerPage(): int;
*
* @return null|PageInterface<TKey,T>
*/
public function getNextPage(): ?self;
public function getNextPage(): ?PageInterface;

/**
* Gets the previous page if it exists.
*
* @return null|PageInterface<TKey,T>
*/
public function getPreviousPage(): ?self;
public function getPreviousPage(): ?PageInterface;

/**
* Gets n next pages
Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Batch/BatchProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function __construct(
) {
}

public function stop(): bool
final public function stop(): bool
{
if ($this->stopFlag === false) {
$this->stopFlag = true;
Expand All @@ -56,7 +56,7 @@ public function stop(): bool
/**
* @param int<1,max>|null $pageSize
*/
public function run(
final public function run(
?string $resume = null,
?int $pageSize = null,
?int $timeLimit = null,
Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Contracts/PagerItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function isDisabled(): bool;
/**
* @return null|PagerItemInterface<TKey,T>
*/
public function getNextPage(): ?self;
public function getNextPage(): ?PagerItemInterface;

/**
* @return null|PagerItemInterface<TKey,T>
*/
public function getPreviousPage(): ?self;
public function getPreviousPage(): ?PagerItemInterface;

/**
* Gets n next pages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @internal
*/
final class NullPagerUrlGenerator implements PagerUrlGeneratorInterface
class NullPagerUrlGenerator implements PagerUrlGeneratorInterface
{
#[\Override]
public function generateUrl(PageInterface $page): ?string
Expand Down
6 changes: 3 additions & 3 deletions packages/rekapager-core/src/Pager/Internal/PagerItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ public function getUrl(): ?string
* @param PageInterface<TKey2,T2> $page
* @return PagerItem<TKey2,T2>
*/
private function decorate(PageInterface $page): self
private function decorate(PageInterface $page): PagerItem
{
if ($page instanceof self) {
if ($page instanceof PagerItem) {
return $page;
}

return new self(
return new PagerItem(
wrapped: $page,
pagerUrlGenerator: $this->pagerUrlGenerator,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
/**
* @internal
*/
final readonly class PagerUrlGenerator implements PagerUrlGeneratorInterface
class PagerUrlGenerator implements PagerUrlGeneratorInterface
{
/**
* @param PageIdentifierEncoderInterface<object> $pageIdentifierEncoder
*/
public function __construct(
private PageUrlGeneratorInterface $pageUrlGenerator,
private PageIdentifierEncoderInterface $pageIdentifierEncoder,
private readonly PageUrlGeneratorInterface $pageUrlGenerator,
private readonly PageIdentifierEncoderInterface $pageIdentifierEncoder,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-core/src/Pager/Internal/ProximityPager.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ public function __construct(
if (
$lastPageFromNextNeighboringPages !== false
&& $this->hasHiddenPagesAfter
&& null !== ($lastPageNumber = $this->lastPage?->getPageNumber())
&& null !== ($lastPageFromNextNeighboringPagesNumber = $lastPageFromNextNeighboringPages->getPageNumber())
&& !\is_null($lastPageNumber = $this->lastPage?->getPageNumber())
&& !\is_null($lastPageFromNextNeighboringPagesNumber = $lastPageFromNextNeighboringPages->getPageNumber())
&& $lastPageFromNextNeighboringPagesNumber - $lastPageNumber === -2
&& $secondLastPage = array_shift($nextPages)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @implements PagerInterface<TKey,T>
* @internal
*/
final class ZeroProximityPager implements PagerInterface
class ZeroProximityPager implements PagerInterface
{
//
// pager components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
'Missing placeholder "{{%s}}" in SQL variable "$%s". Required placeholders: %s',
$template,
$sqlVariable,
implode(', ', array_map(static fn (string $template): string => sprintf('"{{%s}}"', $template), $templates))
implode(', ', array_map(fn (string $template): string => sprintf('"{{%s}}"', $template), $templates))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __serialize(): array
];
}

/** @phpstan-ignore-next-line */
// @phpstan-ignore-next-line
public function __unserialize(array $data): void
{
$this->pageOffsetFromBoundary = $data['o'];
Expand Down
4 changes: 2 additions & 2 deletions packages/rekapager-symfony-bridge/src/Batch/BatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,13 @@ final protected function execute(InputInterface $input, OutputInterface $output)
#[\Override]
public function getSubscribedSignals(): array
{
return [SIGINT, SIGTERM];
return [\SIGINT, \SIGTERM];
}

#[\Override]
public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false
{
if (SIGINT !== $signal && SIGTERM !== $signal) {
if (\SIGINT !== $signal && \SIGTERM !== $signal) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @internal
*/
final class BatchTimer
class BatchTimer
{
public const TIMER_PROCESS = 'process';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @extends BatchProcessorDecorator<TKey,T>
* @internal
*/
final class CommandBatchProcessorDecorator extends BatchProcessorDecorator
class CommandBatchProcessorDecorator extends BatchProcessorDecorator
{
private readonly BatchTimer $timer;

Expand Down
10 changes: 5 additions & 5 deletions tests/src/App/Controller/DemoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function page(

$dumper->setTheme('light');

$output = fopen('php://memory', 'r+') ?: throw new \RuntimeException('Failed to open memory stream');
$output = fopen('php://memory', 'r+b') ?: throw new \RuntimeException('Failed to open memory stream');
$dumper->dump($cloner->cloneVar($pageIdentifier), $output);
$output = stream_get_contents($output, -1, 0);

Expand Down Expand Up @@ -135,7 +135,7 @@ public function batch(
setName: 'medium',
);

// highlight-start
// @highlight-start

$output = '<ul>';

Expand Down Expand Up @@ -182,7 +182,7 @@ public function batch(
}

$output .= '</ul>';
// highlight-end
// @highlight-end

$title = $pageableGenerator->getTitle();

Expand Down Expand Up @@ -216,13 +216,13 @@ private function getSourceCode(string $class): string
}

$contents = preg_replace(
'|^.*//\s+highlight-start\n|s',
'|^.*//\s+@highlight-start\n|s',
'',
$contents,
) ?? throw new \RuntimeException('Regex fail');

$contents = preg_replace(
'|\n\s+//\s+highlight-end.*\n$|s',
'|\n\s+//\s+@highlight-end.*\n$|s',
'',
$contents,
) ?? throw new \RuntimeException('Regex fail');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$resultSetMapping = new ResultSetMappingBuilder($this->entityManager);
$resultSetMapping->addRootEntityFromClassMetadata(Post::class, 'p');

Expand Down Expand Up @@ -91,7 +91,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$resultSetMapping = new ResultSetMappingBuilder($this->entityManager);
$resultSetMapping->addRootEntityFromClassMetadata(Post::class, 'p');

Expand Down Expand Up @@ -93,7 +93,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$queryBuilder = $this->connection
->createQueryBuilder()
->select('p.id', 'p.date', 'p.title', 'p.content', 'p.category')
Expand All @@ -72,7 +72,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$queryBuilder = $this->connection
->createQueryBuilder()
->select('p.id', 'p.date', 'p.title', 'p.content', 'p.category')
Expand All @@ -74,7 +74,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$queryBuilder = $this->postRepository
->createQueryBuilder('p')
->where('p.setName = :setName')
Expand All @@ -71,7 +71,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function generatePageable(
string $setName,
?int $pageLimit = null,
): PageableInterface {
// highlight-start
// @highlight-start
$queryBuilder = $this->postRepository
->createQueryBuilder('p')
->where('p.setName = :setName')
Expand All @@ -73,7 +73,7 @@ public function generatePageable(
itemsPerPage: $itemsPerPage,
count: $count,
);
// highlight-end
// @highlight-end

// @phpstan-ignore-next-line
return $pageable;
Expand Down
Loading

0 comments on commit 28e5d96

Please sign in to comment.