Skip to content

Commit

Permalink
Require php 8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MortalFlesh committed Apr 27, 2022
1 parent e30c01b commit feb1c10
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 121 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/pr-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pull request check

on: [pull_request]

jobs:
block-fixup-merge:
runs-on: ubuntu-latest
name: Block fixup commits

steps:
- uses: actions/checkout@v2

- name: Block fixup commit merge
uses: 13rac1/block-fixup-merge-action@v2.0.0
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

strategy:
matrix:
php-version: ['7.4']
php-version: ['8.1']
dependencies: ['']
include:
- { php-version: '7.4', dependencies: '--prefer-lowest --prefer-stable' }
- { php-version: '8.1', dependencies: '--prefer-lowest --prefer-stable' }

name: Unit tests - PHP ${{ matrix.dependencies }}

Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
extensions: json, mbstring

- name: Install dependencies
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<!-- There should always be "Unreleased" section at the beginning. -->

## Unreleased
- Require php 8.1
- [**BC**] Use new language features and change method signatures
- Allow Symfony 6

## 1.3.0 - 2022-04-05
- Allow setting a profiler bag verbosity in bundle configuration
Expand Down
34 changes: 17 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
"license": "MIT",
"type": "symfony-bundle",
"require": {
"php": "^7.4",
"php": "^8.1",
"ext-json": "*",
"ext-mbstring": "*",
"lmc/cqrs-handler": "^1.3",
"lmc/cqrs-types": "^2.3",
"symfony/config": "^4.4 || ^5.1",
"symfony/console": "^4.4 || ^5.1",
"symfony/dependency-injection": "^4.4 || ^5.1",
"symfony/error-handler": "^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-foundation": "^4.4 || ^5.1",
"symfony/http-kernel": "^4.4 || ^5.1",
"lmc/cqrs-handler": "^2.0",
"lmc/cqrs-types": "^3.0",
"symfony/config": "^4.4 || ^5.1 || ^6.0",
"symfony/console": "^4.4 || ^5.1 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.1 || ^6.0",
"symfony/error-handler": "^4.4 || ^5.1 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.1 || ^6.0",
"symfony/http-foundation": "^4.4 || ^5.1 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.1 || ^6.0",
"twig/twig": "^2.0 || ^3.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.5",
"lmc/coding-standard": "^3.0",
"lmc/cqrs-http": "^2.0",
"lmc/cqrs-solr": "^1.2",
"lmc/coding-standard": "^3.3",
"lmc/cqrs-http": "^3.0",
"lmc/cqrs-solr": "^3.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^0.12.83",
"phpstan/phpstan-phpunit": "^0.12.18",
"phpunit/phpunit": "^9.5",
"symfony/yaml": "^5.2"
"phpstan/phpstan": "^1.6",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^9.5.20",
"symfony/yaml": "^5.2 || ^6.0"
},
"suggest": {
"lmc/cqrs-http": "Provides http handler and base types for queries and commands.",
Expand Down
6 changes: 2 additions & 4 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php declare(strict_types=1);

use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
Expand All @@ -10,7 +9,7 @@

$parameters->set(
Option::SKIP,
['SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff.ReferencedGeneralException' => ['tests/Exception/*.php']]
['SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff.ReferencedGeneralException' => ['tests/Exception/*.php']],
);

$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs.php');
Expand All @@ -20,6 +19,5 @@
$services->set(PhpUnitTestAnnotationFixer::class)
->call('configure', [['style' => 'annotation']]);

$services->set(NoSuperfluousPhpdocTagsFixer::class)
->call('configure', [['allow_mixed' => true]]);
$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs-8.1.php');
};
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
parameters:
checkMissingIterableValueType: false
level: 7
level: 8
paths:
- src
- tests

excludes_analyse:
excludePaths:
- src/DependencyInjection/Configuration.php

ignoreErrors:
32 changes: 8 additions & 24 deletions src/Command/DebugCqrsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,21 @@

