Skip to content

Commit a9f8af2

Browse files
committed
Update Rector and CS fixer, fix indentation
1 parent 1a80eca commit a9f8af2

17 files changed

+242
-233
lines changed

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ indent_style = space
66
insert_final_newline = true
77
max_line_length = 120
88
tab_width = 2
9-
ij_continuation_indent_size = 4
9+
ij_continuation_indent_size = 2
1010
ij_formatter_off_tag = @formatter:off
1111
ij_formatter_on_tag = @formatter:on
1212
ij_formatter_tags_enabled = false
@@ -440,6 +440,7 @@ ij_php_align_class_constants = true
440440
ij_php_align_group_field_declarations = true
441441
ij_php_align_inline_comments = false
442442
ij_php_align_key_value_pairs = true
443+
ij_php_align_match_arm_bodies = true
443444
ij_php_align_multiline_array_initializer_expression = false
444445
ij_php_align_multiline_binary_operation = false
445446
ij_php_align_multiline_chained_methods = false
@@ -481,7 +482,11 @@ ij_php_call_parameters_wrap = off
481482
ij_php_catch_on_new_line = false
482483
ij_php_category_weight = 28
483484
ij_php_class_brace_style = next_line
485+
ij_php_comma_after_last_argument = true
484486
ij_php_comma_after_last_array_element = true
487+
ij_php_comma_after_last_closure_use_var = true
488+
ij_php_comma_after_last_match_arm = true
489+
ij_php_comma_after_last_parameter = true
485490
ij_php_concat_spaces = true
486491
ij_php_copyright_weight = 28
487492
ij_php_deprecated_weight = 28

.php-cs-fixer.dist.php

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
11
<?php
22

33
return (new PhpCsFixer\Config())
4-
->setIndent(' ')
5-
->setRules([
6-
'@Symfony' => true,
7-
'binary_operator_spaces' => [
8-
'default' => 'align',
9-
'operators' => [
10-
'=>' => 'align_single_space_minimal',
11-
'|' => 'no_space',
12-
'+' => 'single_space',
13-
'-' => 'single_space',
14-
'*' => 'single_space',
15-
'/' => 'single_space',
16-
'??' => 'single_space',
17-
'||' => 'single_space',
18-
'&&' => 'single_space',
19-
'===' => 'single_space',
20-
'==' => 'single_space',
21-
'!==' => 'single_space',
22-
'!=' => 'single_space',
23-
'<' => 'single_space',
24-
'<=' => 'single_space',
25-
'>' => 'single_space',
26-
'>=' => 'single_space',
27-
],
28-
],
29-
'cast_spaces' => ['space' => 'none'],
30-
'class_attributes_separation' => ['elements' => ['const' => 'only_if_meta']],
31-
'concat_space' => ['spacing' => 'one'],
32-
'increment_style' => false,
33-
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
34-
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
35-
'phpdoc_order' => true,
36-
'single_line_throw' => false,
37-
'single_line_comment_spacing' => false,
38-
'yoda_style' => false,
39-
])
40-
->setFinder(
41-
PhpCsFixer\Finder::create()
42-
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
43-
);
4+
->setIndent(' ')
5+
->setRules([
6+
'@Symfony' => true,
7+
'array_indentation' => true,
8+
'binary_operator_spaces' => [
9+
'default' => 'align',
10+
'operators' => [
11+
'=>' => 'align_single_space_minimal',
12+
'|' => 'no_space',
13+
'+' => 'single_space',
14+
'-' => 'single_space',
15+
'*' => 'single_space',
16+
'/' => 'single_space',
17+
'??' => 'single_space',
18+
'||' => 'single_space',
19+
'&&' => 'single_space',
20+
'===' => 'single_space',
21+
'==' => 'single_space',
22+
'!==' => 'single_space',
23+
'!=' => 'single_space',
24+
'<' => 'single_space',
25+
'<=' => 'single_space',
26+
'>' => 'single_space',
27+
'>=' => 'single_space',
28+
],
29+
],
30+
'cast_spaces' => ['space' => 'none'],
31+
'class_attributes_separation' => ['elements' => ['const' => 'only_if_meta']],
32+
'concat_space' => ['spacing' => 'one'],
33+
'global_namespace_import' => ['import_classes' => true],
34+
'increment_style' => false,
35+
'method_chaining_indentation' => true,
36+
'nullable_type_declaration_for_default_null_value' => true,
37+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
38+
'phpdoc_line_span' => ['const' => 'single', 'method' => 'single', 'property' => 'single'],
39+
'phpdoc_order' => true,
40+
'phpdoc_to_comment' => ['ignored_tags' => ['noinspection', 'noRector']],
41+
'single_line_throw' => false,
42+
'single_line_comment_spacing' => false,
43+
'yoda_style' => false,
44+
])
45+
->setFinder(
46+
PhpCsFixer\Finder::create()
47+
->in(__DIR__ . DIRECTORY_SEPARATOR . 'src')
48+
->files()->notName('Configuration.php')
49+
);

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
},
4343
"require-dev": {
4444
"drenso/phan-extensions": "^3.0",
45-
"friendsofphp/php-cs-fixer": "3.8.0",
46-
"rector/rector": "0.14.8",
45+
"friendsofphp/php-cs-fixer": "3.45.0",
46+
"rector/rector": "0.18.13",
4747
"symfony/cache": "^5.4 || ^6.3 || ^7.0",
4848
"symfony/translation-contracts": "^2.0 || ^3.0"
4949
},

