UseUse.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * @property PHPParser_Node_Name $name Namespace/Class to alias
  4. * @property string $alias Alias
  5. */
  6. class PHPParser_Node_Stmt_UseUse extends PHPParser_Node_Stmt
  7. {
  8. /**
  9. * Constructs an alias (use) node.
  10. *
  11. * @param PHPParser_Node_Name $name Namespace/Class to alias
  12. * @param null|string $alias Alias
  13. * @param array $attributes Additional attributes
  14. */
  15. public function __construct(PHPParser_Node_Name $name, $alias = null, array $attributes = array()) {
  16. if (null === $alias) {
  17. $alias = $name->getLast();
  18. }
  19. if ('self' == $alias || 'parent' == $alias) {
  20. throw new PHPParser_Error(sprintf(
  21. 'Cannot use "%s" as "%s" because "%2$s" is a special class name',
  22. $name, $alias
  23. ));
  24. }
  25. parent::__construct(
  26. array(
  27. 'name' => $name,
  28. 'alias' => $alias,
  29. ),
  30. $attributes
  31. );
  32. }
  33. }