Skip to content

Commit 12ce7cd

Browse files
committed
Add php-cs-fixer
1 parent 19bc0ee commit 12ce7cd

42 files changed

Lines changed: 190 additions & 249 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- uses: php-actions/composer@v6 # or alternative dependency management
1212
- uses: php-actions/phpunit@v4
13+
- name: Run PHP CS Fixer
14+
run: php vendor/bin/php-cs-fixer fix --dry-run --diff

.php-cs-fixer.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"php":"8.4.13","version":"3.75.0:v3.75.0#399a128ff2fdaf4281e4e79b755693286cdf325c","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_before_statement":{"statements":["return"]},"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"function_declaration":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["break","continue","extra","return","throw","use","parenthesis_brace_block","square_brace_block","curly_brace_block"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_hidden_params":true,"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_braces":{"namespaces":true},"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration":true,"nullable_type_declaration_for_default_null_value":true,"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"ordered_types":{"null_adjustment":"always_last","sort_algorithm":"none"},"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":{"order":["param","return","throws"]},"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":{"groups":[["Annotation","NamedArgumentConstructor","Target"],["author","copyright","license"],["category","package","subpackage"],["property","property-read","property-write"],["deprecated","link","see","since"]]},"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":{"group_to_single_imports":false},"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"statement_indentation":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":{"after_heredoc":true,"elements":["array_destructuring","arrays","match","parameters"]},"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"whitespace_after_comma_in_array":true,"yoda_style":{"equal":false,"identical":false,"less_and_greater":false,"always_move_variable":false},"array_indentation":true,"array_syntax":{"syntax":"short"},"cast_spaces":true,"new_with_parentheses":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":true,"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_push":true,"combine_nested_dirname":true,"dir_constant":true,"ereg_to_preg":true,"error_suppression":true,"fopen_flag_order":true,"fopen_flags":{"b_mode":false},"function_to_constant":true,"get_class_to_class_keyword":true,"implode_call":true,"is_null":true,"logical_operators":true,"long_to_shorthand_operator":true,"modernize_strpos":true,"modernize_types_casting":true,"native_constant_invocation":{"strict":false},"native_function_invocation":{"include":["@compiler_optimized"]},"no_alias_functions":true,"no_homoglyph_names":true,"no_php4_constructor":true,"no_unneeded_final_method":true,"no_useless_sprintf":true,"non_printable_character":true,"ordered_traits":true,"php_unit_construct":true,"php_unit_mock_short_will_return":true,"php_unit_set_up_tear_down_visibility":true,"php_unit_test_annotation":true,"psr_autoloading":true,"self_accessor":true,"set_type_to_cast":true,"string_length_to_empty":true,"string_line_ending":true,"ternary_to_elvis_operator":true,"pow_to_exponentiation":true,"no_trailing_whitespace_in_string":true,"no_unreachable_default_argument_value":true,"combine_consecutive_unsets":true},"hashes":{"src\/DependencyInjection\/Compiler\/DataflowTypeCompilerPass.php":"f451f87330d3c95f14ce6085ff3b252c","src\/DependencyInjection\/Compiler\/BusCompilerPass.php":"1ed15da70c0928889f26fae296cc248b","src\/DependencyInjection\/Compiler\/DefaultLoggerCompilerPass.php":"1cbb6d450a0f94787c5ae02fe5a6082a","src\/DependencyInjection\/CodeRhapsodieDataflowExtension.php":"e75faa7ad4f1ed49577a26f1f86bcf33","src\/DependencyInjection\/Configuration.php":"01c8c96aa6006dd2f67b80489e057d48","src\/Runner\/PendingDataflowRunner.php":"0561ae10d1ecea1a387f19eec50b3439","src\/Runner\/MessengerDataflowRunner.php":"fac48b1cf7e8582adb7a6cd2a2d4fc58","src\/Runner\/PendingDataflowRunnerInterface.php":"59043006c40e4dfe44f1785aaa290ca9","src\/Repository\/JobRepository.php":"4975a0de733179cffe4582b62c800197","src\/Repository\/InitFromDbTrait.php":"166a6a5ec65429f028099e406f787619","src\/Repository\/ScheduledDataflowRepository.php":"07ce67a02b8a7d5ccf43c4dbf9ed37a6","src\/Entity\/Job.php":"925bc2600e923890788cf18516c47581","src\/Entity\/ScheduledDataflow.php":"a6bd06504af21951482cbb2bffe51056","src\/DataflowType\/AutoUpdateCountInterface.php":"5a8653de3eb197f1dd605ad8766770d0","src\/DataflowType\/AbstractDataflowType.php":"d06e33405cbeaa5e21c24434b8ff207e","src\/DataflowType\/DataflowTypeInterface.php":"d1d47c313e1b5972aaa270fe6d182491","src\/DataflowType\/Writer\/PortWriterAdapter.php":"d3ffd9ad5ef488abf73261d7f4cd5b5d","src\/DataflowType\/Writer\/DelegatorWriter.php":"6ed30d117286d6dd6e453f3ed0f8d262","src\/DataflowType\/Writer\/CollectionWriter.php":"e04fb0084748c08c77d9af3bb02fee58","src\/DataflowType\/Writer\/DelegateWriterInterface.php":"15336223262db86647e6cec7665e5000","src\/DataflowType\/Writer\/WriterInterface.php":"20f9a6c60c044ed25d1bd6609cbbdfa3","src\/DataflowType\/DataflowBuilder.php":"91af10f1f8df0194aed62e335597e83f","src\/DataflowType\/Result.php":"7b6f7f26735af7bfecfcf3a67b2bb205","src\/DataflowType\/AMPAsyncDataflowBuilder.php":"969b83f7d6e614e874a1f8cc228e82e5","src\/DataflowType\/Dataflow\/DataflowInterface.php":"19ddae8a205b1393792a61ad368b83ca","src\/DataflowType\/Dataflow\/AMPAsyncDataflow.php":"2b5edee1549ae2b58d828585d8ad4d3c","src\/DataflowType\/Dataflow\/Dataflow.php":"e288e93cb67bf1eb067cbb94faf8c3c5","src\/Manager\/ScheduledDataflowManagerInterface.php":"27618c58ded92b7bddff3b100850bd3c","src\/Manager\/ScheduledDataflowManager.php":"7b98b54e0c70c4763c12c3ae78c23c8a","src\/Command\/ChangeScheduleStatusCommand.php":"04f9345a1bb1ddb3a0292d1737d1bcf1","src\/Command\/DatabaseSchemaCommand.php":"525904f64559fdffeabbc044e1a52391","src\/Command\/ExecuteDataflowCommand.php":"35b6b47b180722950b3f338d82962c4f","src\/Command\/SchemaCommand.php":"37001aa1f1ed2c5dfdf3d6379ff95a6e","src\/Command\/AddScheduledDataflowCommand.php":"91488884b2f5ea56e9087df34f9e65c0","src\/Command\/JobShowCommand.php":"bace5ffc113b84be08b144989490479c","src\/Command\/ScheduleListCommand.php":"86bd08feaa0f24c4d06361433ba6418b","src\/Command\/RunPendingDataflowsCommand.php":"054cdafe2da013f6f01e7799ff0dd09f","src\/CodeRhapsodieDataflowBundle.php":"f5298ec9ac061dc6732e2f1f824de59e","src\/Factory\/ConnectionFactory.php":"5c09d051d4567a86207a497f5eb18974","src\/SchemaProvider\/DataflowSchemaProvider.php":"b222bd368a471a4ac685a15da56bdb46","src\/MessengerMode\/JobMessageHandler.php":"63e011e273226eed5683edeb23239629","src\/MessengerMode\/JobMessage.php":"2a5131eb1ae046c26e9ad5941ca1cec6","src\/Processor\/JobProcessorInterface.php":"5ee30d068611a28172ca1449f9b4580f","src\/Processor\/JobProcessor.php":"30b2d5dcd187e57b09e5a1374ae555fc","src\/Logger\/DelegatingLogger.php":"27f0c2c78cc77fa351e6d450307137eb","src\/Logger\/BufferHandler.php":"87b61a99f41bbfbeb04e6fc1f11225cd","src\/Exceptions\/UnsupportedItemTypeException.php":"7cf41fbc2b674a461da6833c662acc6c","src\/Exceptions\/UnknownDataflowTypeException.php":"0ade22a7cfe7f23ccedd8599c9256e89","src\/Exceptions\/InterruptedProcessingException.php":"a6c208183e65012e22ec954132188081","src\/Registry\/DataflowTypeRegistryInterface.php":"4273ff743f7886835a980a230b9df0f0","src\/Registry\/DataflowTypeRegistry.php":"cc9211b11f2778a6cc3c8cbea43ea71e","src\/Validator\/Constraints\/Frequency.php":"cd7362cdaebc76bb3a79dcac66c3a5b7","src\/Validator\/Constraints\/FrequencyValidator.php":"0bb6a01afbc6fdb6fc44ec7144993313","src\/Event\/CrEvent.php":"6b62e16872dcf235b2360343618344e5","src\/Event\/Events.php":"6992c62744aae1c016f54be50bce5746","src\/Event\/ProcessingEvent.php":"a86aca24299133cf897bbea60d853ff6"}}

