Skip to content

Commit

Permalink
MatchExpressionArmBody
Browse files Browse the repository at this point in the history
  • Loading branch information
janedbal committed Sep 14, 2022
1 parent 2c8d745 commit fb1f36f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
use PHPStan\Node\LiteralArrayItem;
use PHPStan\Node\LiteralArrayNode;
use PHPStan\Node\MatchExpressionArm;
use PHPStan\Node\MatchExpressionArmBody;
use PHPStan\Node\MatchExpressionArmCondition;
use PHPStan\Node\MatchExpressionNode;
use PHPStan\Node\MethodCallableNode;
Expand Down Expand Up @@ -2633,7 +2634,8 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
$filteringExpr = new BinaryOp\BooleanOr($filteringExpr, $armCondExpr);
}

$armNodes[] = new MatchExpressionArm($condNodes, $arm->getLine());
$matchArmBody = new MatchExpressionArmBody($armCondScope, $arm->body);
$armNodes[] = new MatchExpressionArm($matchArmBody, $condNodes, $arm->getLine());

$armResult = $this->processExprNode(
$arm->body,
Expand Down
7 changes: 6 additions & 1 deletion src/Node/MatchExpressionArm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ class MatchExpressionArm
/**
* @param MatchExpressionArmCondition[] $conditions
*/
public function __construct(private array $conditions, private int $line)
public function __construct(private MatchExpressionArmBody $body, private array $conditions, private int $line)
{
}

public function getBody(): MatchExpressionArmBody
{
return $this->body;
}

/**
* @return MatchExpressionArmCondition[]
*/
Expand Down
26 changes: 26 additions & 0 deletions src/Node/MatchExpressionArmBody.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace PHPStan\Node;

use PhpParser\Node\Expr;
use PHPStan\Analyser\Scope;

/** @api */
class MatchExpressionArmBody
{

public function __construct(private Scope $scope, private Expr $body)
{
}

public function getScope(): Scope
{
return $this->scope;
}

public function getBody(): Expr
{
return $this->body;
}

}

0 comments on commit fb1f36f

Please sign in to comment.