Skip to content

Commit e669556

Browse files
committed
Update Rector configuration & re-run it
1 parent cbb4305 commit e669556

21 files changed

Lines changed: 109 additions & 96 deletions

File tree

rector.src.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
__DIR__ . '/src/core/etl/src',
1515
__DIR__ . '/src/cli/src',
1616
__DIR__ . '/src/lib/*/src',
17-
__DIR__ . '/src/adapter/*/src',
18-
__DIR__ . '/src/bridge/*/*/src',
19-
__DIR__ . '/src/tools/*/*/src',
17+
__DIR__ . '/src/adapter/**/src',
18+
__DIR__ . '/src/bridge/**/src',
19+
__DIR__ . '/src/tools/**/src',
2020
])
2121
->withSkip([
2222
RemoveExtraParametersRector::class,
@@ -28,5 +28,5 @@
2828
->withCache(__DIR__ . '/var/rector/src')
2929
->withImportNames(importShortClasses: false, removeUnusedImports: true)
3030
->withSets([
31-
LevelSetList::UP_TO_PHP_82
32-
]);
31+
LevelSetList::UP_TO_PHP_82,
32+
]);

rector.tests.php

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
<?php
22

3+
use Flow\ETL\Adapter\Avro\FlixTech\AvroExtractor;
4+
use Flow\ETL\Adapter\CSV\CSVExtractor;
5+
use Flow\ETL\Adapter\Doctrine\DbalQueryExtractor;
6+
use Flow\ETL\Adapter\Elasticsearch\ElasticsearchPHP\ElasticsearchExtractor;
7+
use Flow\ETL\Adapter\Excel\ExcelExtractor;
8+
use Flow\ETL\Adapter\GoogleSheet\GoogleSheetExtractor;
9+
use Flow\ETL\Adapter\Http\PsrHttpClientDynamicExtractor;
10+
use Flow\ETL\Adapter\Http\PsrHttpClientStaticExtractor;
11+
use Flow\ETL\Adapter\JSON\JSONMachine\JsonExtractor;
12+
use Flow\ETL\Adapter\JSON\JSONMachine\JsonLinesExtractor;
13+
use Flow\ETL\Adapter\Meilisearch\MeilisearchPHP\MeilisearchExtractor;
14+
use Flow\ETL\Adapter\Parquet\ParquetExtractor;
15+
use Flow\ETL\Adapter\Text\TextExtractor;
16+
use Flow\ETL\Adapter\XML\XMLParserExtractor;
317
use Flow\ETL\Config;
418
use Flow\ETL\Extractor\ArrayExtractor;
519
use Flow\ETL\Extractor\CacheExtractor;
@@ -67,12 +81,12 @@
6781
__DIR__ . '/src/core/etl/tests',
6882
__DIR__ . '/src/cli/tests',
6983
__DIR__ . '/src/lib/*/tests',
70-
__DIR__ . '/src/adapter/*/tests',
71-
__DIR__ . '/src/bridge/*/*/tests',
72-
__DIR__ . '/src/tools/*/*/tests',
84+
__DIR__ . '/src/adapter/**/tests',
85+
__DIR__ . '/src/bridge/**/tests',
86+
__DIR__ . '/src/tools/**/tests',
7387
])
7488
->withSets([
75-
LevelSetList::UP_TO_PHP_82
89+
LevelSetList::UP_TO_PHP_82,
7690
])
7791
->withRules([
7892
DataProviderAnnotationToAttributeRector::class,
@@ -162,6 +176,21 @@
162176
new NewObjectToFunction(PipelineExtractor::class, 'from_pipeline'),
163177
new NewObjectToFunction(DataFrameExtractor::class, 'from_data_frame'),
164178

179+
// Adapters
180+
new NewObjectToFunction(AvroExtractor::class, 'Flow\ETL\DSL\Adapter\Avro\from_avro'),
181+
new NewObjectToFunction(CSVExtractor::class, 'Flow\ETL\Adapter\CSV\from_csv'),
182+
new NewObjectToFunction(DbalQueryExtractor::class, 'Flow\ETL\Adapter\Doctrine\from_dbal_query'),
183+
new NewObjectToFunction(ElasticsearchExtractor::class, 'Flow\ETL\Adapter\Elasticsearch\from_es'),
184+
new NewObjectToFunction(ExcelExtractor::class, 'Flow\ETL\Adapter\Excel\from_excel'),
185+
new NewObjectToFunction(GoogleSheetExtractor::class, 'Flow\ETL\Adapter\GoogleSheet\from_google_sheet'),
186+
new NewObjectToFunction(PsrHttpClientDynamicExtractor::class, 'Flow\ETL\Adapter\Http\from_dynamic_http_requests'),
187+
new NewObjectToFunction(PsrHttpClientStaticExtractor::class, 'Flow\ETL\Adapter\Http\from_static_http_requests'),
188+
new NewObjectToFunction(JsonExtractor::class, 'Flow\ETL\Adapter\JSON\from_json'),
189+
new NewObjectToFunction(JsonLinesExtractor::class, 'Flow\ETL\Adapter\JSON\from_json_lines'),
190+
new NewObjectToFunction(MeilisearchExtractor::class, 'Flow\ETL\Adapter\Meilisearch\from_meilisearch'),
191+
new NewObjectToFunction(ParquetExtractor::class, 'Flow\ETL\Adapter\Parquet\from_parquet'),
192+
new NewObjectToFunction(TextExtractor::class, 'Flow\ETL\Adapter\Text\from_text'),
193+
new NewObjectToFunction(XMLParserExtractor::class, 'Flow\ETL\Adapter\XML\from_xml'),
165194
]
166195
)
167196
->withSkip([
@@ -177,4 +206,4 @@
177206
importDocBlockNames: true,
178207
importShortClasses: false,
179208
removeUnusedImports: true
180-
);
209+
);