.php-cs-fixer.dist.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->in('src')
5+
//->in('tests')
6+
->files()->name('*.php');
7+
8+
$config = new PhpCsFixer\Config();
9+
$config->setRules([
10+
'@Symfony' => true,
11+
'@Symfony:risky' => true,
12+
'@PSR12' => true,
13+
'array_syntax' => [
14+
'syntax' => 'short',
15+
],
16+
'combine_consecutive_unsets' => true,
17+
'native_function_invocation' => [
18+
'include' => [
19+
'@compiler_optimized',
20+
],
21+
],
22+
'no_extra_blank_lines' => [
23+
'tokens' => [
24+
'break',
25+
'continue',
26+
'extra',
27+
'return',
28+
'throw',
29+
'use',
30+
'parenthesis_brace_block',
31+
'square_brace_block',
32+
'curly_brace_block',
33+
],
34+
],
35+
'ordered_class_elements' => true,
36+
'ordered_imports' => true,
37+
'yoda_style' => [
38+
'equal' => false,
39+
'identical' => false,
40+
'less_and_greater' => false,
41+
'always_move_variable' => false,
42+
],
43+
])
44+
->setRiskyAllowed(true)
45+
->setFinder(
46+
$finder
47+
);
48+
49+
return $config;

.php_cs.dist

