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

Breadcrumb

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

function InputArgument::setDefault

Sets the default value.

1 call to InputArgument::setDefault()
InputArgument::__construct in vendor/symfony/console/Input/InputArgument.php

File

vendor/symfony/console/Input/InputArgument.php, line 104

Class

InputArgument
Represents a command line argument.

Namespace

Symfony\Component\Console\Input

Code

public function setDefault(string|bool|int|float|array|null $default) : void {
    if ($this->isRequired() && null !== $default) {
        throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
    }
    if ($this->isArray()) {
        if (null === $default) {
            $default = [];
        }
        elseif (!\is_array($default)) {
            throw new LogicException('A default value for an array argument must be an array.');
        }
    }
    $this->default = $default;
}

API Navigation

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