Skip to content

Commit aa83ce4

Browse files
committed
refactor: DataFrame Entry contract
1 parent 1efdd51 commit aa83ce4

156 files changed

Lines changed: 3531 additions & 4054 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.

src/adapter/etl-adapter-elasticsearch/src/Flow/ETL/Adapter/Elasticsearch/ElasticsearchPHP/ElasticsearchLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Flow\ETL\Row;
1616
use Flow\ETL\Row\Entry\JsonEntry;
1717
use Flow\ETL\Rows;
18+
use Flow\Types\Value\Json;
1819
use Throwable;
1920

2021
use function class_exists;
@@ -82,7 +83,7 @@ public function load(Rows $rows, FlowContext $context): void
8283
*/
8384
$dataCollection = $rows->map(static fn(Row $row): Row => Row::create(
8485
$factory->create($row),
85-
new JsonEntry('body', $row->toArray()),
86+
new JsonEntry('body', Json::fromArray($row->toArray())),
8687
))->toArray();
8788

8889
foreach ($dataCollection as $data) {

src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/RowsNormalizer/ExcelRowsNormalizer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ private function normalizeEntry(Entry $entry): bool|float|int|string|null
8888
};
8989
}
9090

91+
/**
92+
* @param EnumEntry<\UnitEnum|null> $entry
93+
*/
9194
private function normalizeEnumEntry(EnumEntry $entry): ?string
9295
{
9396
$value = $entry->value();

src/adapter/etl-adapter-http/src/Flow/ETL/Adapter/Http/RequestEntriesFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Flow\ETL\Row;
99
use Flow\ETL\Row\Entries;
1010
use Flow\ETL\Row\Entry\JsonEntry;
11+
use Flow\Types\Value\Json;
1112
use Psr\Http\Message\RequestInterface;
1213

1314
use function class_exists;
@@ -70,7 +71,7 @@ public function create(RequestInterface $request): Entries
7071
);
7172
}
7273

73-
$requestBodyEntry = new JsonEntry('request_body', $decodedJson);
74+
$requestBodyEntry = new JsonEntry('request_body', Json::fromArray($decodedJson));
7475
} else {
7576
$requestBodyEntry = string_entry('request_body', $requestBodyContent);
7677
}
@@ -88,7 +89,7 @@ public function create(RequestInterface $request): Entries
8889
return new Entries(
8990
$requestBodyEntry,
9091
string_entry('request_uri', (string) $request->getUri()),
91-
new JsonEntry('request_headers', $request->getHeaders()),
92+
new JsonEntry('request_headers', Json::fromArray($request->getHeaders())),
9293
string_entry('request_protocol_version', $request->getProtocolVersion()),
9394
string_entry('request_method', $request->getMethod()),
9495
);

src/adapter/etl-adapter-xml/src/Flow/ETL/Adapter/XML/RowsNormalizer/EntryNormalizer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function normalize(Entry $entry): XMLNode|XMLAttribute
8686
* It might be possible to use a schema here, if provided we might be able to take a metadata from entry definition and use it to define a node name.
8787
* However this might be a bit problematic in case of deeply nested lists.
8888
*
89-
* @param ListEntry<mixed> $entry
89+
* @param ListEntry<mixed, list<mixed>|null> $entry
9090
*/
9191
private function listToNode(ListEntry $entry): XMLNode
9292
{
@@ -143,7 +143,7 @@ private function listToNode(ListEntry $entry): XMLNode
143143
*
144144
* Because of that and because Map Values can be other nested structures, the only valid solution is solution from Example 1.
145145
*
146-
* @param MapEntry<array-key, mixed> $entry
146+
* @param MapEntry<array-key, mixed, array<array-key, mixed>|null> $entry
147147
*/
148148
private function mapToNode(MapEntry $entry): XMLNode
149149
{
@@ -174,7 +174,7 @@ private function mapToNode(MapEntry $entry): XMLNode
174174
}
175175

176176
/**
177-
* @param StructureEntry<array<string, mixed>> $entry
177+
* @param StructureEntry<mixed, array<string, mixed>|null> $entry
178178
*/
179179
private function structureToNode(StructureEntry $entry): XMLNode
180180
{

src/core/etl/src/Flow/ETL/Constraint/SortedByConstraint.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class SortedByConstraint implements Constraint
2323
private bool $firstRow = true;
2424

2525
/**
26-
* @var array<string, mixed>
26+
* @var array<string, null|array<array-key, mixed>|bool|float|int|object|string>
2727
*/
2828
private array $previousValues = [];
2929

@@ -46,9 +46,7 @@ public function isSatisfiedBy(Row $row): bool
4646
}
4747

4848
foreach ($this->references->all() as $reference) {
49-
// @mago-ignore analysis:mixed-assignment
5049
$currentValue = $row->valueOf($reference);
51-
// @mago-ignore analysis:mixed-assignment
5250
$previousValue = $this->previousValues[$reference->name()];
5351

5452
$direction = $reference->sort();
@@ -120,7 +118,6 @@ public function violation(Row $row): string
120118

121119
foreach ($this->references->all() as $reference) {
122120
$entry = $row->get($reference);
123-
// @mago-ignore analysis:mixed-assignment
124121
$previousValue = $this->previousValues[$reference->name()] ?? null;
125122

126123
$violations[] = sprintf(

0 commit comments

Comments
 (0)