Skip to content

Commit dafb6c2

Browse files
committed
Fixed rector paths & replaced Path usages with DSL
1 parent e7231b1 commit dafb6c2

64 files changed

Lines changed: 444 additions & 423 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.

rector.src.php

Lines changed: 3 additions & 3 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,

rector.tests.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,16 @@
7676
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
7777
use Rector\CodingStyle\Rector\FuncCall\FunctionFirstClassCallableRector;
7878
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
79+
use Flow\Filesystem\Path;
7980

8081
return RectorConfig::configure()
8182
->withPaths([
8283
__DIR__ . '/src/core/etl/tests',
8384
__DIR__ . '/src/cli/tests',
84-
__DIR__ . '/src/lib/*/tests',
85-
__DIR__ . '/src/adapter/**/tests',
86-
__DIR__ . '/src/bridge/**/tests',
87-
__DIR__ . '/src/tools/**/tests',
85+
__DIR__ . '/src/lib/*/*/tests',
86+
__DIR__ . '/src/adapter/*/*/tests',
87+
__DIR__ . '/src/bridge/*/*/tests',
88+
__DIR__ . '/src/tools/*/*/tests',
8889
])
8990
->withSets([
9091
LevelSetList::UP_TO_PHP_82,
@@ -97,6 +98,8 @@
9798
[
9899
// Building Blocks
99100
new StaticCallToFuncCall(Row::class, 'create', 'Flow\ETL\DSL\row'),
101+
new StaticCallToFuncCall(Path::class, 'from', 'Flow\Filesystem\DSL\path'),
102+
new StaticCallToFuncCall(Path::class, 'realpath', 'Flow\Filesystem\DSL\path_real'),
100103
new StaticCallToFuncCall(Config::class, 'default', 'Flow\ETL\DSL\config'),
101104
// Schema
102105
new StaticCallToFuncCall(Definition::class, 'boolean', 'Flow\ETL\DSL\bool_schema'),

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

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

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

7+
use function Flow\Filesystem\DSL\path_real;
78
use Flow\ETL\Adapter\Avro\FlixTech\{AvroExtractor, AvroLoader};
89
use Flow\ETL\{Attribute\DocumentationDSL, Attribute\Module, Attribute\Type, Schema};
910
use Flow\Filesystem\Path;
@@ -12,15 +13,15 @@
1213
function from_avro(Path|string $path) : AvroExtractor
1314
{
1415
return new AvroExtractor(
15-
\is_string($path) ? Path::realpath($path) : $path
16+
\is_string($path) ? path_real($path) : $path
1617
);
1718
}
1819

1920
#[DocumentationDSL(module: Module::AVRO, type: Type::LOADER)]
2021
function to_avro(Path|string $path, ?Schema $schema = null) : AvroLoader
2122
{
2223
return new AvroLoader(
23-
\is_string($path) ? Path::realpath($path) : $path,
24+
\is_string($path) ? path_real($path) : $path,
2425
$schema
2526
);
2627
}

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

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

77
use function Flow\ETL\DSL\Adapter\Avro\{from_avro, to_avro};
88
use function Flow\ETL\DSL\{config, flow_context};
9+
use function Flow\Filesystem\DSL\{path, path_real};
910
use Flow\ETL\Extractor\Signal;
1011
use Flow\ETL\Tests\FlowTestCase;
11-
use Flow\Filesystem\Path;
1212

1313
final class AvroTest extends FlowTestCase
1414
{
@@ -19,7 +19,7 @@ protected function setUp() : void
1919

2020
public function test_limit() : void
2121
{
22-
$extractor = from_avro(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
22+
$extractor = from_avro(path_real(__DIR__ . '/../Fixtures/orders_flow.avro'));
2323
$extractor->changeLimit(2);
2424

2525
self::assertCount(
@@ -30,7 +30,7 @@ public function test_limit() : void
3030

3131
public function test_signal_stop() : void
3232
{
33-
$extractor = from_avro(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.avro'));
33+
$extractor = from_avro(path_real(__DIR__ . '/../Fixtures/orders_flow.avro'));
3434

3535
$generator = $extractor->extract(flow_context(config()));
3636

@@ -47,6 +47,6 @@ public function test_using_pattern_path() : void
4747
{
4848
$this->expectExceptionMessage("AvroLoader path can't be pattern, given: /path/*/pattern.avro");
4949

50-
to_avro(Path::from('/path/*/pattern.avro'));
50+
to_avro(path('/path/*/pattern.avro'));
5151
}
5252
}

src/adapter/etl-adapter-chartjs/src/Flow/ETL/Adapter/ChartJS/ChartJSLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ChartJSLoader implements Closure, Loader
2121

2222
public function __construct(private readonly Chart $type)
2323
{
24-
$this->template = Path::from(__DIR__ . '/Resources/template/full_page.html');
24+
$this->template = \Flow\Filesystem\DSL\path(__DIR__ . '/Resources/template/full_page.html');
2525
}
2626

2727
public function closure(FlowContext $context) : void

src/adapter/etl-adapter-chartjs/src/Flow/ETL/Adapter/ChartJS/functions.php

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

55
namespace Flow\ETL\Adapter\ChartJS;
66

7+
use function Flow\Filesystem\DSL\path_real;
78
use Flow\ETL\Adapter\ChartJS\Chart\{BarChart, LineChart, PieChart};
89
use Flow\ETL\Attribute\{DocumentationDSL, Module, Type};
910
use Flow\ETL\Row\{EntryReference, References};
@@ -42,11 +43,11 @@ function to_chartjs(Chart $type) : ChartJSLoader
4243
function to_chartjs_file(Chart $type, Path|string|null $output = null, Path|string|null $template = null) : ChartJSLoader
4344
{
4445
if (\is_string($output)) {
45-
$output = Path::realpath($output);
46+
$output = path_real($output);
4647
}
4748

4849
if (\is_string($template)) {
49-
$template = Path::realpath($template);
50+
$template = path_real($template);
5051
}
5152

5253
$loader = new ChartJSLoader($type);

src/adapter/etl-adapter-csv/src/Flow/ETL/Adapter/CSV/functions.php

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

55
namespace Flow\ETL\Adapter\CSV;
66

7+
use function Flow\Filesystem\DSL\path_real;
78
use Flow\ETL\Adapter\CSV\Detector\{Option, Options};
89
use Flow\ETL\{Attribute\DocumentationDSL, Attribute\DocumentationExample, Attribute\Module, Attribute\Type as DSLType};
910
use Flow\ETL\Schema;
@@ -32,7 +33,7 @@ function from_csv(
3233
?Schema $schema = null,
3334
) : CSVExtractor {
3435

35-
$loader = (new CSVExtractor(\is_string($path) ? Path::realpath($path) : $path))
36+
$loader = (new CSVExtractor(\is_string($path) ? path_real($path) : $path))
3637
->withHeader($with_header)
3738
->withEmptyToNull($empty_to_null)
3839
->withCharactersReadInLine($characters_read_in_line);
@@ -75,7 +76,7 @@ function to_csv(
7576
string $new_line_separator = PHP_EOL,
7677
string $datetime_format = \DateTimeInterface::ATOM,
7778
) : CSVLoader {
78-
return (new CSVLoader(\is_string($uri) ? Path::realpath($uri) : $uri))
79+
return (new CSVLoader(\is_string($uri) ? path_real($uri) : $uri))
7980
->withHeader($with_header)
8081
->withSeparator($separator)
8182
->withEnclosure($enclosure)

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
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 function Flow\Filesystem\DSL\path_real;
1011
use Flow\ETL\{Config, Row, Rows, Tests\FlowTestCase};
1112
use Flow\ETL\Extractor\Signal;
12-
use Flow\Filesystem\Path;
1313
use Flow\Filesystem\Tests\OperatingSystem;
1414

1515
final class CSVExtractorTest extends FlowTestCase
@@ -19,7 +19,7 @@ final class CSVExtractorTest extends FlowTestCase
1919
public function test_bom_removal_utf16_be() : void
2020
{
2121
$extractor = from_csv(
22-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf16be_bom.csv'),
22+
$path = path_real(__DIR__ . '/../Fixtures/with_utf16be_bom.csv'),
2323
);
2424
self::assertTrue($this->ensureBOMExists(__DIR__ . '/../Fixtures/with_utf16be_bom.csv', "\xFE\xFF"));
2525

@@ -44,7 +44,7 @@ public function test_bom_removal_utf16_be() : void
4444
public function test_bom_removal_utf16_le() : void
4545
{
4646
$extractor = from_csv(
47-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf16le_bom.csv'),
47+
$path = path_real(__DIR__ . '/../Fixtures/with_utf16le_bom.csv'),
4848
);
4949
self::assertTrue($this->ensureBOMExists(__DIR__ . '/../Fixtures/with_utf16le_bom.csv', "\xFF\xFE"));
5050

@@ -69,7 +69,7 @@ public function test_bom_removal_utf16_le() : void
6969
public function test_bom_removal_utf32_be() : void
7070
{
7171
$extractor = from_csv(
72-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf32be_bom.csv'),
72+
$path = path_real(__DIR__ . '/../Fixtures/with_utf32be_bom.csv'),
7373
);
7474

7575
self::assertTrue($this->ensureBOMExists(__DIR__ . '/../Fixtures/with_utf32be_bom.csv', "\x00\x00\xFE\xFF"));
@@ -95,7 +95,7 @@ public function test_bom_removal_utf32_be() : void
9595
public function test_bom_removal_utf32_le() : void
9696
{
9797
$extractor = from_csv(
98-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf32le_bom.csv'),
98+
$path = path_real(__DIR__ . '/../Fixtures/with_utf32le_bom.csv'),
9999
);
100100

101101
self::assertTrue($this->ensureBOMExists(__DIR__ . '/../Fixtures/with_utf32le_bom.csv', "\xFF\xFE\x00\x00"));
@@ -121,7 +121,7 @@ public function test_bom_removal_utf32_le() : void
121121
public function test_bom_removal_utf8() : void
122122
{
123123
$extractor = from_csv(
124-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf8_bom.csv'),
124+
$path = path_real(__DIR__ . '/../Fixtures/with_utf8_bom.csv'),
125125
);
126126

127127
self::assertTrue($this->ensureBOMExists(__DIR__ . '/../Fixtures/with_utf8_bom.csv', "\xEF\xBB\xBF"));
@@ -147,7 +147,7 @@ public function test_bom_removal_utf8() : void
147147
public function test_extracting_csv_empty_columns_as_empty_strings() : void
148148
{
149149
$extractor = from_csv(
150-
$path = Path::realpath(__DIR__ . '/../Fixtures/file_with_empty_columns.csv'),
150+
$path = path_real(__DIR__ . '/../Fixtures/file_with_empty_columns.csv'),
151151
empty_to_null: false,
152152
);
153153

@@ -371,7 +371,7 @@ public function test_extracting_csv_with_more_columns_than_headers() : void
371371
public function test_extracting_csv_with_more_headers_than_columns() : void
372372
{
373373
$extractor = from_csv(
374-
Path::realpath(__DIR__ . '/../Fixtures/more_headers_than_columns.csv')
374+
path_real(__DIR__ . '/../Fixtures/more_headers_than_columns.csv')
375375
);
376376

377377
$total = 0;
@@ -443,7 +443,7 @@ public function test_extracting_csv_with_multiline_strings() : void
443443
public function test_limit() : void
444444
{
445445

446-
$extractor = from_csv(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
446+
$extractor = from_csv(path_real(__DIR__ . '/../Fixtures/orders_flow.csv'));
447447
$extractor->changeLimit(2);
448448

449449
self::assertCount(
@@ -476,7 +476,7 @@ public function test_loading_data_from_all_partitions() : void
476476

477477
public function test_signal_stop() : void
478478
{
479-
$extractor = from_csv(Path::realpath(__DIR__ . '/../Fixtures/orders_flow.csv'));
479+
$extractor = from_csv(path_real(__DIR__ . '/../Fixtures/orders_flow.csv'));
480480

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

@@ -492,7 +492,7 @@ public function test_signal_stop() : void
492492
public function test_without_bom_removal_utf8() : void
493493
{
494494
$extractor = from_csv(
495-
$path = Path::realpath(__DIR__ . '/../Fixtures/with_utf8_bom.csv'),
495+
$path = path_real(__DIR__ . '/../Fixtures/with_utf8_bom.csv'),
496496
);
497497

498498
$extractor = $extractor->withBOMRemoval(false);

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

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

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

7+
use function Flow\Filesystem\DSL\path_real;
78
use Flow\ETL\Adapter\CSV\CSVLineReader;
89
use Flow\ETL\Tests\FlowTestCase;
9-
use Flow\Filesystem\Path;
1010
use Flow\Filesystem\Stream\NativeLocalSourceStream;
1111
use Flow\Filesystem\Tests\OperatingSystem;
1212

@@ -19,7 +19,7 @@ public function test_memory_usage_with_large_multiline_csv() : void
1919
$path = __DIR__ . '/../Fixtures/large_multiline_csv.csv';
2020
$memoryBefore = memory_get_usage(true);
2121

22-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
22+
$stream = NativeLocalSourceStream::open(path_real($path));
2323
$reader = new CSVLineReader('"');
2424
$lines = iterator_to_array($reader->readLines($stream));
2525

@@ -39,7 +39,7 @@ public function test_memory_usage_with_large_multiline_csv() : void
3939
public function test_reading_csv_with_custom_character_limit() : void
4040
{
4141
$path = __DIR__ . '/../Fixtures/more_than_1000_characters_per_line.csv';
42-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
42+
$stream = NativeLocalSourceStream::open(path_real($path));
4343

4444
$reader = new CSVLineReader('"', 2000);
4545
$lines = iterator_to_array($reader->readLines($stream));
@@ -57,7 +57,7 @@ public function test_reading_csv_with_different_enclosures() : void
5757
}
5858

5959
$path = __DIR__ . '/../Fixtures/single_quotes_csv.csv';
60-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
60+
$stream = NativeLocalSourceStream::open(path_real($path));
6161

6262
$reader = new CSVLineReader("'"); // Use single quote as enclosure
6363
$lines = iterator_to_array($reader->readLines($stream));
@@ -73,7 +73,7 @@ public function test_reading_csv_with_different_enclosures() : void
7373
public function test_reading_csv_with_escaped_quotes_file() : void
7474
{
7575
$path = __DIR__ . '/../Fixtures/escaped_quotes_csv.csv';
76-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
76+
$stream = NativeLocalSourceStream::open(path_real($path));
7777

7878
$reader = new CSVLineReader('"');
7979
$lines = iterator_to_array($reader->readLines($stream));
@@ -91,7 +91,7 @@ public function test_reading_large_csv_file_performance() : void
9191
$path = __DIR__ . '/../Fixtures/large_performance_csv.csv';
9292
$startTime = microtime(true);
9393

94-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
94+
$stream = NativeLocalSourceStream::open(path_real($path));
9595
$reader = new CSVLineReader('"');
9696
$lines = iterator_to_array($reader->readLines($stream));
9797

@@ -111,7 +111,7 @@ public function test_reading_large_csv_file_performance() : void
111111
public function test_reading_multiline_csv_file() : void
112112
{
113113
$path = __DIR__ . '/../Fixtures/multiline_strings.csv';
114-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
114+
$stream = NativeLocalSourceStream::open(path_real($path));
115115

116116
$reader = new CSVLineReader('"');
117117
$lines = iterator_to_array($reader->readLines($stream));
@@ -132,7 +132,7 @@ public function test_reading_multiline_csv_file() : void
132132
public function test_reading_real_csv_file_with_quotes() : void
133133
{
134134
$path = __DIR__ . '/../Fixtures/annual-enterprise-survey-2019-financial-year-provisional-csv.csv';
135-
$stream = NativeLocalSourceStream::open(Path::realpath($path));
135+
$stream = NativeLocalSourceStream::open(path_real($path));
136136

137137
$reader = new CSVLineReader('"');
138138
$lines = iterator_to_array($reader->readLines($stream));

src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/DSL/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

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

7+
use function Flow\Filesystem\DSL\path_real;
78
use Flow\ETL\{Adapter\Excel\ExcelExtractor,
89
Adapter\Excel\Function\IsValidExcelSheetName,
910
Attribute\DocumentationDSL,
@@ -18,7 +19,7 @@
1819
function from_excel(
1920
string|Path $path,
2021
) : ExcelExtractor {
21-
return new ExcelExtractor(\is_string($path) ? Path::realpath($path) : $path);
22+
return new ExcelExtractor(\is_string($path) ? path_real($path) : $path);
2223
}
2324

2425
#[DocumentationDSL(module: Module::EXCEL, type: DSLType::HELPER)]

0 commit comments

Comments
 (0)