2020-12-24 00:44:16 +01:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2020-12-24 00:44:16 +01:00
|
|
|
namespace Rector\Php80\ValueObject;
|
|
|
|
|
|
|
|
use PhpParser\Node\Expr;
|
2021-06-28 21:18:55 +00:00
|
|
|
use Rector\Php80\Enum\MatchKind;
|
2020-12-24 00:44:16 +01:00
|
|
|
final class CondAndExpr
|
|
|
|
{
|
|
|
|
/**
|
2021-12-30 16:07:15 +00:00
|
|
|
* @var Expr[]|null
|
2021-12-04 12:47:17 +00:00
|
|
|
* @readonly
|
2020-12-24 00:44:16 +01:00
|
|
|
*/
|
2021-06-08 11:02:16 +00:00
|
|
|
private $condExprs;
|
2020-12-24 00:44:16 +01:00
|
|
|
/**
|
2021-12-04 12:47:17 +00:00
|
|
|
* @readonly
|
2021-08-23 00:20:32 +00:00
|
|
|
* @var \PhpParser\Node\Expr
|
2020-12-24 00:44:16 +01:00
|
|
|
*/
|
|
|
|
private $expr;
|
|
|
|
/**
|
2021-12-04 12:47:17 +00:00
|
|
|
* @readonly
|
2021-06-28 21:18:55 +00:00
|
|
|
* @var \Rector\Php80\Enum\MatchKind
|
2020-12-24 00:44:16 +01:00
|
|
|
*/
|
2021-06-28 21:18:55 +00:00
|
|
|
private $matchKind;
|
2021-06-08 11:02:16 +00:00
|
|
|
/**
|
2021-11-25 19:08:52 +00:00
|
|
|
* @param Expr[]|null $condExprs
|
2021-06-08 11:02:16 +00:00
|
|
|
*/
|
2021-11-25 19:08:52 +00:00
|
|
|
public function __construct($condExprs, \PhpParser\Node\Expr $expr, \Rector\Php80\Enum\MatchKind $matchKind)
|
2020-12-24 00:44:16 +01:00
|
|
|
{
|
2021-06-08 11:02:16 +00:00
|
|
|
$this->condExprs = $condExprs;
|
2020-12-24 00:44:16 +01:00
|
|
|
$this->expr = $expr;
|
2021-06-28 21:18:55 +00:00
|
|
|
$this->matchKind = $matchKind;
|
2020-12-24 00:44:16 +01:00
|
|
|
}
|
2021-05-10 22:23:08 +00:00
|
|
|
public function getExpr() : \PhpParser\Node\Expr
|
2020-12-24 00:44:16 +01:00
|
|
|
{
|
|
|
|
return $this->expr;
|
|
|
|
}
|
2021-06-08 11:02:16 +00:00
|
|
|
/**
|
2021-11-25 13:01:10 +00:00
|
|
|
* @return mixed[]|null
|
2021-06-08 11:02:16 +00:00
|
|
|
*/
|
2021-11-25 13:01:10 +00:00
|
|
|
public function getCondExprs()
|
2020-12-24 00:44:16 +01:00
|
|
|
{
|
2021-11-25 13:01:10 +00:00
|
|
|
// internally checked by PHPStan, cannot be empty array
|
|
|
|
if ($this->condExprs === []) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-06-08 11:02:16 +00:00
|
|
|
return $this->condExprs;
|
2020-12-24 00:44:16 +01:00
|
|
|
}
|
2021-06-28 21:18:55 +00:00
|
|
|
public function getMatchKind() : \Rector\Php80\Enum\MatchKind
|
2020-12-24 00:44:16 +01:00
|
|
|
{
|
2021-06-28 21:18:55 +00:00
|
|
|
return $this->matchKind;
|
|
|
|
}
|
|
|
|
public function equalsMatchKind(\Rector\Php80\Enum\MatchKind $matchKind) : bool
|
|
|
|
{
|
|
|
|
return $this->matchKind->equals($matchKind);
|
2020-12-24 00:44:16 +01:00
|
|
|
}
|
|
|
|
}
|