Removed modules/contrib/media module to allow update to the core media module
[yaffs-website] / vendor / nikic / php-parser / lib / PhpParser / Internal / PrintableNewAnonClassNode.php
1 <?php declare(strict_types=1);
2
3 namespace PhpParser\Internal;
4
5 use PhpParser\Node;
6 use PhpParser\Node\Expr;
7
8 /**
9  * This node is used internally by the format-preserving pretty printer to print anonymous classes.
10  *
11  * The normal anonymous class structure violates assumptions about the order of token offsets.
12  * Namely, the constructor arguments are part of the Expr\New_ node and follow the class node, even
13  * though they are actually interleaved with them. This special node type is used temporarily to
14  * restore a sane token offset order.
15  *
16  * @internal
17  */
18 class PrintableNewAnonClassNode extends Expr
19 {
20     /** @var Node\Arg[] Arguments */
21     public $args;
22     /** @var null|Node\Name Name of extended class */
23     public $extends;
24     /** @var Node\Name[] Names of implemented interfaces */
25     public $implements;
26     /** @var Node\Stmt[] Statements */
27     public $stmts;
28
29     public function __construct(
30         array $args, Node\Name $extends = null, array $implements, array $stmts, array $attributes
31     ) {
32         parent::__construct($attributes);
33         $this->args = $args;
34         $this->extends = $extends;
35         $this->implements = $implements;
36         $this->stmts = $stmts;
37     }
38
39     public static function fromNewNode(Expr\New_ $newNode) {
40         $class = $newNode->class;
41         assert($class instanceof Node\Stmt\Class_);
42         assert($class->name === null);
43         return new self(
44             $newNode->args, $class->extends, $class->implements,
45             $class->stmts, $newNode->getAttributes()
46         );
47     }
48
49     public function getType() : string {
50         return 'Expr_PrintableNewAnonClass';
51     }
52
53     public function getSubNodeNames() : array {
54         return ['args', 'extends', 'implements', 'stmts'];
55     }
56 }