Skip to content

Commit b2005a1

Browse files
committed
refactor: reformat code with mago formatter / linter
1 parent d78fd77 commit b2005a1

4,088 files changed

Lines changed: 106124 additions & 93506 deletions

File tree

Some content is hidden

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

bin/docs.php

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33

44
declare(strict_types=1);
55

6-
use Flow\Documentation\{FunctionCollector, FunctionsExtractor, MethodCollector, MethodsExtractor};
6+
use Flow\Documentation\FunctionCollector;
7+
use Flow\Documentation\FunctionsExtractor;
8+
use Flow\Documentation\MethodCollector;
9+
use Flow\Documentation\MethodsExtractor;
710
use Flow\ETL\Attribute\Module;
11+
use Flow\ETL\DataFrame;
812
use Flow\ETL\DataFrame\GroupedDataFrame;
9-
use Flow\ETL\{DataFrame, Flow};
13+
use Flow\ETL\Flow;
1014
use Flow\ETL\Function\ScalarFunctionChain;
1115
use Symfony\Component\Console\Application;
1216
use Symfony\Component\Console\Command\Command;
13-
use Symfony\Component\Console\Input\{InputArgument, InputInterface};
17+
use Symfony\Component\Console\Input\InputArgument;
18+
use Symfony\Component\Console\Input\InputInterface;
1419
use Symfony\Component\Console\Output\OutputInterface;
1520

1621
require __DIR__ . '/../vendor/autoload.php';
@@ -32,18 +37,23 @@
3237
$application = new Application('Flow-PHP - Documentation');
3338

