NullsafePropertyFetch.php 980 B

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