rector.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44

55
use Rector\Config\RectorConfig;
66
use Rector\Core\ValueObject\PhpVersion;
7-
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
87
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
8+
use Rector\PostRector\Rector\NameImportingPostRector;
99
use Rector\Set\ValueObject\LevelSetList;
1010

1111
return static function (RectorConfig $rc): void {
12-
$rc->paths([__DIR__ . '/src']);
12+
$rc->paths(['./src']);
1313
$rc->importNames();
1414
$rc->phpVersion(PhpVersion::PHP_80);
1515
$rc->skip([
16-
AddDefaultValueForUndefinedVariableRector::class,
17-
JsonThrowOnErrorRector::class,
16+
JsonThrowOnErrorRector::class,
17+
NameImportingPostRector::class => [
18+
'./src/OidcClient.php',
19+
],
1820
]);
1921

2022
$rc->import(LevelSetList::UP_TO_PHP_80);

src/DependencyInjection/DrensoOidcExtension.php

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,53 +36,53 @@ public function loadInternal(array $mergedConfig, ContainerBuilder $container):
3636

3737
// Setup default alias
3838
$container
39-
->setAlias(OidcClientInterface::class, sprintf('drenso.oidc.client.%s', $mergedConfig['default_client']));
39+
->setAlias(OidcClientInterface::class, sprintf('drenso.oidc.client.%s', $mergedConfig['default_client']));
4040

4141
// Configure client locator
4242
$container
43-
->getDefinition(self::CLIENT_LOCATOR_ID)
44-
->addArgument(ServiceLocatorTagPass::register($container, $clientServices))
45-
->addArgument($mergedConfig['default_client']);
43+
->getDefinition(self::CLIENT_LOCATOR_ID)
44+
->addArgument(ServiceLocatorTagPass::register($container, $clientServices))
45+
->addArgument($mergedConfig['default_client']);
4646
}
4747

