Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Param.php

class Param

Same name in this branch
  1. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Param.php \PhpParser\Node\Param
  2. 11.1.x vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php \phpDocumentor\Reflection\DocBlock\Tags\Param

Hierarchy

  • class \PhpParser\Builder\Param implements \PhpParser\Builder

Expanded class hierarchy of Param

5 string references to 'Param'
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml
DocBlockFactory::createInstance in vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php
Factory method for easy instantiation.
Param::getType in vendor/nikic/php-parser/lib/PhpParser/Node/Param.php
Gets the type of the node.
Param::__construct in vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Param.php
ParamFactory::create in vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/ParamFactory.php

File

vendor/nikic/php-parser/lib/PhpParser/Builder/Param.php, line 10

Namespace

PhpParser\Builder
View source
class Param implements PhpParser\Builder {
    protected string $name;
    protected ?Node\Expr $default = null;
    
    /** @var Node\Identifier|Node\Name|Node\ComplexType|null */
    protected ?Node $type = null;
    protected bool $byRef = false;
    protected int $flags = 0;
    protected bool $variadic = false;
    
    /** @var list<Node\AttributeGroup> */
    protected array $attributeGroups = [];
    
    /**
     * Creates a parameter builder.
     *
     * @param string $name Name of the parameter
     */
    public function __construct(string $name) {
        $this->name = $name;
    }
    
    /**
     * Sets default value for the parameter.
     *
     * @param mixed $value Default value to use
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function setDefault($value) {
        $this->default = BuilderHelpers::normalizeValue($value);
        return $this;
    }
    
    /**
     * Sets type for the parameter.
     *
     * @param string|Node\Name|Node\Identifier|Node\ComplexType $type Parameter type
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function setType($type) {
        $this->type = BuilderHelpers::normalizeType($type);
        if ($this->type == 'void') {
            throw new \LogicException('Parameter type cannot be void');
        }
        return $this;
    }
    
    /**
     * Make the parameter accept the value by reference.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makeByRef() {
        $this->byRef = true;
        return $this;
    }
    
    /**
     * Make the parameter variadic
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makeVariadic() {
        $this->variadic = true;
        return $this;
    }
    
    /**
     * Makes the (promoted) parameter public.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makePublic() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PUBLIC);
        return $this;
    }
    
    /**
     * Makes the (promoted) parameter protected.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makeProtected() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED);
        return $this;
    }
    
    /**
     * Makes the (promoted) parameter private.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makePrivate() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE);
        return $this;
    }
    
    /**
     * Makes the (promoted) parameter readonly.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makeReadonly() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::READONLY);
        return $this;
    }
    
    /**
     * Gives the promoted property private(set) visibility.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makePrivateSet() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PRIVATE_SET);
        return $this;
    }
    
    /**
     * Gives the promoted property protected(set) visibility.
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function makeProtectedSet() {
        $this->flags = BuilderHelpers::addModifier($this->flags, Modifiers::PROTECTED_SET);
        return $this;
    }
    
    /**
     * Adds an attribute group.
     *
     * @param Node\Attribute|Node\AttributeGroup $attribute
     *
     * @return $this The builder instance (for fluid interface)
     */
    public function addAttribute($attribute) {
        $this->attributeGroups[] = BuilderHelpers::normalizeAttribute($attribute);
        return $this;
    }
    
    /**
     * Returns the built parameter node.
     *
     * @return Node\Param The built parameter node
     */
    public function getNode() : Node {
        return new Node\Param(new Node\Expr\Variable($this->name), $this->default, $this->type, $this->byRef, $this->variadic, [], $this->flags, $this->attributeGroups);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
Param::$attributeGroups protected property @var list&lt;Node\AttributeGroup&gt;
Param::$byRef protected property
Param::$default protected property
Param::$flags protected property
Param::$name protected property
Param::$type protected property @var Node\Identifier|Node\Name|Node\ComplexType|null
Param::$variadic protected property
Param::addAttribute public function Adds an attribute group.
Param::getNode public function Returns the built parameter node. Overrides Builder::getNode
Param::makeByRef public function Make the parameter accept the value by reference.
Param::makePrivate public function Makes the (promoted) parameter private.
Param::makePrivateSet public function Gives the promoted property private(set) visibility.
Param::makeProtected public function Makes the (promoted) parameter protected.
Param::makeProtectedSet public function Gives the promoted property protected(set) visibility.
Param::makePublic public function Makes the (promoted) parameter public.
Param::makeReadonly public function Makes the (promoted) parameter readonly.
Param::makeVariadic public function Make the parameter variadic
Param::setDefault public function Sets default value for the parameter.
Param::setType public function Sets type for the parameter.
Param::__construct public function Creates a parameter builder.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal