MethodCall.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php declare(strict_types=1);
  2. namespace PhpParser\Node\Expr;
  3. use PhpParser\Node\Arg;
  4. use PhpParser\Node\Expr;
  5. use PhpParser\Node\Identifier;
  6. class MethodCall extends Expr
  7. {
  8. /** @var Expr Variable holding object */
  9. public $var;
  10. /** @var Identifier|Expr Method name */
  11. public $name;
  12. /** @var Arg[] Arguments */
  13. public $args;
  14. /**
  15. * Constructs a function call node.
  16. *
  17. * @param Expr $var Variable holding object
  18. * @param string|Identifier|Expr $name Method name
  19. * @param Arg[] $args Arguments
  20. * @param array $attributes Additional attributes
  21. */
  22. public function __construct(Expr $var, $name, array $args = [], array $attributes = []) {
  23. $this->attributes = $attributes;
  24. $this->var = $var;
  25. $this->name = \is_string($name) ? new Identifier($name) : $name;
  26. $this->args = $args;
  27. }
  28. public function getSubNodeNames() : array {
  29. return ['var', 'name', 'args'];
  30. }
  31. public function getType() : string {
  32. return 'Expr_MethodCall';
  33. }
  34. }