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

ParameterBag.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 5.82 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\HttpFoundation;
 013   
 014  /**
 015   * ParameterBag is a container for key/value pairs.
 016   *
 017   * @author Fabien Potencier <fabien@symfony.com>
 018   */
 019  class ParameterBag implements \IteratorAggregate, \Countable
 020  {
 021      /**
 022       * Parameter storage.
 023       */
 024      protected $parameters;
 025   
 026      /**
 027       * @param array $parameters An array of parameters
 028       */
 029      public function __construct(array $parameters = [])
 030      {
 031          $this->parameters = $parameters;
 032      }
 033   
 034      /**
 035       * Returns the parameters.
 036       *
 037       * @return array An array of parameters
 038       */
 039      public function all()
 040      {
 041          return $this->parameters;
 042      }
 043   
 044      /**
 045       * Returns the parameter keys.
 046       *
 047       * @return array An array of parameter keys
 048       */
 049      public function keys()
 050      {
 051          return array_keys($this->parameters);
 052      }
 053   
 054      /**
 055       * Replaces the current parameters by a new set.
 056       *
 057       * @param array $parameters An array of parameters
 058       */
 059      public function replace(array $parameters = [])
 060      {
 061          $this->parameters = $parameters;
 062      }
 063   
 064      /**
 065       * Adds parameters.
 066       *
 067       * @param array $parameters An array of parameters
 068       */
 069      public function add(array $parameters = [])
 070      {
 071          $this->parameters = array_replace($this->parameters, $parameters);
 072      }
 073   
 074      /**
 075       * Returns a parameter by name.
 076       *
 077       * @param string $key     The key
 078       * @param mixed  $default The default value if the parameter key does not exist
 079       *
 080       * @return mixed
 081       */
 082      public function get($key, $default = null)
 083      {
 084          return \array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
 085      }
 086   
 087      /**
 088       * Sets a parameter by name.
 089       *
 090       * @param string $key   The key
 091       * @param mixed  $value The value
 092       */
 093      public function set($key, $value)
 094      {
 095          $this->parameters[$key] = $value;
 096      }
 097   
 098      /**
 099       * Returns true if the parameter is defined.
 100       *
 101       * @param string $key The key
 102       *
 103       * @return bool true if the parameter exists, false otherwise
 104       */
 105      public function has($key)
 106      {
 107          return \array_key_exists($key, $this->parameters);
 108      }
 109   
 110      /**
 111       * Removes a parameter.
 112       *
 113       * @param string $key The key
 114       */
 115      public function remove($key)
 116      {
 117          unset($this->parameters[$key]);
 118      }
 119   
 120      /**
 121       * Returns the alphabetic characters of the parameter value.
 122       *
 123       * @param string $key     The parameter key
 124       * @param string $default The default value if the parameter key does not exist
 125       *
 126       * @return string The filtered value
 127       */
 128      public function getAlpha($key, $default = '')
 129      {
 130          return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default));
 131      }
 132   
 133      /**
 134       * Returns the alphabetic characters and digits of the parameter value.
 135       *
 136       * @param string $key     The parameter key
 137       * @param string $default The default value if the parameter key does not exist
 138       *
 139       * @return string The filtered value
 140       */
 141      public function getAlnum($key, $default = '')
 142      {
 143          return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default));
 144      }
 145   
 146      /**
 147       * Returns the digits of the parameter value.
 148       *
 149       * @param string $key     The parameter key
 150       * @param string $default The default value if the parameter key does not exist
 151       *
 152       * @return string The filtered value
 153       */
 154      public function getDigits($key, $default = '')
 155      {
 156          // we need to remove - and + because they're allowed in the filter
 157          return str_replace(['-', '+'], '', $this->filter($key, $default, \FILTER_SANITIZE_NUMBER_INT));
 158      }
 159   
 160      /**
 161       * Returns the parameter value converted to integer.
 162       *
 163       * @param string $key     The parameter key
 164       * @param int    $default The default value if the parameter key does not exist
 165       *
 166       * @return int The filtered value
 167       */
 168      public function getInt($key, $default = 0)
 169      {
 170          return (int) $this->get($key, $default);
 171      }
 172   
 173      /**
 174       * Returns the parameter value converted to boolean.
 175       *
 176       * @param string $key     The parameter key
 177       * @param bool   $default The default value if the parameter key does not exist
 178       *
 179       * @return bool The filtered value
 180       */
 181      public function getBoolean($key, $default = false)
 182      {
 183          return $this->filter($key, $default, \FILTER_VALIDATE_BOOLEAN);
 184      }
 185   
 186      /**
 187       * Filter key.
 188       *
 189       * @param string $key     Key
 190       * @param mixed  $default Default = null
 191       * @param int    $filter  FILTER_* constant
 192       * @param mixed  $options Filter options
 193       *
 194       * @see https://php.net/filter-var
 195       *
 196       * @return mixed
 197       */
 198      public function filter($key, $default = null, $filter = \FILTER_DEFAULT, $options = [])
 199      {
 200          $value = $this->get($key, $default);
 201   
 202          // Always turn $options into an array - this allows filter_var option shortcuts.
 203          if (!\is_array($options) && $options) {
 204              $options = ['flags' => $options];
 205          }
 206   
 207          // Add a convenience check for arrays.
 208          if (\is_array($value) && !isset($options['flags'])) {
 209              $options['flags'] = \FILTER_REQUIRE_ARRAY;
 210          }
 211   
 212          return filter_var($value, $filter, $options);
 213      }
 214   
 215      /**
 216       * Returns an iterator for parameters.
 217       *
 218       * @return \ArrayIterator An \ArrayIterator instance
 219       */
 220      public function getIterator()
 221      {
 222          return new \ArrayIterator($this->parameters);
 223      }
 224   
 225      /**
 226       * Returns the number of parameters.
 227       *
 228       * @return int The number of parameters
 229       */
 230      public function count()
 231      {
 232          return \count($this->parameters);
 233      }
 234  }
 235