BinaryOp.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Expr;
  3. use PhpParser\Node\Expr;
  4. abstract class BinaryOp extends Expr {
  5. /** @var Expr The left hand side expression */
  6. public Expr $left;
  7. /** @var Expr The right hand side expression */
  8. public Expr $right;
  9. /**
  10. * Constructs a binary operator node.
  11. *
  12. * @param Expr $left The left hand side expression
  13. * @param Expr $right The right hand side expression
  14. * @param array<string, mixed> $attributes Additional attributes
  15. */
  16. public function __construct(Expr $left, Expr $right, array $attributes = []) {
  17. $this->attributes = $attributes;
  18. $this->left = $left;
  19. $this->right = $right;
  20. }
  21. public function getSubNodeNames(): array {
  22. return ['left', 'right'];
  23. }
  24. /**
  25. * Get the operator sigil for this binary operation.
  26. *
  27. * In the case there are multiple possible sigils for an operator, this method does not
  28. * necessarily return the one used in the parsed code.
  29. */
  30. abstract public function getOperatorSigil(): string;
  31. }