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

chore: replace stylecy with php-cs-fixer #626

Merged
merged 2 commits into from
May 4, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.gitattributes export-ignore
.gitignore export-ignore
.scrutinizer.yml export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
Resources/doc export-ignore
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,16 @@ jobs:
uses: docker://oskarstark/phpstan-ga
with:
args: analyze --no-progress -c phpstan.tests.neon.dist

php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --dry-run --diff
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ vendor/
composer.lock
phpunit.xml
Resources/doc/_build
.php-cs-fixer.cache
18 changes: 18 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__.'/src')
->in(__DIR__.'/tests')
->name('*.php')
;

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'single_line_throw' => false,
])
->setFinder($finder)
;
7 changes: 0 additions & 7 deletions .styleci.yml

This file was deleted.

5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpstan/extension-installer": "^1.3",
"jean-beru/fos-http-cache-cloudfront": "^1.1"
"jean-beru/fos-http-cache-cloudfront": "^1.1",
"friendsofphp/php-cs-fixer": "^3.54"
},
"suggest": {
"jean-beru/fos-http-cache-cloudfront": "To use CloudFront proxy",
Expand Down Expand Up @@ -90,4 +91,4 @@
"phpstan/extension-installer": true
}
}
}
}
3 changes: 0 additions & 3 deletions src/DependencyInjection/Compiler/HashGeneratorPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ final class HashGeneratorPass implements CompilerPassInterface
{
public const TAG_NAME = 'fos_http_cache.user_context_provider';

/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (!$container->has('fos_http_cache.user_context.hash_generator')) {
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Compiler/LoggerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*/
final class LoggerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if (!$container->has('logger') || !$container->has('fos_http_cache.event_listener.log')) {
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Compiler/SessionListenerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
*/
final class SessionListenerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
{
if ($container->has('session_listener')) {
Expand Down
3 changes: 0 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public function __construct($debug)
$this->debug = $debug;
}

/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('fos_http_cache');
Expand Down
3 changes: 0 additions & 3 deletions src/EventListener/AttributesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ public function onKernelRequest(RequestEvent $event): void
}
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
3 changes: 0 additions & 3 deletions src/EventListener/CacheControlListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ public function __construct(string|false $debugHeader = false)
$this->debugHeader = $debugHeader;
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
3 changes: 0 additions & 3 deletions src/EventListener/FlashMessageListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ public function __construct(array $options = [])
$this->options = $resolver->resolve($options);
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
5 changes: 1 addition & 4 deletions src/EventListener/InvalidationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
CacheManager $cacheManager,
UrlGeneratorInterface $urlGenerator,
RuleMatcherInterface $mustInvalidateRule,
ExpressionLanguage $expressionLanguage = null
?ExpressionLanguage $expressionLanguage = null
) {
$this->cacheManager = $cacheManager;
$this->urlGenerator = $urlGenerator;
Expand Down Expand Up @@ -109,9 +109,6 @@ public function onConsoleTerminate(ConsoleEvent $event): void
}
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
3 changes: 0 additions & 3 deletions src/EventListener/SwitchUserListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public function __construct(UserContextInvalidator $invalidator)
$this->invalidator = $invalidator;
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
5 changes: 1 addition & 4 deletions src/EventListener/TagListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
SymfonyResponseTagger $tagHandler,
RuleMatcherInterface $cacheableRule,
RuleMatcherInterface $mustInvalidateRule,
ExpressionLanguage $expressionLanguage = null
?ExpressionLanguage $expressionLanguage = null
) {
$this->cacheManager = $cacheManager;
$this->symfonyResponseTagger = $tagHandler;
Expand Down Expand Up @@ -94,9 +94,6 @@ public function onKernelResponse(ResponseEvent $event): void
}
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
7 changes: 2 additions & 5 deletions src/EventListener/UserContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ final class UserContextListener implements EventSubscriberInterface
public function __construct(
RequestMatcherInterface $requestMatcher,
HashGenerator $hashGenerator,
RequestMatcherInterface $anonymousRequestMatcher = null,
ResponseTagger $responseTagger = null,
?RequestMatcherInterface $anonymousRequestMatcher = null,
?ResponseTagger $responseTagger = null,
array $options = [],
bool $hasSessionListener = true
) {
Expand Down Expand Up @@ -220,9 +220,6 @@ public function onKernelResponse(ResponseEvent $event): void
$response->setVary($vary, true);
}

/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
Expand Down
3 changes: 0 additions & 3 deletions src/FOSHttpCacheBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

final class FOSHttpCacheBundle extends Bundle
{
/**
* {@inheritdoc}
*/
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new LoggerPass());
Expand Down
2 changes: 1 addition & 1 deletion src/Http/ResponseMatcher/ExpressionResponseMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class ExpressionResponseMatcher implements ResponseMatcherInterface
private ?ExpressionLanguage $expressionLanguage;
private string $expression;

public function __construct(string $expression, ExpressionLanguage $expressionLanguage = null)
public function __construct(string $expression, ?ExpressionLanguage $expressionLanguage = null)
{
$this->expression = $expression;
$this->expressionLanguage = $expressionLanguage;
Expand Down
7 changes: 0 additions & 7 deletions src/Http/RuleMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ final class RuleMatcher implements RuleMatcherInterface

private ?ResponseMatcherInterface $responseMatcher;

/**
* @param RequestMatcherInterface $requestMatcher|null Request matcher
* @param ResponseMatcherInterface $responseMatcher|null Response matcher
*/
public function __construct(
?RequestMatcherInterface $requestMatcher = null,
?ResponseMatcherInterface $responseMatcher = null
Expand All @@ -41,9 +37,6 @@ public function __construct(
$this->responseMatcher = $responseMatcher;
}

/**
* {@inheritdoc}
*/
public function matches(Request $request, Response $response)
{
if ($this->requestMatcher && !$this->requestMatcher->matches($request)) {
Expand Down
3 changes: 0 additions & 3 deletions src/Twig/CacheTagExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ public function __construct(ResponseTagger $responseTagger)
$this->responseTagger = $responseTagger;
}

/**
* {@inheritdoc}
*/
public function getFunctions(): array
{
return [
Expand Down
3 changes: 0 additions & 3 deletions src/UserContext/RequestMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public function __construct(?string $accept = 'application/vnd.fos.user-context-
$this->method = $method;
}

/**
* {@inheritdoc}
*/
public function matches(Request $request): bool
{
if (null !== $this->accept && $this->accept != $request->headers->get('accept', null)) {
Expand Down
2 changes: 0 additions & 2 deletions src/UserContext/RoleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public function __construct(
}

/**
* {@inheritdoc}
*
* @throws InvalidConfigurationException when called without a security context being set
*/
public function updateUserContext(UserContext $context): void
Expand Down
10 changes: 5 additions & 5 deletions tests/Functional/Fixtures/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ protected function build(ContainerBuilder $container): void
public function registerBundles(): iterable
{
return [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \FOS\HttpCacheBundle\FOSHttpCacheBundle(),
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
];
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/DependencyInjection/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,10 @@ public function testSupportsFastly(): void
$formats = array_map(static function (string $path) {
return __DIR__.'/../../Resources/Fixtures/'.$path;
}, [
'config/fastly.yml',
'config/fastly.xml',
'config/fastly.php',
]);
'config/fastly.yml',
'config/fastly.xml',
'config/fastly.php',
]);

foreach ($formats as $format) {
$this->assertProcessedConfigurationEquals($expectedConfiguration, [$format]);
Expand Down
40 changes: 20 additions & 20 deletions tests/Unit/DependencyInjection/FOSHttpCacheExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ public function testConfigLoadFastly(): void
{
$container = $this->createContainer();
$this->extension->load([
[
'proxy_client' => [
'fastly' => [
'service_identifier' => 'test',
'authentication_token' => 'test',
],
],
],
], $container);
[
'proxy_client' => [
'fastly' => [
'service_identifier' => 'test',
'authentication_token' => 'test',
],
],
],
], $container);

$this->assertFalse($container->hasDefinition('fos_http_cache.proxy_client.varnish'));
$this->assertTrue($container->hasDefinition('fos_http_cache.proxy_client.fastly'));
Expand Down Expand Up @@ -292,20 +292,20 @@ public function testConfigTagNotSupported(): void
$this->expectExceptionMessage('You can not enable cache tagging with the nginx client');

$config = [
'proxy_client' => [
'nginx' => [
'http' => [
'base_url' => 'my_hostname',
'servers' => [
'127.0.0.1',
],
'proxy_client' => [
'nginx' => [
'http' => [
'base_url' => 'my_hostname',
'servers' => [
'127.0.0.1',
],
],
],
'tags' => [
'enabled' => true,
],
];
],
'tags' => [
'enabled' => true,
],
];

$container = $this->createContainer();
$this->extension->load([$config], $container);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/EventListener/InvalidationListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function testOnConsoleTerminate()
$this->listener->onConsoleTerminate($event);
}

protected function getEvent(Request $request, Response $response = null): TerminateEvent
protected function getEvent(Request $request, ?Response $response = null): TerminateEvent
{
return new TerminateEvent(
\Mockery::mock(HttpKernelInterface::class),
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/EventListener/TagListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function testOnKernelResponsePost(): void
$this->listener->onKernelResponse($event);
}

private function getEvent(Request $request, Response $response = null): ResponseEvent
private function getEvent(Request $request, ?Response $response = null): ResponseEvent
{
return new ResponseEvent(
\Mockery::mock(HttpKernelInterface::class),
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/EventListener/UserContextListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ protected function getKernelRequestEvent(Request $request, $type = HttpKernelInt
);
}

protected function getKernelResponseEvent(Request $request, Response $response = null, $type = HttpKernelInterface::MAIN_REQUEST): ResponseEvent
protected function getKernelResponseEvent(Request $request, ?Response $response = null, $type = HttpKernelInterface::MAIN_REQUEST): ResponseEvent
{
return new ResponseEvent(
\Mockery::mock(HttpKernelInterface::class),
Expand Down