class DebugCqrsCommand extends Command
{
/** @phpstan-var QueryFetcherInterface<mixed, mixed> */
private QueryFetcherInterface $queryFetcher;
/** @phpstan-var CommandSenderInterface<mixed, mixed> */
private CommandSenderInterface $commandSender;
private SymfonyStyle $io;
private ?string $cacheProvider;
private ?CqrsDataCollector $cqrsDataCollector;
private bool $isExtensionHttpEnabled;
private bool $isExtensionSolrEnabled;
private ?ProfilerBag $profilerBag;

/**
* @phpstan-param QueryFetcherInterface<mixed, mixed> $queryFetcher
* @phpstan-param CommandSenderInterface<mixed, mixed> $commandSender
*/
public function __construct(
QueryFetcherInterface $queryFetcher,
CommandSenderInterface $commandSender,
?string $cacheProvider,
?CqrsDataCollector $cqrsDataCollector,
bool $isExtensionHttpEnabled,
bool $isExtensionSolrEnabled,
?ProfilerBag $profilerBag
private QueryFetcherInterface $queryFetcher,
private CommandSenderInterface $commandSender,
private ?string $cacheProvider,
private ?CqrsDataCollector $cqrsDataCollector,
private bool $isExtensionHttpEnabled,
private bool $isExtensionSolrEnabled,
private ?ProfilerBag $profilerBag,
) {
$this->queryFetcher = $queryFetcher;
$this->commandSender = $commandSender;
$this->cacheProvider = $cacheProvider;
$this->cqrsDataCollector = $cqrsDataCollector;
$this->isExtensionHttpEnabled = $isExtensionHttpEnabled;
$this->isExtensionSolrEnabled = $isExtensionSolrEnabled;
$this->profilerBag = $profilerBag;
parent::__construct();
}

Expand All @@ -69,7 +53,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
[
['http', $this->isExtensionHttpEnabled ? 'Yes' : 'No'],
['solr', $this->isExtensionSolrEnabled ? 'Yes' : 'No'],
]
],
);

