Phan\Language\Element\Parameter::setDefaultValue PHP Method

setDefaultValue() public method

public setDefaultValue ( mixed $value ) : void
$value mixed The value of the default for this parameter
return void
    public function setDefaultValue($value)
    {
        $this->default_value = $value;
    }

Usage Example

Example #1
0
 /**
  * @return Parameter
  * A parameter built from a node
  *
  * @see \Phan\Deprecated\Pass1::node_param
  * Formerly `function node_param`
  */
 public static function fromNode(Context $context, CodeBase $code_base, Node $node) : Parameter
 {
     assert($node instanceof Node, "node was not an \\ast\\Node");
     // Get the type of the parameter
     $type = UnionType::fromSimpleNode($context, $node->children['type']);
     $comment = Comment::fromStringInContext($node->docComment ?? '', $context);
     // Create the skeleton parameter from what we know so far
     $parameter = new Parameter($context, (string) $node->children['name'], $type, $node->flags ?? 0);
     // If there is a default value, store it and its type
     if (($default_node = $node->children['default']) !== null) {
         // We can't figure out default values during the
         // parsing phase, unfortunately
         if (!$default_node instanceof Node || $default_node->kind == \ast\AST_CONST || $default_node->kind == \ast\AST_UNARY_OP || $default_node->kind == \ast\AST_ARRAY) {
             // Set the default value
             $parameter->setDefaultValue($node->children['default'], UnionType::fromNode($context, $code_base, $node->children['default']));
         } else {
             // Nodes here may be of type \ast\AST_CLASS_CONST
             // which we can't figure out during the first
             // parsing pass
             $parameter->setDefaultValue(null, NullType::instance()->asUnionType());
         }
     }
     return $parameter;
 }
All Usage Examples Of Phan\Language\Element\Parameter::setDefaultValue