Skip to content

Commit 3c487a0

Browse files
committed
move propertyPathBuilder to satellite-toolbox package, add a class alias for compatibility
1 parent 3e5476c commit 3c487a0

File tree

3 files changed

+23
-64
lines changed

3 files changed

+23
-64
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php-etl/metadata": "*",
2626
"php-etl/mapping-contracts": "0.4.*",
2727
"php-etl/metadata-contracts": "0.2.*",
28-
"php-etl/satellite-toolbox": "*"
28+
"php-etl/satellite-toolbox": "dev-feature/add-property-path-builder-from-fastmap"
2929
},
3030
"require-dev": {
3131
"mikey179/vfsstream": "^1.6",

composer.lock

Lines changed: 16 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Compiler/Builder/PropertyPathBuilder.php

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

55
namespace Kiboko\Component\FastMap\Compiler\Builder;
66

7-
use PhpParser\Builder;
8-
use PhpParser\Node;
9-
use Symfony\Component\PropertyAccess\PropertyPathInterface;
7+
use Kiboko\Component\SatelliteToolbox\Builder\PropertyPathBuilder;
108

11-
final readonly class PropertyPathBuilder implements Builder
12-
{
13-
public function __construct(
14-
private \IteratorAggregate&PropertyPathInterface $propertyPath,
15-
private Node\Expr $pathNode,
16-
private ?int $limit = null
17-
) {
18-
}
9+
trigger_deprecation('php-etl/fast-map', '0.5', 'The "%s" class is deprecated, use "%s" instead.', 'Kiboko\\Component\\FastMap\\Compiler\\Builder\\PropertyPathBuilder', PropertyPathBuilder::class);
1910

20-
public function getNode(): Node\Expr
21-
{
22-
$pathNode = $this->pathNode;
23-
24-
$iterator = $this->propertyPath->getIterator();
25-
if ($this->limit < 0) {
26-
$iterator = new \LimitIterator($iterator, 0, iterator_count($iterator) + $this->limit);
27-
} elseif (null !== $this->limit) {
28-
$iterator = new \LimitIterator($iterator, 0, $this->limit);
29-
}
30-
31-
try {
32-
foreach ($iterator as $index => $child) {
33-
if ($this->propertyPath->isIndex($index)) {
34-
if (\is_int($child)) {
35-
$pathNode = new Node\Expr\ArrayDimFetch(
36-
$pathNode,
37-
new Node\Scalar\LNumber($child)
38-
);
39-
} else {
40-
$pathNode = new Node\Expr\ArrayDimFetch(
41-
$pathNode,
42-
new Node\Scalar\String_($child)
43-
);
44-
}
45-
} elseif ($this->propertyPath->isProperty($index)) {
46-
$pathNode = new Node\Expr\PropertyFetch(
47-
$pathNode,
48-
new Node\Name($child)
49-
);
50-
}
51-
}
52-
} catch (\OutOfBoundsException) {
53-
// Case when the iterator is empty
54-
}
55-
56-
return $pathNode;
57-
}
58-
}
11+
/*
12+
* @deprecated since Satellite 0.7, use Kiboko\Component\SatelliteToolbox\Builder\PropertyPathBuilder instead.
13+
*/
14+
class_alias(PropertyPathBuilder::class, 'Kiboko\\Component\\FastMap\\Compiler\\Builder\\PropertyPathBuilder');

0 commit comments

Comments
 (0)