xref: /PHP-Parser/lib/PhpParser/Node/Stmt/Enum_.php (revision ea778075)
1<?php declare(strict_types=1);
2
3namespace PhpParser\Node\Stmt;
4
5use PhpParser\Node;
6
7class Enum_ extends ClassLike {
8    /** @var null|Node\Identifier Scalar Type */
9    public ?Node $scalarType;
10    /** @var Node\Name[] Names of implemented interfaces */
11    public array $implements;
12
13    /**
14     * @param string|Node\Identifier|null $name Name
15     * @param array{
16     *     scalarType?: Node\Identifier|null,
17     *     implements?: Node\Name[],
18     *     stmts?: Node\Stmt[],
19     *     attrGroups?: Node\AttributeGroup[],
20     * } $subNodes Array of the following optional subnodes:
21     *             'scalarType'  => null    : Scalar type
22     *             'implements'  => array() : Names of implemented interfaces
23     *             'stmts'       => array() : Statements
24     *             'attrGroups'  => array() : PHP attribute groups
25     * @param array<string, mixed> $attributes Additional attributes
26     */
27    public function __construct($name, array $subNodes = [], array $attributes = []) {
28        $this->name = \is_string($name) ? new Node\Identifier($name) : $name;
29        $this->scalarType = $subNodes['scalarType'] ?? null;
30        $this->implements = $subNodes['implements'] ?? [];
31        $this->stmts = $subNodes['stmts'] ?? [];
32        $this->attrGroups = $subNodes['attrGroups'] ?? [];
33
34        parent::__construct($attributes);
35    }
36
37    public function getSubNodeNames(): array {
38        return ['attrGroups', 'name', 'scalarType', 'implements', 'stmts'];
39    }
40
41    public function getType(): string {
42        return 'Stmt_Enum';
43    }
44}
45