Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

InputArgument.php

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 3.33 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of the Symfony package.
 005   *
 006   * (c) Fabien Potencier <fabien@symfony.com>
 007   *
 008   * For the full copyright and license information, please view the LICENSE
 009   * file that was distributed with this source code.
 010   */
 011   
 012  namespace Symfony\Component\Console\Input;
 013   
 014  use Symfony\Component\Console\Exception\InvalidArgumentException;
 015  use Symfony\Component\Console\Exception\LogicException;
 016   
 017  /**
 018   * Represents a command line argument.
 019   *
 020   * @author Fabien Potencier <fabien@symfony.com>
 021   */
 022  class InputArgument
 023  {
 024      const REQUIRED = 1;
 025      const OPTIONAL = 2;
 026      const IS_ARRAY = 4;
 027   
 028      private $name;
 029      private $mode;
 030      private $default;
 031      private $description;
 032   
 033      /**
 034       * @param string               $name        The argument name
 035       * @param int|null             $mode        The argument mode: self::REQUIRED or self::OPTIONAL
 036       * @param string               $description A description text
 037       * @param string|string[]|null $default     The default value (for self::OPTIONAL mode only)
 038       *
 039       * @throws InvalidArgumentException When argument mode is not valid
 040       */
 041      public function __construct($name, $mode = null, $description = '', $default = null)
 042      {
 043          if (null === $mode) {
 044              $mode = self::OPTIONAL;
 045          } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
 046              throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
 047          }
 048   
 049          $this->name = $name;
 050          $this->mode = $mode;
 051          $this->description = $description;
 052   
 053          $this->setDefault($default);
 054      }
 055   
 056      /**
 057       * Returns the argument name.
 058       *
 059       * @return string The argument name
 060       */
 061      public function getName()
 062      {
 063          return $this->name;
 064      }
 065   
 066      /**
 067       * Returns true if the argument is required.
 068       *
 069       * @return bool true if parameter mode is self::REQUIRED, false otherwise
 070       */
 071      public function isRequired()
 072      {
 073          return self::REQUIRED === (self::REQUIRED & $this->mode);
 074      }
 075   
 076      /**
 077       * Returns true if the argument can take multiple values.
 078       *
 079       * @return bool true if mode is self::IS_ARRAY, false otherwise
 080       */
 081      public function isArray()
 082      {
 083          return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
 084      }
 085   
 086      /**
 087       * Sets the default value.
 088       *
 089       * @param string|string[]|null $default The default value
 090       *
 091       * @throws LogicException When incorrect default value is given
 092       */
 093      public function setDefault($default = null)
 094      {
 095          if (self::REQUIRED === $this->mode && null !== $default) {
 096              throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
 097          }
 098   
 099          if ($this->isArray()) {
 100              if (null === $default) {
 101                  $default = [];
 102              } elseif (!\is_array($default)) {
 103                  throw new LogicException('A default value for an array argument must be an array.');
 104              }
 105          }
 106   
 107          $this->default = $default;
 108      }
 109   
 110      /**
 111       * Returns the default value.
 112       *
 113       * @return string|string[]|null The default value
 114       */
 115      public function getDefault()
 116      {
 117          return $this->default;
 118      }
 119   
 120      /**
 121       * Returns the description text.
 122       *
 123       * @return string The description text
 124       */
 125      public function getDescription()
 126      {
 127          return $this->description;
 128      }
 129  }
 130