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

85 lines
2.5 KiB
PHP
Raw Normal View History

2024-05-07 12:17:25 +02:00
<?php declare(strict_types=1);
namespace PhpParser\Node;
2024-05-17 12:24:19 +00:00
use PhpParser\Modifiers;
use PhpParser\Node;
2024-05-07 12:17:25 +02:00
use PhpParser\NodeAbstract;
2024-05-17 12:24:19 +00:00
class Param extends NodeAbstract {
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 bool Whether parameter is passed by reference */
2024-05-17 12:24:19 +00:00
public bool $byRef;
2024-05-07 12:17:25 +02:00
/** @var bool Whether this is a variadic argument */
2024-05-17 12:24:19 +00:00
public bool $variadic;
2024-05-07 12:17:25 +02:00
/** @var Expr\Variable|Expr\Error Parameter variable */
2024-05-17 12:24:19 +00:00
public Expr $var;
2024-05-07 12:17:25 +02:00
/** @var null|Expr Default value */
2024-05-17 12:24:19 +00:00
public ?Expr $default;
/** @var int Optional visibility flags */
public int $flags;
2024-05-07 12:17:25 +02:00
/** @var 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 parameter node.
*
2024-05-17 12:24:19 +00:00
* @param Expr\Variable|Expr\Error $var Parameter variable
* @param null|Expr $default Default value
* @param null|Identifier|Name|ComplexType $type Type declaration
* @param bool $byRef Whether is passed by reference
* @param bool $variadic Whether this is a variadic argument
* @param array<string, mixed> $attributes Additional attributes
* @param int $flags Optional visibility flags
* @param list<AttributeGroup> $attrGroups PHP attribute groups
2024-05-07 12:17:25 +02:00
*/
public function __construct(
2024-05-17 12:24:19 +00:00
Expr $var, ?Expr $default = null, ?Node $type = null,
2024-05-07 12:17:25 +02:00
bool $byRef = false, bool $variadic = false,
array $attributes = [],
int $flags = 0,
array $attrGroups = []
) {
$this->attributes = $attributes;
2024-05-17 12:24:19 +00:00
$this->type = $type;
2024-05-07 12:17:25 +02:00
$this->byRef = $byRef;
$this->variadic = $variadic;
$this->var = $var;
$this->default = $default;
$this->flags = $flags;
$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', 'byRef', 'variadic', 'var', 'default'];
}
2024-05-17 12:24:19 +00:00
public function getType(): string {
2024-05-07 12:17:25 +02:00
return 'Param';
}
2024-05-17 12:24:19 +00:00
/**
* Whether this parameter uses constructor property promotion.
*/
public function isPromoted(): bool {
return $this->flags !== 0;
}
public function isPublic(): bool {
return (bool) ($this->flags & Modifiers::PUBLIC);
}
public function isProtected(): bool {
return (bool) ($this->flags & Modifiers::PROTECTED);
}
public function isPrivate(): bool {
return (bool) ($this->flags & Modifiers::PRIVATE);
}
public function isReadonly(): bool {
return (bool) ($this->flags & Modifiers::READONLY);
}
2024-05-07 12:17:25 +02:00
}