Skip to content

Commit cf979e0

Browse files
committed
add "append" setting, to merge the output of the mapper into the previous step's output,
update phpstan
1 parent 6f7d5af commit cf979e0

File tree

7 files changed

+19
-9
lines changed

7 files changed

+19
-9
lines changed

.github/workflows/phpstan-5.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 5
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan5:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/phpstan-6.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 6
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan6:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/phpstan-7.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 7
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan7:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/phpstan-8.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 8
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan8:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

src/Builder/Transformer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ class: new Node\Name\FullyQualified(
9797
new Node\Arg(
9898
value: new Node\Expr\Variable('line')
9999
),
100+
new Node\Arg(
101+
value: new Node\Expr\Variable('line')
102+
),
100103
]
101104
),
102105
),

src/Factory/ArrayMapper.php

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

55
namespace Kiboko\Plugin\FastMap\Factory;
66

7+
use Kiboko\Component\FastMapConfig\ArrayAppendBuilder;
78
use Kiboko\Component\FastMapConfig\ArrayBuilder;
89
use Kiboko\Contract\Configurator;
910
use Kiboko\Plugin\FastMap;
@@ -17,7 +18,7 @@
1718
private Processor $processor;
1819
private ConfigurationInterface $configuration;
1920

20-
public function __construct(private ?ExpressionLanguage $interpreter, private array $additionalExpressionVariables = [])
21+
public function __construct(private ?ExpressionLanguage $interpreter, private array $additionalExpressionVariables = [], private bool $append = false)
2122
{
2223
$this->processor = new Processor();
2324
$this->configuration = new FastMap\Configuration\MapMapper();
@@ -54,9 +55,15 @@ public function validate(array $config): bool
5455

5556
public function compile(array $config): Repository\TransformerMapper
5657
{
57-
$mapper = new ArrayBuilder(
58-
interpreter: $this->interpreter,
59-
);
58+
if ($this->append) {
59+
$mapper = new ArrayAppendBuilder(
60+
interpreter: $this->interpreter,
61+
);
62+
} else {
63+
$mapper = new ArrayBuilder(
64+
interpreter: $this->interpreter,
65+
);
66+
}
6067

6168
$builder = new FastMap\Builder\Transformer(
6269
new FastMap\Builder\ArrayMapper($mapper)

src/Service.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function compile(array $config): Factory\Repository\TransformerMapper
9191
return $conditionalFactory->compile($config['conditional']);
9292
}
9393
if (\array_key_exists('map', $config)) {
94-
$arrayFactory = new Factory\ArrayMapper($interpreter, $this->additionalExpressionVariables);
94+
$arrayFactory = new Factory\ArrayMapper($interpreter, $this->additionalExpressionVariables, isset($config['append']) && $config['append']);
9595

9696
return $arrayFactory->compile($config['map']);
9797
}

0 commit comments

Comments
 (0)