Skip to content

Commit 07fcaee

Browse files
committed
avoid phpstan error: the type of the expression could not be determined
1 parent efec3c9 commit 07fcaee

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Builder/ConditionalMapper.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ private function compileConditions(array $alternatives): Node
3535

3636
/** @var Builder $builder */
3737
[$condition, $builder] = array_shift($alternatives);
38+
/** @var Node\Stmt\Expression $expression */
39+
$expression = $parser->parse('<?php '.$this->interpreter->compile($condition, ['input', 'output']).';')[0];
3840

3941
return new Node\Expr\New_(
4042
new Node\Stmt\Class_(
@@ -106,7 +108,7 @@ function ($alternative) {
106108
],
107109
'stmts' => [
108110
new Node\Stmt\If_(
109-
cond: $parser->parse('<?php '.$this->interpreter->compile($condition, ['input', 'output']).';')[0]->expr,
111+
cond: $expression->expr,
110112
subNodes: [
111113
'stmts' => [
112114
new Node\Stmt\Return_(
@@ -130,11 +132,11 @@ function ($alternative) {
130132
),
131133
],
132134
'elseifs' => array_map(
133-
function ($alternative, $index) use ($parser) {
135+
function ($alternative, $index) use ($expression) {
134136
[$condition, $repository] = $alternative;
135137

136138
return new Node\Stmt\ElseIf_(
137-
cond: $parser->parse('<?php '.$this->interpreter->compile($condition, ['input', 'output']).';')[0]->expr,
139+
cond: $expression->expr,
138140
stmts: [
139141
new Node\Stmt\Return_(
140142
new Node\Expr\FuncCall(

0 commit comments

Comments
 (0)