4848
private function registerClient(ContainerBuilder $container, string $name, array $config): Reference
4949
{
5050
$urlFetcherId = sprintf('%s.%s', self::URL_FETCHER_ID, $name);
5151
$container
52-
->setDefinition($urlFetcherId, new ChildDefinition(self::URL_FETCHER_ID))
53-
->addArgument($config['custom_client_headers']);
52+
->setDefinition($urlFetcherId, new ChildDefinition(self::URL_FETCHER_ID))
53+
->addArgument($config['custom_client_headers']);
5454

5555
$sessionStorageId = sprintf('%s.%s', self::SESSION_STORAGE_ID, $name);
5656
$container
57-
->setDefinition($sessionStorageId, new ChildDefinition(self::SESSION_STORAGE_ID))
58-
->addArgument($name);
57+
->setDefinition($sessionStorageId, new ChildDefinition(self::SESSION_STORAGE_ID))
58+
->addArgument($name);
5959

6060
$jwtHelperId = sprintf('%s.%s', self::JWT_HELPER_ID, $name);
6161
$container
62-
->setDefinition($jwtHelperId, new ChildDefinition(self::JWT_HELPER_ID))
63-
->addArgument(new Reference($urlFetcherId))
64-
->addArgument(new Reference($sessionStorageId))
65-
->addArgument($config['client_id']);
62+
->setDefinition($jwtHelperId, new ChildDefinition(self::JWT_HELPER_ID))
63+
->addArgument(new Reference($urlFetcherId))
64+
->addArgument(new Reference($sessionStorageId))
65+
->addArgument($config['client_id']);
6666

6767
$clientId = sprintf('%s.%s', self::CLIENT_ID, $name);
6868
$wellKnownParserId = $config['well_known_parser'];
6969
$container
70-
->setDefinition($clientId, new ChildDefinition(self::CLIENT_ID))
71-
->addArgument(new Reference($urlFetcherId))
72-
->addArgument(new Reference($sessionStorageId))
73-
->addArgument(new Reference($jwtHelperId))
74-
->addArgument($config['well_known_url'])
75-
->addArgument($config['well_known_cache_time'])
76-
->addArgument($config['client_id'])
77-
->addArgument($config['client_secret'])
78-
->addArgument($config['redirect_route'])
79-
->addArgument($config['remember_me_parameter'])
80-
->addArgument($wellKnownParserId ? new Reference($wellKnownParserId) : null)
81-
->addArgument($config['code_challenge_method'])
82-
->addArgument($config['disable_nonce']);
70+
->setDefinition($clientId, new ChildDefinition(self::CLIENT_ID))
71+
->addArgument(new Reference($urlFetcherId))
72+
->addArgument(new Reference($sessionStorageId))
73+
->addArgument(new Reference($jwtHelperId))
74+
->addArgument($config['well_known_url'])
75+
->addArgument($config['well_known_cache_time'])
76+
->addArgument($config['client_id'])
77+
->addArgument($config['client_secret'])
78+
->addArgument($config['redirect_route'])
79+
->addArgument($config['remember_me_parameter'])
80+
->addArgument($wellKnownParserId ? new Reference($wellKnownParserId) : null)
81+
->addArgument($config['code_challenge_method'])
82+
->addArgument($config['disable_nonce']);
8383

8484
$container
85-
->registerAliasForArgument($clientId, OidcClientInterface::class, sprintf('%sOidcClient', $name));
85+
->registerAliasForArgument($clientId, OidcClientInterface::class, sprintf('%sOidcClient', $name));
8686

8787
return new Reference($clientId);
8888
}

src/EventListener/OidcEndSessionSubscriber.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
class OidcEndSessionSubscriber implements EventSubscriberInterface
1515
{
1616
public function __construct(
17-
private OidcClientInterface $oidcClient,
18-
private HttpUtils $httpUtils,
19-
private ?string $logoutTarget = null)
17+
private OidcClientInterface $oidcClient,
18+
private HttpUtils $httpUtils,
19+
private ?string $logoutTarget = null)
2020
{
2121
}
2222

@@ -38,8 +38,8 @@ public function onLogout(LogoutEvent $event): void
3838
: null;
3939

4040
$event->setResponse($this->oidcClient->generateEndSessionEndpointRedirect(
41-
$token->getAuthData(),
42-
$postLogoutRedirectUrl
41+
$token->getAuthData(),
42+
$postLogoutRedirectUrl
4343
));
4444
}
4545

src/Exception/OidcClientNotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class OidcClientNotFoundException extends OidcException
88
{
9-
public function __construct(string $name, Throwable $previous = null)
9+
public function __construct(string $name, ?Throwable $previous = null)
1010
{
1111
parent::__construct(sprintf('Client "%s" does not exist.', $name), previous: $previous);
1212
}

src/Model/OidcUserData.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public function getUserDataArray(string $key): array
9898
public function getUserData(string $propertyPath): mixed
9999
{
100100
self::$accessor ??= PropertyAccess::createPropertyAccessorBuilder()
101-
->disableExceptionOnInvalidIndex()
102-
->disableExceptionOnInvalidPropertyPath()
103-
->getPropertyAccessor();
101+
->disableExceptionOnInvalidIndex()
102+
->disableExceptionOnInvalidPropertyPath()
103+
->getPropertyAccessor();
104104

105105
// Cast the user data to a stdClass
106106
return self::$accessor->getValue($this->userData, $propertyPath);

0 commit comments

Comments
 (0)