Skip to content

Commit 1fec178

Browse files
committed
Update ECS and apply coding standards
1 parent f1840f8 commit 1fec178

File tree

7 files changed

+54
-84
lines changed

7 files changed

+54
-84
lines changed

.editorconfig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
# editorconfig.org
12
root = true
23

34
[*]
4-
charset = utf-8
5-
end_of_line = lf
6-
insert_final_newline = true
75
indent_style = space
86
indent_size = 4
7+
end_of_line = lf
8+
charset = utf-8
99
trim_trailing_whitespace = true
10+
insert_final_newline = true
1011

1112
[*.md]
1213
trim_trailing_whitespace = false
1314

15+
[**.{yml,yaml}]
16+
indent_size = 2
17+
18+
[**.{neon,neon.dist}]
19+
indent_style = tab

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"require-dev": {
2121
"orchestra/testbench": "^6.0 || 7.0",
22-
"symplify/easy-coding-standard": "^10.3.3"
22+
"symplify/easy-coding-standard": "^11.1"
2323
},
2424
"autoload": {
2525
"psr-4": {

ecs.php

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
1616
use PhpCsFixer\Fixer\FunctionNotation\NoUselessSprintfFixer;
1717
use PhpCsFixer\Fixer\FunctionNotation\UseArrowFunctionsFixer;
18+
use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer;
1819
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
1920
use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer;
2021
use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer;
@@ -26,73 +27,36 @@
2627
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
2728
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer;
2829
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
29-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
30+
use Symplify\EasyCodingStandard\Config\ECSConfig;
3031
use Symplify\EasyCodingStandard\ValueObject\Option;
3132
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
3233

33-
return static function (ContainerConfigurator $containerConfigurator): void {
34-
$parameters = $containerConfigurator->parameters();
34+
return static function (ECSConfig $ecsConfig): void {
35+
$ecsConfig->paths([
36+
__DIR__ . '/src',
37+
__DIR__ . '/tests',
38+
__FILE__,
39+
]);
3540

41+
$parameters = $ecsConfig->parameters();
3642
$parameters->set(Option::INDENTATION, 'spaces');
3743
$parameters->set(Option::LINE_ENDING, "\n");
3844
$parameters->set(Option::PARALLEL, true);
39-
$parameters->set(Option::PATHS, [
40-
__DIR__.'/src',
41-
__DIR__.'/tests',
42-
__FILE__,
43-
]);
4445

45-
$containerConfigurator->import(SetList::PHP_CS_FIXER);
46-
$containerConfigurator->import(SetList::PHP_CS_FIXER_RISKY);
46+
$ecsConfig->sets([SetList::PSR_12]);
4747

48-
$parameters->set(Option::SKIP, [
49-
FinalInternalClassFixer::class => [
50-
__DIR__.'/src',
51-
],
52-
PhpdocToCommentFixer::class,
53-
PhpUnitTestClassRequiresCoversFixer::class,
54-
PhpUnitStrictFixer::class,
55-
]);
48+
$ecsConfig->rule(DeclareStrictTypesFixer::class);
49+
$ecsConfig->rule(PhpUnitInternalClassFixer::class);
50+
$ecsConfig->rule(UseArrowFunctionsFixer::class);
5651

57-
$services = $containerConfigurator->services();
58-
$services->set(DeclareStrictTypesFixer::class);
59-
$services->set(FopenFlagsFixer::class)->call('configure', [[
60-
'b_mode' => true,
61-
]]);
62-
$services->set(NativeFunctionInvocationFixer::class)->call('configure', [[
63-
'include' => [
64-
'@all',
65-
],
66-
'scope' => 'all',
67-
'strict' => true,
68-
]]);
69-
$services->set(NoAliasFunctionsFixer::class);
70-
$services->set(NoSuperfluousPhpdocTagsFixer::class)->call('configure', [[
71-
'allow_mixed' => true,
72-
'allow_unused_params' => false,
73-
]]);
74-
$services->set(NoUselessSprintfFixer::class);
75-
$services->set(OrderedClassElementsFixer::class)->call('configure', [[
76-
'order' => ['use_trait'],
77-
]]);
78-
$services->set(PhpdocAlignFixer::class)->call('configure', [[
52+
$ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, [
7953
'align' => 'left',
80-
]]);
81-
$services->set(PhpdocTypesOrderFixer::class)->call('configure', [[
82-
'sort_algorithm' => 'none',
83-
'null_adjustment' => 'always_last',
84-
]]);
85-
$services->set(PhpUnitInternalClassFixer::class);
86-
$services->set(PhpUnitMethodCasingFixer::class)->call('configure', [['case' => 'snake_case']]);
87-
$services->set(PhpUnitTestAnnotationFixer::class)->call('configure', [['style' => 'annotation']]);
88-
$services->set(UseArrowFunctionsFixer::class);
89-
$services->set(YodaStyleFixer::class)->call('configure', [[
90-
'equal' => null,
91-
'identical' => null,
92-
'less_and_greater' => null,
93-
'always_move_variable' => false,
94-
]]);
95-
$services->set(PhpUnitTestCaseStaticMethodCallsFixer::class)->call('configure', [[
96-
'call_type' => 'this',
97-
]]);
54+
]);
55+
56+
$ecsConfig->ruleWithConfiguration(PhpUnitMethodCasingFixer::class, [
57+
'case' => 'snake_case',
58+
]);
59+
$ecsConfig->ruleWithConfiguration(PhpUnitTestAnnotationFixer::class, [
60+
'style' => 'annotation',
61+
]);
9862
};

src/FirebaseProjectManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function project(?string $name = null): FirebaseProject
3838

3939
protected function configuration(string $name): array
4040
{
41-
$config = $this->app->config->get('firebase.projects.'.$name);
41+
$config = $this->app->config->get('firebase.projects.' . $name);
4242

4343
if (!$config) {
4444
throw new InvalidArgumentException("Firebase project [{$name}] not configured.");

src/ServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ public function boot(): void
1818
// @codeCoverageIgnoreEnd
1919

2020
$this->publishes([
21-
__DIR__.'/../config/firebase.php' => $this->app->configPath('firebase.php'),
21+
__DIR__ . '/../config/firebase.php' => $this->app->configPath('firebase.php'),
2222
], 'config');
2323
}
2424

2525
public function register(): void
2626
{
27-
$this->mergeConfigFrom(__DIR__.'/../config/firebase.php', 'firebase');
27+
$this->mergeConfigFrom(__DIR__ . '/../config/firebase.php', 'firebase');
2828

2929
$this->registerManager();
3030
$this->registerComponents();

tests/FirebaseProjectManagerTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class FirebaseProjectManagerTest extends TestCase
1818
{
1919
protected function defineEnvironment($app): void
2020
{
21-
$app['config']->set('firebase.projects.app.credentials.file', __DIR__.'/_fixtures/service_account.json');
21+
$app['config']->set('firebase.projects.app.credentials.file', __DIR__ . '/_fixtures/service_account.json');
2222
}
2323

2424
/**
@@ -68,12 +68,12 @@ public function calls_are_passed_to_default_project(): void
6868
public function credentials_can_be_configured(): void
6969
{
7070
// Reference credentials
71-
$credentialsPath = \realpath(__DIR__.'/_fixtures/service_account.json');
71+
$credentialsPath = \realpath(__DIR__ . '/_fixtures/service_account.json');
7272
$credentials = \json_decode(\file_get_contents($credentialsPath), true);
7373

7474
// Set configuration and retrieve project
7575
$projectName = 'app';
76-
$this->app->config->set('firebase.projects.'.$projectName.'.credentials.file', \realpath(__DIR__.'/_fixtures/service_account.json'));
76+
$this->app->config->set('firebase.projects.' . $projectName . '.credentials.file', \realpath(__DIR__ . '/_fixtures/service_account.json'));
7777
$factory = $this->factoryForProject($projectName);
7878

7979
// Retrieve service account
@@ -90,19 +90,19 @@ public function credentials_can_be_configured(): void
9090
public function projects_can_have_different_credentials(): void
9191
{
9292
// Reference credentials
93-
$credentialsPath = \realpath(__DIR__.'/_fixtures/service_account.json');
93+
$credentialsPath = \realpath(__DIR__ . '/_fixtures/service_account.json');
9494
$credentials = \json_decode(\file_get_contents($credentialsPath), true);
9595

96-
$secondCredentialsPath = \realpath(__DIR__.'/_fixtures/another_service_account.json');
96+
$secondCredentialsPath = \realpath(__DIR__ . '/_fixtures/another_service_account.json');
9797
$secondCredentials = \json_decode(\file_get_contents($secondCredentialsPath), true);
9898

9999
// Project names to use
100100
$projectName = 'app';
101101
$secondProjectName = 'another-app';
102102

103103
// Set service accounts explicitly
104-
$this->app->config->set('firebase.projects.'.$projectName.'.credentials.file', \realpath(__DIR__.'/_fixtures/service_account.json'));
105-
$this->app->config->set('firebase.projects.'.$secondProjectName.'.credentials.file', \realpath(__DIR__.'/_fixtures/another_service_account.json'));
104+
$this->app->config->set('firebase.projects.' . $projectName . '.credentials.file', \realpath(__DIR__ . '/_fixtures/service_account.json'));
105+
$this->app->config->set('firebase.projects.' . $secondProjectName . '.credentials.file', \realpath(__DIR__ . '/_fixtures/another_service_account.json'));
106106

107107
// Retrieve factories and service accounts
108108
$factory = $this->factoryForProject($projectName);
@@ -142,7 +142,7 @@ public function credential_auto_discovery_can_be_disabled_for_default_project():
142142
{
143143
$projectName = $this->app->config->get('firebase.default');
144144

145-
$this->app->config->set('firebase.projects.'.$projectName.'.credentials.auto_discovery', false);
145+
$this->app->config->set('firebase.projects.' . $projectName . '.credentials.auto_discovery', false);
146146

147147
$factory = $this->factoryForProject($projectName);
148148

@@ -158,7 +158,7 @@ public function credential_auto_discovery_is_not_enabled_by_default_for_other_pr
158158
{
159159
$projectName = 'another-app';
160160

161-
$this->app->config->set('firebase.projects.'.$projectName.'.credentials', []);
161+
$this->app->config->set('firebase.projects.' . $projectName . '.credentials', []);
162162

163163
$factory = $this->factoryForProject($projectName); // factory for default project with default settings
164164

@@ -174,7 +174,7 @@ public function credential_auto_discovery_can_be_enabled_for_other_project(): vo
174174
{
175175
$projectName = 'another-app';
176176

177-
$this->app->config->set('firebase.projects.'.$projectName.'.credentials.auto_discovery', true);
177+
$this->app->config->set('firebase.projects.' . $projectName . '.credentials.auto_discovery', true);
178178

179179
$factory = $this->factoryForProject($projectName);
180180

@@ -189,8 +189,8 @@ public function credential_auto_discovery_can_be_enabled_for_other_project(): vo
189189
public function the_realtime_database_url_can_be_configured(): void
190190
{
191191
$projectName = $this->app->config->get('firebase.default');
192-
$this->app->config->set('firebase.projects.'.$projectName.'.database.url', $url = 'https://domain.tld');
193-
$this->app->config->set('firebase.projects.'.$projectName.'.database.auth_variable_override', ['uid' => 'some-uid']);
192+
$this->app->config->set('firebase.projects.' . $projectName . '.database.url', $url = 'https://domain.tld');
193+
$this->app->config->set('firebase.projects.' . $projectName . '.database.auth_variable_override', ['uid' => 'some-uid']);
194194

195195
$database = $this->app->make(Firebase\Contract\Database::class);
196196

@@ -205,7 +205,7 @@ public function the_realtime_database_url_can_be_configured(): void
205205
public function the_dynamic_links_default_domain_can_be_configured(): void
206206
{
207207
$projectName = $this->app->config->get('firebase.default');
208-
$this->app->config->set('firebase.projects.'.$projectName.'.dynamic_links.default_domain', $domain = 'https://domain.tld');
208+
$this->app->config->set('firebase.projects.' . $projectName . '.dynamic_links.default_domain', $domain = 'https://domain.tld');
209209

210210
$dynamicLinks = $this->app->make(Firebase\Contract\DynamicLinks::class);
211211

@@ -222,7 +222,7 @@ public function the_dynamic_links_default_domain_can_be_configured(): void
222222
public function the_storage_default_bucket_can_be_configured(): void
223223
{
224224
$projectName = $this->app->config->get('firebase.default');
225-
$this->app->config->set('firebase.projects.'.$projectName.'.storage.default_bucket', $name = 'my-bucket');
225+
$this->app->config->set('firebase.projects.' . $projectName . '.storage.default_bucket', $name = 'my-bucket');
226226

227227
$storage = $this->app->make(Firebase\Contract\Storage::class);
228228

@@ -237,7 +237,7 @@ public function the_storage_default_bucket_can_be_configured(): void
237237
public function logging_can_be_configured(): void
238238
{
239239
$projectName = $this->app->config->get('firebase.default');
240-
$this->app->config->set('firebase.projects.'.$projectName.'.logging.http_log_channel', 'stack');
240+
$this->app->config->set('firebase.projects.' . $projectName . '.logging.http_log_channel', 'stack');
241241

242242
$factory = $this->factoryForProject($projectName);
243243

@@ -252,7 +252,7 @@ public function logging_can_be_configured(): void
252252
public function debug_logging_can_be_configured(): void
253253
{
254254
$projectName = $this->app->config->get('firebase.default');
255-
$this->app->config->set('firebase.projects.'.$projectName.'.logging.http_debug_log_channel', 'stack');
255+
$this->app->config->set('firebase.projects.' . $projectName . '.logging.http_debug_log_channel', 'stack');
256256

257257
$factory = $this->factoryForProject($projectName);
258258

@@ -267,8 +267,8 @@ public function debug_logging_can_be_configured(): void
267267
public function http_client_options_can_be_configured(): void
268268
{
269269
$projectName = $this->app->config->get('firebase.default');
270-
$this->app->config->set('firebase.projects.'.$projectName.'.http_client_options.proxy', 'proxy.domain.tld');
271-
$this->app->config->set('firebase.projects.'.$projectName.'.http_client_options.timeout', 1.23);
270+
$this->app->config->set('firebase.projects.' . $projectName . '.http_client_options.proxy', 'proxy.domain.tld');
271+
$this->app->config->set('firebase.projects.' . $projectName . '.http_client_options.timeout', 1.23);
272272

273273
$factory = $this->factoryForProject($projectName);
274274

tests/ServiceProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class ServiceProviderTest extends TestCase
1616
*/
1717
public function it_provides_components(): void
1818
{
19-
$this->app->config->set('firebase.projects.app.credentials.file', \realpath(__DIR__.'/_fixtures/service_account.json'));
19+
$this->app->config->set('firebase.projects.app.credentials.file', \realpath(__DIR__ . '/_fixtures/service_account.json'));
2020

2121
$this->assertInstanceOf(Firebase\Contract\Auth::class, $this->app->make(Firebase\Contract\Auth::class));
2222
$this->assertInstanceOf(Firebase\Contract\Database::class, $this->app->make(Firebase\Contract\Database::class));

0 commit comments

Comments
 (0)