src/adapter/etl-adapter-avro/tests/Flow/ETL/Adapter/Avro/Tests/Integration/AvroTest.php

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

55
namespace Flow\ETL\Adapter\Avro\Tests\Integration;
66

7-
use function Flow\ETL\DSL\Adapter\Avro\to_avro;
7+
use function Flow\ETL\DSL\Adapter\Avro\{from_avro, to_avro};
88
use function Flow\ETL\DSL\{config, flow_context};
9-
use Flow\ETL\Adapter\Avro\FlixTech\AvroExtractor;
109
use Flow\ETL\Extractor\Signal;
1110
use Flow\ETL\Tests\FlowTestCase;
1211
use Flow\Filesystem\Path;
@@ -20,7 +19,7 @@ protected function setUp() : void
2019

2120
public function test_limit() : void
2221
{
23-
$extractor = new AvroExtractor(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
22+
$extractor = from_avro(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
2423
$extractor->changeLimit(2);
2524

2625
self::assertCount(
@@ -31,7 +30,7 @@ public function test_limit() : void
3130

3231
public function test_signal_stop() : void
3332
{
34-
$extractor = new AvroExtractor(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
33+
$extractor = from_avro(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
3534

3635
$generator = $extractor->extract(flow_context(config()));
3736

src/adapter/etl-adapter-csv/tests/Flow/ETL/Adapter/CSV/Tests/Integration/CSVExtractorTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use function Flow\ETL\Adapter\CSV\from_csv;
88
use function Flow\ETL\DSL\{df, print_schema, ref};
99
use function Flow\ETL\DSL\flow_context;
10-
use Flow\ETL\Adapter\CSV\CSVExtractor;
1110
use Flow\ETL\{Config, Row, Rows, Tests\FlowTestCase};
1211
use Flow\ETL\Extractor\Signal;
1312
use Flow\Filesystem\Path;
@@ -444,7 +443,7 @@ public function test_extracting_csv_with_multiline_strings() : void
444443
public function test_limit() : void
445444
{
446445

447-
$extractor = new CSVExtractor(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
446+
$extractor = from_csv(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
448447
$extractor->changeLimit(2);
449448

450449
self::assertCount(
@@ -477,7 +476,7 @@ public function test_loading_data_from_all_partitions() : void
477476

478477
public function test_signal_stop() : void
479478
{
480-
$extractor = new CSVExtractor(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
479+
$extractor = from_csv(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
481480

482481
$generator = $extractor->extract(flow_context(\Flow\ETL\DSL\config()));
483482

src/adapter/etl-adapter-http/tests/Flow/ETL/Adapter/HTTP/Tests/Integration/PsrHttpClientDynamicExtractorTest.php

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

55
namespace Flow\ETL\Adapter\HTTP\Tests\Integration;
66

7+
use function Flow\ETL\Adapter\Http\from_dynamic_http_requests;
78
use function Flow\ETL\DSL\{config, flow_context};
89
use Flow\ETL\Adapter\Http\DynamicExtractor\NextRequestFactory;
9-
use Flow\ETL\Adapter\Http\PsrHttpClientDynamicExtractor;
1010
use Flow\ETL\Tests\FlowTestCase;
1111
use Http\Mock\Client;
1212
use Nyholm\Psr7\Factory\Psr17Factory;
@@ -32,7 +32,7 @@ public function test_http_extractor() : void
3232
], $fixtureContent),
3333
);
3434

35-
$extractor = new PsrHttpClientDynamicExtractor($psr18Client, new class implements NextRequestFactory {
35+
$extractor = from_dynamic_http_requests($psr18Client, new class implements NextRequestFactory {
3636
public function create(?ResponseInterface $previousResponse = null) : ?RequestInterface
3737
{
3838
$psr17Factory = new Psr17Factory();

src/adapter/etl-adapter-http/tests/Flow/ETL/Adapter/HTTP/Tests/Integration/PsrHttpClientStaticExtractorTest.php

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

55
namespace Flow\ETL\Adapter\HTTP\Tests\Integration;
66

7+
use function Flow\ETL\Adapter\Http\from_static_http_requests;
78
use function Flow\ETL\DSL\{config, flow_context};
8-
use Flow\ETL\Adapter\Http\PsrHttpClientStaticExtractor;
99
use Flow\ETL\{Rows, Tests\FlowTestCase};
1010
use Http\Mock\Client;
1111
use Nyholm\Psr7\Factory\Psr17Factory;
@@ -48,7 +48,7 @@ public function test_http_extractor() : void
4848
->withHeader('User-Agent', 'flow-php/etl');
4949
};
5050

51-
$extractor = new PsrHttpClientStaticExtractor($psr18Client, $requests());
51+
$extractor = from_static_http_requests($psr18Client, $requests());
5252

5353
$rowsGenerator = $extractor->extract(flow_context(config()));
5454

src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JSONMachine/JsonExtractorTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use function Flow\ETL\Adapter\JSON\from_json;
88
use function Flow\ETL\DSL\{data_frame, flow_context};
99
use function Flow\ETL\DSL\{df, print_schema};
10-
use Flow\ETL\Adapter\JSON\JSONMachine\JsonExtractor;
1110
use Flow\ETL\{Config, Row, Rows, Tests\FlowTestCase};
1211
use Flow\ETL\Extractor\Signal;
1312
use Flow\Filesystem\Path;
@@ -105,7 +104,7 @@ public function test_extracting_json_from_local_file_stream_with_schema() : void
105104

106105
public function test_extracting_json_from_local_file_string_uri() : void
107106
{
108-
$extractor = new JsonExtractor(Path::realpath(__DIR__ . '/../../Fixtures/timezones.json'));
107+
$extractor = from_json(Path::realpath(__DIR__ . '/../../Fixtures/timezones.json'));
109108

110109
$total = 0;
111110

@@ -132,7 +131,7 @@ public function test_extracting_json_from_local_file_string_uri() : void
132131

133132
public function test_limit() : void
134133
{
135-
$extractor = new JsonExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.json'));
134+
$extractor = from_json(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.json'));
136135
$extractor->changeLimit(2);
137136

138137
self::assertCount(
@@ -143,7 +142,7 @@ public function test_limit() : void
143142

144143
public function test_signal_stop() : void
145144
{
146-
$extractor = new JsonExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.json'));
145+
$extractor = from_json(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.json'));
147146

148147
$generator = $extractor->extract(flow_context(\Flow\ETL\DSL\config()));
149148

src/adapter/etl-adapter-json/tests/Flow/ETL/Adapter/JSON/Tests/Integration/JSONMachine/JsonLinesExtractorTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use function Flow\ETL\Adapter\JSON\from_json_lines;
88
use function Flow\ETL\DSL\{data_frame, flow_context};
99
use function Flow\ETL\DSL\{df, print_schema};
10-
use Flow\ETL\Adapter\JSON\JSONMachine\JsonLinesExtractor;
1110
use Flow\ETL\{Config, Row, Rows, Tests\FlowTestCase};
1211
use Flow\ETL\Extractor\Signal;
1312
use Flow\Filesystem\Path;
@@ -105,7 +104,7 @@ public function test_extracting_jsonl_from_local_file_stream_with_schema() : voi
105104

106105
public function test_extracting_jsonl_from_local_file_string_uri() : void
107106
{
108-
$extractor = (new JsonLinesExtractor(Path::realpath(__DIR__ . '/../../Fixtures/timezones.jsonl')));
107+
$extractor = (from_json_lines(Path::realpath(__DIR__ . '/../../Fixtures/timezones.jsonl')));
109108

110109
$total = 0;
111110

@@ -132,7 +131,7 @@ public function test_extracting_jsonl_from_local_file_string_uri() : void
132131

133132
public function test_limit() : void
134133
{
135-
$extractor = (new JsonLinesExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.jsonl')));
134+
$extractor = (from_json_lines(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.jsonl')));
136135
$extractor->changeLimit(2);
137136

138137
self::assertCount(
@@ -143,7 +142,7 @@ public function test_limit() : void
143142

144143
public function test_signal_stop() : void
145144
{
146-
$extractor = (new JsonLinesExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.jsonl')));
145+
$extractor = (from_json_lines(\Flow\Filesystem\DSL\path(__DIR__ . '/../../Fixtures/timezones.jsonl')));
147146

148147
$generator = $extractor->extract(flow_context(\Flow\ETL\DSL\config()));
149148

src/adapter/etl-adapter-parquet/tests/Flow/ETL/Adapter/Parquet/Tests/Integration/PaginationTest.php

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

55
namespace Flow\ETL\Adapter\Parquet\Tests\Integration;
66

7+
use function Flow\ETL\Adapter\Parquet\from_parquet;
78
use function Flow\ETL\DSL\{config, flow_context};
8-
use Flow\ETL\Adapter\Parquet\ParquetExtractor;
99
use Flow\ETL\Tests\FlowTestCase;
1010
use Flow\Filesystem\Path;
1111
use Flow\Parquet\Reader;
@@ -14,9 +14,7 @@ final class PaginationTest extends FlowTestCase
1414
{
1515
public function test_multifile_pagination_from_beginning() : void
1616
{
17-
$extractor = (new ParquetExtractor(
18-
Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet'),
19-
))->withOffset(0);
17+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet')))->withOffset(0);
2018

2119
$extractedRows = 0;
2220

@@ -32,9 +30,7 @@ public function test_multifile_pagination_from_beginning() : void
3230

3331
public function test_multifile_pagination_from_middle() : void
3432
{
35-
$extractor = (new ParquetExtractor(
36-
Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet'),
37-
))->withOffset(2500);
33+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet')))->withOffset(2500);
3834

3935
$extractedRows = 0;
4036

@@ -50,9 +46,7 @@ public function test_multifile_pagination_from_middle() : void
5046

5147
public function test_multifile_pagination_from_middle_partitioned() : void
5248
{
53-
$extractor = (new ParquetExtractor(
54-
Path::realpath(__DIR__ . '/Fixtures/Pagination/partitioned/date=*/*.parquet'),
55-
))->withOffset(2500);
49+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/Pagination/partitioned/date=*/*.parquet')))->withOffset(2500);
5650

5751
$extractedRows = 0;
5852

@@ -68,9 +62,7 @@ public function test_multifile_pagination_from_middle_partitioned() : void
6862

6963
public function test_multifile_pagination_from_offset_bigger_than_total_rows() : void
7064
{
71-
$extractor = (new ParquetExtractor(
72-
Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet'),
73-
))->withOffset(10_000);
65+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/Pagination/*.parquet')))->withOffset(10_000);
7466

7567
$extractedRows = 0;
7668

@@ -88,9 +80,7 @@ public function test_reading_file_from_given_offset() : void
8880
{
8981
$totalRows = (new Reader())->read(__DIR__ . '/Fixtures/orders_1k.parquet')->metadata()->rowsNumber();
9082

91-
$extractor = (new ParquetExtractor(
92-
Path::realpath(__DIR__ . '/Fixtures/orders_1k.parquet'),
93-
))->withOffset($totalRows - 100);
83+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/orders_1k.parquet')))->withOffset($totalRows - 100);
9484

9585
self::assertCount(
9686
100,

src/adapter/etl-adapter-parquet/tests/Flow/ETL/Adapter/Parquet/Tests/Integration/ParquetExtractorTest.php

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

55
namespace Flow\ETL\Adapter\Parquet\Tests\Integration;
66

7+
use function Flow\ETL\Adapter\Parquet\from_parquet;
78
use function Flow\ETL\DSL\{config, flow_context};
8-
use Flow\ETL\Adapter\Parquet\ParquetExtractor;
99
use Flow\ETL\Extractor\Signal;
1010
use Flow\ETL\Tests\FlowTestCase;
1111
use Flow\Filesystem\Path;
@@ -15,7 +15,7 @@ final class ParquetExtractorTest extends FlowTestCase
1515
{
1616
public function test_limit() : void
1717
{
18-
$extractor = new ParquetExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/Fixtures/orders_1k.parquet'));
18+
$extractor = from_parquet(\Flow\Filesystem\DSL\path(__DIR__ . '/Fixtures/orders_1k.parquet'));
1919
$extractor->changeLimit(2);
2020

2121
self::assertCount(
@@ -28,9 +28,7 @@ public function test_reading_file_from_given_offset() : void
2828
{
2929
$totalRows = (new Reader())->read(__DIR__ . '/Fixtures/orders_1k.parquet')->metadata()->rowsNumber();
3030

31-
$extractor = (new ParquetExtractor(
32-
Path::realpath(__DIR__ . '/Fixtures/orders_1k.parquet'),
33-
))->withOffset($totalRows - 100);
31+
$extractor = (from_parquet(Path::realpath(__DIR__ . '/Fixtures/orders_1k.parquet')))->withOffset($totalRows - 100);
3432

3533
self::assertCount(
3634
100,
@@ -40,7 +38,7 @@ public function test_reading_file_from_given_offset() : void
4038

4139
public function test_signal_stop() : void
4240
{
43-
$extractor = new ParquetExtractor(\Flow\Filesystem\DSL\path(__DIR__ . '/Fixtures/orders_1k.parquet'));
41+
$extractor = from_parquet(\Flow\Filesystem\DSL\path(__DIR__ . '/Fixtures/orders_1k.parquet'));
4442

4543
$generator = $extractor->extract(flow_context(config()));
4644

0 commit comments

Comments
 (0)