|
4 | 4 |
|
5 | 5 | namespace Kiboko\Component\FastMap\Compiler\Builder; |
6 | 6 |
|
7 | | -use PhpParser\Builder; |
8 | | -use PhpParser\Node; |
9 | | -use Symfony\Component\PropertyAccess\PropertyPathInterface; |
| 7 | +use Kiboko\Component\SatelliteToolbox\Builder\PropertyPathBuilder; |
10 | 8 |
|
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/satellite', '0.7', 'The "%s" class is deprecated, use "%s" instead.', 'Kiboko\\Component\\FastMap\\Compiler\\Builder\\PropertyPathBuilder', PropertyPathBuilder::class); |
19 | 10 |
|
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