$this->separator();
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/CacheController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class CacheController
/**
* Returns a list of deleted keys or status of deleted key if only one key was provided
*
* @Route("/_profiler/cqrs-bundle/query/cache/invalidate", name="_cqrs_query_cache_invalidate")
* @phpstan-param QueryFetcherInterface<mixed, mixed> $queryFetcher
*/
#[Route('/_profiler/cqrs-bundle/query/cache/invalidate', name: '_cqrs_query_cache_invalidate')]
public function invalidateQueryCacheAction(
QueryFetcherInterface $queryFetcher,
Request $request
Request $request,
): JsonResponse {
/** @var string|array|null $keys */
$keys = $request->query->get('key');
Expand Down
8 changes: 4 additions & 4 deletions src/DependencyInjection/Compiler/HandlerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ private function setUpQueryFetcher(ContainerBuilder $container): void
foreach ($this->iterateByTags(
$container,
LmcCqrsExtension::TAG_QUERY_HANDLER,
$defaultPriority
$defaultPriority,
) as $handlerId => $priority) {
$queryFetcher->addMethodCall('addHandler', [new Reference($handlerId), $priority]);
}

foreach ($this->iterateByTags(
$container,
LmcCqrsExtension::TAG_RESPONSE_DECODER,
$defaultPriority
$defaultPriority,
) as $decoderId => $priority) {
$queryFetcher->addMethodCall('addDecoder', [new Reference($decoderId), $priority]);
}
Expand All @@ -56,15 +56,15 @@ private function setUpCommandSender(ContainerBuilder $container): void
foreach ($this->iterateByTags(
$container,
LmcCqrsExtension::TAG_SEND_COMMAND_HANDLER,
$defaultPriority
$defaultPriority,
) as $handlerId => $priority) {
$commandSender->addMethodCall('addHandler', [new Reference($handlerId), $priority]);
}

foreach ($this->iterateByTags(
$container,
LmcCqrsExtension::TAG_RESPONSE_DECODER,
$defaultPriority
$defaultPriority,
) as $decoderId => $priority) {
$commandSender->addMethodCall('addDecoder', [new Reference($decoderId), $priority]);
}
Expand Down
28 changes: 9 additions & 19 deletions src/Profiler/CqrsDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@

class CqrsDataCollector extends DataCollector
{
private ProfilerBag $profilerBag;
/** @phpstan-var QueryFetcherInterface<mixed, mixed> */
private QueryFetcherInterface $queryFetcher;
/** @phpstan-var CommandSenderInterface<mixed, mixed> */
private CommandSenderInterface $commandSender;
/** @var ProfilerFormatterInterface[] */
private array $formatters;
private ?string $cacheProvider;

public static function getDefaultPriority(): int
{
Expand All @@ -34,17 +28,13 @@ public static function getDefaultPriority(): int
* @param \Traversable<ProfilerFormatterInterface> $formatters
*/
public function __construct(
ProfilerBag $profilerBag,
QueryFetcherInterface $queryFetcher,
CommandSenderInterface $commandSender,
private ProfilerBag $profilerBag,
private QueryFetcherInterface $queryFetcher,
private CommandSenderInterface $commandSender,
\Traversable $formatters,
?string $cacheProvider
private ?string $cacheProvider,
) {
$this->profilerBag = $profilerBag;
$this->queryFetcher = $queryFetcher;
$this->commandSender = $commandSender;
$this->formatters = iterator_to_array($formatters);
$this->cacheProvider = $cacheProvider;
}

/**
Expand Down Expand Up @@ -76,9 +66,9 @@ private function formatItems(array $profilerBag): array
fn (ProfilerItem $item) => array_reduce(
$this->formatters,
fn (ProfilerItem $item, ProfilerFormatterInterface $formatter) => $formatter->formatItem($item),
$item
$item,
),
$profilerBag
$profilerBag,
);
}

Expand All @@ -89,7 +79,7 @@ private function mapPrioritizedItems(array $prioritizedItems, string $itemKey):
$itemKey => get_class($item->getItem()),
'priority' => $item->getPriority(),
],
$prioritizedItems
$prioritizedItems,
);
}

Expand All @@ -107,7 +97,7 @@ public function getFormatters(): array
{
return array_map(
fn (ProfilerFormatterInterface $formatter) => get_class($formatter),
$this->data['formatters'] ?? []
$this->data['formatters'] ?? [],
);
}

Expand Down Expand Up @@ -161,7 +151,7 @@ function (int $count, ProfilerItem $item) use ($cached) {

return $count;
},
0
0,
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Service/ClassExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

class ClassExtension extends AbstractExtension
{
public function getFilters()
public function getFilters(): array
{
return [
new TwigFilter(
'genericClass',
fn (string $class) => $this->formatGenericClass($class),
['is_safe' => ['html']]
['is_safe' => ['html']],
),
];
}
Expand All @@ -29,15 +29,15 @@ private function formatGenericClass(string $class): string
return sprintf(
'<small class="className">%s</small><strong>%s</strong>',
$this->replaceOnceFromEnd($shortName, '', $class),
$shortName
$shortName,
);
} elseif ($this->tryParseClassWithGenerics($class, $shortName, $genericArguments)) {
if ($this->tryParseClassWithGenerics($genericArguments)) {
$generics = $this->formatGenericClass($genericArguments);
} else {
$generics = array_map(
fn (string $genericArgument) => $this->formatGenericClass(trim($genericArgument)),
explode(',', $genericArguments)
explode(',', $genericArguments),
);

$generics = implode(', ', $generics);
Expand Down Expand Up @@ -83,7 +83,7 @@ private function tryParseClassWithoutGenerics(string $class, ?string &$shortClas
private function tryParseClassWithGenerics(
string $class,
?string &$shortClassName = null,
?string &$genericArguments = null
?string &$genericArguments = null,
): bool {
if (preg_match('/^([A-Z][A-Za-z0-9]*\\\\)*([A-Z][A-Za-z]*?)<(.*)>$/', $class, $matches) === 1) {
$genericArguments = array_pop($matches);
Expand Down
Loading

0 comments on commit feb1c10

Please sign in to comment.