3439
$application->add(new class extends Command {
35-
public function configure() : void
40+
public function configure(): void
3641
{
3742
$this
3843
->setName('dsl:dump')
3944
->setDescription('Dump DSL into json file.')
40-
->addOption('repository-root-path', null, InputArgument::OPTIONAL, 'Repository root path.', dirname(__DIR__) . '/')
45+
->addOption(
46+
'repository-root-path',
47+
null,
48+
InputArgument::OPTIONAL,
49+
'Repository root path.',
50+
dirname(__DIR__) . '/',
51+
)
4152
->addArgument('output', InputArgument::REQUIRED, 'Where to dump dsl.');
4253
}
4354

44-
public function execute(InputInterface $input, OutputInterface $output) : int
55+
public function execute(InputInterface $input, OutputInterface $output): int
4556
{
46-
4757
$paths = [
4858
__DIR__ . '/../src/core/etl/src/Flow/ETL/DSL/functions.php',
4959
__DIR__ . '/../src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/functions.php',
@@ -71,23 +81,21 @@ public function execute(InputInterface $input, OutputInterface $output) : int
7181
__DIR__ . '/../src/bridge/filesystem/azure/src/Flow/Filesystem/Bridge/Azure/DSL/functions.php',
7282
__DIR__ . '/../src/bridge/filesystem/async-aws/src/Flow/Filesystem/Bridge/AsyncAWS/DSL/functions.php',
7383
__DIR__ . '/../src/bridge/monolog/telemetry/src/Flow/Bridge/Monolog/Telemetry/DSL/functions.php',
74-
__DIR__ . '/../src/bridge/symfony/http-foundation-telemetry/src/Flow/Bridge/Symfony/HttpFoundationTelemetry/DSL/functions.php',
75-
__DIR__ . '/../src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DSL/functions.php',
84+
__DIR__
85+
. '/../src/bridge/symfony/http-foundation-telemetry/src/Flow/Bridge/Symfony/HttpFoundationTelemetry/DSL/functions.php',
86+
__DIR__
87+
. '/../src/bridge/symfony/telemetry-bundle/src/Flow/Bridge/Symfony/TelemetryBundle/DSL/functions.php',
7688
__DIR__ . '/../src/bridge/psr7/telemetry/src/Flow/Bridge/Psr7/Telemetry/DSL/functions.php',
7789
__DIR__ . '/../src/bridge/psr18/telemetry/src/Flow/Bridge/Psr18/Telemetry/DSL/functions.php',
7890
__DIR__ . '/../src/bridge/telemetry/otlp/src/Flow/Bridge/Telemetry/OTLP/DSL/functions.php',
7991
];
8092

81-
$extractor = new FunctionsExtractor(
82-
$input->getOption('repository-root-path'),
83-
new FunctionCollector()
84-
);
93+
$extractor = new FunctionsExtractor($input->getOption('repository-root-path'), new FunctionCollector());
8594

8695
$normalizedFunctions = [];
8796

8897
foreach ($extractor->extract($paths) as $function) {
8998
if (($attribute = $function->attributes->findByName('DocumentationDSL')) !== null) {
90-
9199
if ($attribute->arguments['module'] === Module::DEPRECATED) {
92100
continue;
93101
}
@@ -96,22 +104,25 @@ public function execute(InputInterface $input, OutputInterface $output) : int
96104
$normalizedFunctions[] = $function->normalize();
97105
}
98106

99-
\file_put_contents(__DIR__ . '/../' . \ltrim((string) $input->getArgument('output'), '/'), \json_encode($normalizedFunctions));
107+
\file_put_contents(
108+
__DIR__ . '/../' . \ltrim((string) $input->getArgument('output'), '/'),
109+
\json_encode($normalizedFunctions),
110+
);
100111

101112
return Command::SUCCESS;
102113
}
103114
});
104115

105116
$application->add(new class extends Command {
106-
public function configure() : void
117+
public function configure(): void
107118
{
108119
$this
109120
->setName('api:dump')
110121
->setDescription('Dump API methods from classes into json file.')
111122
->addArgument('output', InputArgument::REQUIRED, 'Where to dump methods.');
112123
}
113124

114-
public function execute(InputInterface $input, OutputInterface $output) : int
125+
public function execute(InputInterface $input, OutputInterface $output): int
115126
{
116127
$repositoryRootPath = dirname(__DIR__) . '/';
117128

@@ -125,18 +136,17 @@ public function execute(InputInterface $input, OutputInterface $output) : int
125136
$normalizedMethods = [];
126137

127138
foreach ($classes as $className) {
128-
$extractor = new MethodsExtractor(
129-
$repositoryRootPath,
130-
$className,
131-
new MethodCollector()
132-
);
139+
$extractor = new MethodsExtractor($repositoryRootPath, $className, new MethodCollector());
133140

134141
foreach ($extractor->extract() as $method) {
135142
$normalizedMethods[] = $method->normalize();
136143
}
137144
}
138145

139-
\file_put_contents(__DIR__ . '/../' . \ltrim((string) $input->getArgument('output'), '/'), \json_encode($normalizedMethods));
146+
\file_put_contents(
147+
__DIR__ . '/../' . \ltrim((string) $input->getArgument('output'), '/'),
148+
\json_encode($normalizedMethods),
149+
);
140150

141151
return Command::SUCCESS;
142152
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@
351351
],
352352
"cs:php:fix": [
353353
"tools/mago/vendor/bin/mago format",
354-
"tools/mago/vendor/bin/mago lint --fix"
354+
"tools/mago/vendor/bin/mago lint --fix --potentially-unsafe --format-after-fix"
355355
],
356356
"build:phar": [
357357
"bin/build-phar.sh",

mago.toml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ enable-short-tags = false
2020

2121
[linter]
2222
integrations = ["symfony", "phpunit"]
23+
excludes = [
24+
"**/Flow/Parquet/ThriftModel/**",
25+
"**/Flow/Parquet/Thrift/**",
26+
"**/otlp/src/Opentelemetry/**",
27+
"**/otlp/src/GPBMetadata/**",
28+
"**/lib/postgresql/src/Flow/PostgreSql/Protobuf/**",
29+
]
2330

2431
[linter.rules]
2532
cyclomatic-complexity = { enabled = false }
@@ -66,6 +73,29 @@ use-specific-assertions = { enabled = false }
6673
prefer-first-class-callable = { enabled = false }
6774
final-controller = { enabled = false }
6875
prefer-interface = { enabled = false }
76+
no-shorthand-ternary = { enabled = false }
77+
no-error-control-operator = { enabled = false }
78+
no-literal-password = { enabled = false }
79+
no-ini-set = { enabled = false }
80+
instanceof-stringable = { enabled = false }
81+
no-redundant-file = { enabled = false }
82+
no-sprintf-concat = { enabled = false }
83+
no-global = { enabled = false }
84+
no-redundant-method-override = { enabled = false }
6985
no-redundant-else = { enabled = true, level = "warning" }
70-
no-redundant-variable = { enabled = true, level = "warning" }
86+
# Bug in Mago 1.26 - revisit when resolved
87+
no-redundant-variable = { enabled = true, level = "warning", exclude = [
88+
"**/Flow/ETL/Function/ScalarFunctionChain.php",
89+
"**/Flow/ETL/DataFrame.php",
90+
"**/Flow/ETL/Row/EntryReference.php",
91+
"**/Flow/ETL/Sort/SortAlgorithms.php",
92+
"**/Flow/PostgreSql/QueryBuilder/**",
93+
"**/Flow/PostgreSql/Tests/Unit/QueryBuilder/Expression/MockExpression.php",
94+
"**/Flow/PostgreSql/Explain/Plan/PlanNodeType.php",
95+
"**/Flow/Filesystem/Path.php",
96+
"**/CacheSpyClient.php",
97+
"**/Tests/Unit/ObjectExtractorTest.php",
98+
"**/array-dot/src/Flow/ArrayDot/array_dot.php",
99+
"**/TracableHttpClientTest.php",
100+
] }
71101
strict-types = { enabled = true, level = "error" }

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ parameters:
9797
- src/cli/src/Flow/CLI/Command/*
9898
- src/core/etl/src/Flow/ETL/Formatter/ASCII/ASCIITable.php
9999
- src/core/etl/src/Flow/ETL/Formatter/ASCII/ASCIIValue.php
100+
- src/core/etl/tests/Flow/ETL/Tests/Fixtures/empty.php
100101
- src/core/etl/src/Flow/ETL/Sort/ExternalSort/RowsMinHeap.php
101102
- src/adapter/etl-adapter-avro/*
102103
- src/adapter/etl-adapter-elasticsearch/src/Flow/ETL/Adapter/Elasticsearch/ElasticsearchPHP/SearchResults.php
@@ -190,6 +191,22 @@ parameters:
190191
path: src/core/etl/src/Flow/Calculator/Calculator.php
191192
identifier: argument.type
192193
reportUnmatched: false
194+
-
195+
path: src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalKeySetExtractor.php
196+
identifier: method.notFound
197+
reportUnmatched: false
198+
-
199+
path: src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalKeySetExtractor.php
200+
identifier: function.alreadyNarrowedType
201+
reportUnmatched: false
202+
-
203+
path: src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalLimitOffsetExtractor.php
204+
identifier: method.notFound
205+
reportUnmatched: false
206+
-
207+
path: src/adapter/etl-adapter-doctrine/src/Flow/ETL/Adapter/Doctrine/DbalLimitOffsetExtractor.php
208+
identifier: function.alreadyNarrowedType
209+
reportUnmatched: false
193210

194211
includes:
195212
- tools/phpstan/vendor/spaze/phpstan-disallowed-calls/extension.neon

src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/FlixTech/AvroExtractor.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,34 @@
44

55
namespace Flow\ETL\Adapter\Avro\FlixTech;
66

7-
use Flow\ETL\{Exception\RuntimeException, Extractor, FlowContext};
8-
use Flow\ETL\Extractor\{FileExtractor, Limitable, LimitableExtractor};
7+
use Flow\ETL\Exception\RuntimeException;
8+
use Flow\ETL\Extractor;
9+
use Flow\ETL\Extractor\FileExtractor;
10+
use Flow\ETL\Extractor\Limitable;
11+
use Flow\ETL\Extractor\LimitableExtractor;
912
use Flow\ETL\Extractor\PathFiltering;
13+
use Flow\ETL\FlowContext;
1014
use Flow\Filesystem\Path;
1115

1216
final class AvroExtractor implements Extractor, FileExtractor, LimitableExtractor
1317
{
1418
use Limitable;
1519
use PathFiltering;
1620

17-
public function __construct(private readonly Path $path)
18-
{
19-
throw new RuntimeException('Avro integration was abandoned due to lack of availability of good Avro libraries.');
21+
public function __construct(
22+
private readonly Path $path,
23+
) {
24+
throw new RuntimeException(
25+
'Avro integration was abandoned due to lack of availability of good Avro libraries.',
26+
);
2027
}
2128

22-
public function extract(FlowContext $context) : \Generator
29+
public function extract(FlowContext $context): \Generator
2330
{
2431
yield;
2532
}
2633

27-
public function source() : Path
34+
public function source(): Path
2835
{
2936
return $this->path;
3037
}

src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/FlixTech/AvroLoader.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
namespace Flow\ETL\Adapter\Avro\FlixTech;
66

7-
use Flow\ETL\{Exception\RuntimeException, FlowContext, Loader, Rows};
8-
use Flow\ETL\Loader\{Closure, FileLoader};
7+
use Flow\ETL\Exception\RuntimeException;
8+
use Flow\ETL\FlowContext;
9+
use Flow\ETL\Loader;
10+
use Flow\ETL\Loader\Closure;
11+
use Flow\ETL\Loader\FileLoader;
12+
use Flow\ETL\Rows;
913
use Flow\ETL\Schema;
1014
use Flow\Filesystem\Path;
1115
use Flow\Filesystem\Path\Option;
@@ -19,20 +23,18 @@ public function __construct(
1923
Path $path,
2024
private ?Schema $schema = null,
2125
) {
22-
throw new RuntimeException('Avro integration was abandoned due to lack of availability of good Avro libraries.');
26+
throw new RuntimeException(
27+
'Avro integration was abandoned due to lack of availability of good Avro libraries.',
28+
);
2329
$this->path = $path->setOptionWhenEmpty(Option::CONTENT_TYPE->value, ContentType::AVRO);
2430
}
2531

26-
public function closure(FlowContext $context) : void
27-
{
28-
}
32+
public function closure(FlowContext $context): void {}
2933

30-
public function destination() : Path
34+
public function destination(): Path
3135
{
3236
return $this->path;
3337
}
3438

35-
public function load(Rows $rows, FlowContext $context) : void
36-
{
37-
}
39+
public function load(Rows $rows, FlowContext $context): void {}
3840
}

src/adapter/etl-adapter-avro/src/Flow/ETL/Adapter/Avro/functions.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44

55
namespace Flow\ETL\DSL\Adapter\Avro;
66

7-
use function Flow\Filesystem\DSL\path_real;
8-
use Flow\ETL\Adapter\Avro\FlixTech\{AvroExtractor, AvroLoader};
9-
use Flow\ETL\{Attribute\DocumentationDSL, Attribute\Module, Attribute\Type, Schema};
7+
use Flow\ETL\Adapter\Avro\FlixTech\AvroExtractor;
8+
use Flow\ETL\Adapter\Avro\FlixTech\AvroLoader;
9+
use Flow\ETL\Attribute\DocumentationDSL;
10+
use Flow\ETL\Attribute\Module;
11+
use Flow\ETL\Attribute\Type;
12+
use Flow\ETL\Schema;
1013
use Flow\Filesystem\Path;
1114

15+
use function Flow\Filesystem\DSL\path_real;
16+
1217
#[DocumentationDSL(module: Module::AVRO, type: Type::EXTRACTOR)]
13-
function from_avro(Path|string $path) : AvroExtractor
18+
function from_avro(Path|string $path): AvroExtractor
1419
{
15-
return new AvroExtractor(
16-
\is_string($path) ? path_real($path) : $path
17-
);
20+
return new AvroExtractor(\is_string($path) ? path_real($path) : $path);
1821
}
1922

2023
#[DocumentationDSL(module: Module::AVRO, type: Type::LOADER)]
21-
function to_avro(Path|string $path, ?Schema $schema = null) : AvroLoader
24+
function to_avro(Path|string $path, ?Schema $schema = null): AvroLoader
2225
{
23-
return new AvroLoader(
24-
\is_string($path) ? path_real($path) : $path,
25-
$schema
26-
);
26+
return new AvroLoader(\is_string($path) ? path_real($path) : $path, $schema);
2727
}

0 commit comments

Comments
 (0)