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

83 lines
2.3 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;
use PhpParser\Node\ComplexType;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
2024-05-17 12:24:19 +00:00
use PhpParser\Node\PropertyItem;
2024-05-07 12:17:25 +02:00
2024-05-17 12:24:19 +00:00
class Property 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;
/** @var PropertyItem[] Properties */
public array $props;
2024-05-07 12:17:25 +02:00
/** @var null|Identifier|Name|ComplexType Type declaration */
2024-05-17 12:24:19 +00:00
public ?Node $type;
2024-05-07 12:17:25 +02:00
/** @var Node\AttributeGroup[] PHP attribute groups */
2024-05-17 12:24:19 +00:00
public array $attrGroups;
2024-05-07 12:17:25 +02:00
/**
* Constructs a class property list node.
*
2024-05-17 12:24:19 +00:00
* @param int $flags Modifiers
* @param PropertyItem[] $props Properties
* @param array<string, mixed> $attributes Additional attributes
* @param null|Identifier|Name|ComplexType $type Type declaration
* @param Node\AttributeGroup[] $attrGroups PHP attribute groups
2024-05-07 12:17:25 +02:00
*/
2024-05-17 12:24:19 +00:00
public function __construct(int $flags, array $props, array $attributes = [], ?Node $type = null, array $attrGroups = []) {
2024-05-07 12:17:25 +02:00
$this->attributes = $attributes;
$this->flags = $flags;
$this->props = $props;
2024-05-17 12:24:19 +00:00
$this->type = $type;
2024-05-07 12:17:25 +02:00
$this->attrGroups = $attrGroups;
}
2024-05-17 12:24:19 +00:00
public function getSubNodeNames(): array {
2024-05-07 12:17:25 +02:00
return ['attrGroups', 'flags', 'type', 'props'];
}
/**
* Whether the property 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 the property 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 the property 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 the property is static.
*/
2024-05-17 12:24:19 +00:00
public function isStatic(): bool {
return (bool) ($this->flags & Modifiers::STATIC);
2024-05-07 12:17:25 +02:00
}
/**
* Whether the property is readonly.
*/
2024-05-17 12:24:19 +00:00
public function isReadonly(): bool {
return (bool) ($this->flags & Modifiers::READONLY);
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_Property';
}
}