Files
apimacro/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/ClassConst.php

78 lines
2.1 KiB
PHP
Raw Normal View History

2024-05-07 12:17:25 +02:00
<?php declare(strict_types=1);
namespace PhpParser\Node\Stmt;
2024-05-17 12:24:19 +00:00
use PhpParser\Modifiers;
2024-05-07 12:17:25 +02:00
use PhpParser\Node;
2024-05-17 12:24:19 +00:00
class ClassConst extends Node\Stmt {
2024-05-07 12:17:25 +02:00
/** @var int Modifiers */
2024-05-17 12:24:19 +00:00
public int $flags;
2024-05-07 12:17:25 +02:00
/** @var Node\Const_[] Constant declarations */
2024-05-17 12:24:19 +00:00
public array $consts;
/** @var Node\AttributeGroup[] PHP attribute groups */
public array $attrGroups;
/** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */
public ?Node $type;
2024-05-07 12:17:25 +02:00
/**
* Constructs a class const list node.
*
2024-05-17 12:24:19 +00:00
* @param Node\Const_[] $consts Constant declarations
* @param int $flags Modifiers
* @param array<string, mixed> $attributes Additional attributes
* @param list<Node\AttributeGroup> $attrGroups PHP attribute groups
* @param null|Node\Identifier|Node\Name|Node\ComplexType $type Type declaration
2024-05-07 12:17:25 +02:00
*/
public function __construct(
array $consts,
int $flags = 0,
array $attributes = [],
2024-05-17 12:24:19 +00:00
array $attrGroups = [],
?Node $type = null
2024-05-07 12:17:25 +02:00
) {
$this->attributes = $attributes;
$this->flags = $flags;
$this->consts = $consts;
$this->attrGroups = $attrGroups;
2024-05-17 12:24:19 +00:00
$this->type = $type;
2024-05-07 12:17:25 +02:00
}
2024-05-17 12:24:19 +00:00
public function getSubNodeNames(): array {
return ['attrGroups', 'flags', 'type', 'consts'];
2024-05-07 12:17:25 +02:00
}
/**
* Whether constant is explicitly or implicitly public.
*/
2024-05-17 12:24:19 +00:00
public function isPublic(): bool {
return ($this->flags & Modifiers::PUBLIC) !== 0
|| ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
2024-05-07 12:17:25 +02:00
}
/**
* Whether constant is protected.
*/
2024-05-17 12:24:19 +00:00
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
2024-05-07 12:17:25 +02:00
}
/**
* Whether constant is private.
*/
2024-05-17 12:24:19 +00:00
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
2024-05-07 12:17:25 +02:00
}
/**
* Whether constant is final.
*/
2024-05-17 12:24:19 +00:00
public function isFinal(): bool {
return (bool) ($this->flags & Modifiers::FINAL);
2024-05-07 12:17:25 +02:00
}
2024-05-17 12:24:19 +00:00
public function getType(): string {
2024-05-07 12:17:25 +02:00
return 'Stmt_ClassConst';
}
}