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

Breadcrumb

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

function InputOption::setDefault

Sets the default value.

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

File

vendor/symfony/console/Input/InputOption.php, line 191

Class

InputOption
Represents a command line option.

Namespace

Symfony\Component\Console\Input

Code

public function setDefault(string|bool|int|float|array|null $default) : void {
    if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
        throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
    }
    if ($this->isArray()) {
        if (null === $default) {
            $default = [];
        }
        elseif (!\is_array($default)) {
            throw new LogicException('A default value for an array option must be an array.');
        }
    }
    $this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
}

API Navigation

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