Skip to content

Commit d543d9f

Browse files
committed
avoid case where we build "is_null(null)"
1 parent 78d8dff commit d543d9f

File tree

3 files changed

+19
-23
lines changed

3 files changed

+19
-23
lines changed

src/Builder/Capacity/Lookup/All.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ public function getNode(): Node
5757
return (new IsolatedValueAppendingBuilder(
5858
new Node\Expr\Variable('input'),
5959
new Node\Expr\Variable('lookup'),
60-
[
61-
new Node\Stmt\If_(
60+
array_filter([
61+
$this->code ? new Node\Stmt\If_(
6262
cond: new Node\Expr\FuncCall(
6363
name: new Node\Name('is_null'),
64-
args: array_filter(
65-
[
66-
null !== $this->code ? new Node\Arg(
67-
value: $this->code,
68-
) : null,
69-
],
70-
),
64+
args: [
65+
new Node\Arg(
66+
value: $this->code,
67+
)
68+
],
7169
),
7270
subNodes: [
7371
'stmts' => [
@@ -78,7 +76,7 @@ public function getNode(): Node
7876
),
7977
],
8078
],
81-
),
79+
) : null,
8280
new Node\Stmt\TryCatch(
8381
stmts: [
8482
new Node\Stmt\Expression(
@@ -169,7 +167,7 @@ public function getNode(): Node
169167
new Node\Stmt\Return_(
170168
expr: new Node\Expr\Variable('items'),
171169
),
172-
],
170+
]),
173171
new Node\Expr\Variable('bucket')
174172
))->getNode();
175173
}

src/Builder/Capacity/Lookup/ListPerPage.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ public function getNode(): Node
5757
return (new IsolatedValueAppendingBuilder(
5858
new Node\Expr\Variable('input'),
5959
new Node\Expr\Variable('lookup'),
60-
[
61-
new Node\Stmt\If_(
60+
array_filter([
61+
$this->code ? new Node\Stmt\If_(
6262
cond: new Node\Expr\FuncCall(
6363
name: new Node\Name('is_null'),
64-
args: array_filter(
65-
[
66-
null !== $this->code ? new Node\Arg(
67-
value: $this->code,
68-
) : null,
69-
],
70-
),
64+
args: [
65+
new Node\Arg(
66+
value: $this->code,
67+
),
68+
],
7169
),
7270
subNodes: [
7371
'stmts' => [
@@ -78,7 +76,7 @@ public function getNode(): Node
7876
),
7977
],
8078
],
81-
),
79+
) : null,
8280
new Node\Stmt\TryCatch(
8381
stmts: [
8482
new Node\Stmt\Expression(
@@ -169,7 +167,7 @@ public function getNode(): Node
169167
new Node\Stmt\Return_(
170168
expr: new Node\Expr\Variable('items'),
171169
),
172-
],
170+
]),
173171
new Node\Expr\Variable('bucket')
174172
))->getNode();
175173
}

src/Capacity/Lookup/All.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ private function compileFilters(array ...$filters): Node\Expr
9393
public function getBuilder(array $config): Builder
9494
{
9595
$builder = (new Akeneo\Builder\Capacity\Lookup\All())
96-
->withType((string) $config['type'])
9796
->withEndpoint(new Node\Identifier(sprintf('get%sApi', ucfirst((string) $config['type']))))
97+
->withType($config['type'])
9898
;
9999

100100
if (isset($config['search']) && \is_array($config['search'])) {

0 commit comments

Comments
 (0)