Lines changed: 0 additions & 12 deletions
This file was deleted.

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
},
6161
"require-dev": {
6262
"amphp/amp": "^2.5",
63+
"friendsofphp/php-cs-fixer": "^3.75",
6364
"phpunit/phpunit": "^11",
6465
"portphp/portphp": "^1.9",
6566
"rector/rector": "^1.0",

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
$rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
1818

1919
$rectorConfig->sets([
20-
SymfonySetList::SYMFONY_60,
20+
SymfonySetList::SYMFONY_70,
2121
SymfonySetList::SYMFONY_CODE_QUALITY,
2222
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
2323
LevelSetList::UP_TO_PHP_80,

src/Command/AddScheduledDataflowCommand.php

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,29 +27,27 @@ public function __construct(private DataflowTypeRegistryInterface $registry, pri
2727
parent::__construct();
2828
}
2929

30-
/**
31-
* {@inheritdoc}
32-
*/
3330
protected function configure(): void
3431
{
3532
$this
3633
->setHelp('The <info>%command.name%</info> allows you to create a new scheduled dataflow.')
3734
->addOption('label', null, InputOption::VALUE_REQUIRED, 'Label of the scheduled dataflow')
3835
->addOption('type', null, InputOption::VALUE_REQUIRED, 'Type of the scheduled dataflow (FQCN)')
39-
->addOption('options', null, InputOption::VALUE_OPTIONAL,
40-
'Options of the scheduled dataflow (ex: {"option1": "value1", "option2": "value2"})')
36+
->addOption(
37+
'options',
38+
null,
39+
InputOption::VALUE_OPTIONAL,
40+
'Options of the scheduled dataflow (ex: {"option1": "value1", "option2": "value2"})'
41+
)
4142
->addOption('frequency', null, InputOption::VALUE_REQUIRED, 'Frequency of the scheduled dataflow')
4243
->addOption('first_run', null, InputOption::VALUE_REQUIRED, 'Date for the first run of the scheduled dataflow (Y-m-d H:i:s)')
4344
->addOption('enabled', null, InputOption::VALUE_REQUIRED, 'State of the scheduled dataflow')
4445
->addOption('connection', null, InputOption::VALUE_REQUIRED, 'Define the DBAL connection to use');
4546
}
4647

47-
/**
48-
* {@inheritdoc}
49-
*/
5048
protected function execute(InputInterface $input, OutputInterface $output): int
5149
{
52-
if (null !== $input->getOption('connection')) {
50+
if ($input->getOption('connection') !== null) {
5351
$this->connectionFactory->setConnectionName($input->getOption('connection'));
5452
}
5553
$choices = [];
@@ -71,13 +69,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7169
}
7270
$options = $input->getOption('options');
7371
if (!$options) {
74-
$options = $io->ask('What are the launch options for the scheduled dataflow? (ex: {"option1": "value1", "option2": "value2"})',
75-
json_encode([]));
72+
$options = $io->ask(
73+
'What are the launch options for the scheduled dataflow? (ex: {"option1": "value1", "option2": "value2"})',
74+
json_encode([])
75+
);
7676
}
7777
$frequency = $input->getOption('frequency');
7878
if (!$frequency) {
79-
$frequency = $io->choice('What is the frequency for the scheduled dataflow?',
80-
ScheduledDataflow::AVAILABLE_FREQUENCIES);
79+
$frequency = $io->choice(
80+
'What is the frequency for the scheduled dataflow?',
81+
ScheduledDataflow::AVAILABLE_FREQUENCIES
82+
);
8183
}
8284
$firstRun = $input->getOption('first_run');
8385
if (!$firstRun) {
@@ -92,22 +94,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9294
'id' => null,
9395
'label' => $label,
9496
'dataflow_type' => $type,
95-
'options' => json_decode($options, true, 512, JSON_THROW_ON_ERROR),
97+
'options' => json_decode($options, true, 512, \JSON_THROW_ON_ERROR),
9698
'frequency' => $frequency,
9799
'next' => new \DateTime($firstRun),
98100
'enabled' => $enabled,
99101
]);
100102

101103
$errors = $this->validator->validate($newScheduledDataflow);
102-
if (count($errors) > 0) {
104+
if (\count($errors) > 0) {
103105
$io->error((string) $errors);
104106

105107
return 2;
106108
}
107109

108110
$this->scheduledDataflowRepository->save($newScheduledDataflow);
109-
$io->success(sprintf('New scheduled dataflow "%s" (id:%d) was created successfully.',
110-
$newScheduledDataflow->getLabel(), $newScheduledDataflow->getId()));
111+
$io->success(\sprintf(
112+
'New scheduled dataflow "%s" (id:%d) was created successfully.',
113+
$newScheduledDataflow->getLabel(),
114+
$newScheduledDataflow->getId()
115+
));
111116

112117
return 0;
113118
}

src/Command/ChangeScheduleStatusCommand.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ public function __construct(private ScheduledDataflowRepository $scheduledDatafl
2626
parent::__construct();
2727
}
2828

29-
/**
30-
* {@inheritdoc}
31-
*/
3229
protected function configure(): void
3330
{
3431
$this
@@ -39,20 +36,17 @@ protected function configure(): void
3936
->addOption('connection', null, InputOption::VALUE_REQUIRED, 'Define the DBAL connection to use');
4037
}
4138

42-
/**
43-
* {@inheritdoc}
44-
*/
4539
protected function execute(InputInterface $input, OutputInterface $output): int
4640
{
47-
if (null !== $input->getOption('connection')) {
41+
if ($input->getOption('connection') !== null) {
4842
$this->connectionFactory->setConnectionName($input->getOption('connection'));
4943
}
5044
$io = new SymfonyStyle($input, $output);
5145
/** @var ScheduledDataflow|null $schedule */
5246
$schedule = $this->scheduledDataflowRepository->find((int) $input->getArgument('schedule-id'));
5347

5448
if (!$schedule) {
55-
$io->error(sprintf('Cannot find scheduled dataflow with id "%d".', $input->getArgument('schedule-id')));
49+
$io->error(\sprintf('Cannot find scheduled dataflow with id "%d".', $input->getArgument('schedule-id')));
5650

5751
return 1;
5852
}
@@ -71,9 +65,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7165
try {
7266
$schedule->setEnabled($input->getOption('enable'));
7367
$this->scheduledDataflowRepository->save($schedule);
74-
$io->success(sprintf('Schedule with id "%s" has been successfully updated.', $schedule->getId()));
68+
$io->success(\sprintf('Schedule with id "%s" has been successfully updated.', $schedule->getId()));
7569
} catch (\Exception $e) {
76-
$io->error(sprintf('An error occured when changing schedule status : "%s".', $e->getMessage()));
70+
$io->error(\sprintf('An error occured when changing schedule status : "%s".', $e->getMessage()));
7771

7872
return 4;
7973
}

0 commit comments

Comments
 (0)