Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

Scope.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.06 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\Bridge\Twig\NodeVisitor;
013   
014  /**
015   * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
016   */
017  class Scope
018  {
019      private $parent;
020      private $data = [];
021      private $left = false;
022   
023      public function __construct(self $parent = null)
024      {
025          $this->parent = $parent;
026      }
027   
028      /**
029       * Opens a new child scope.
030       *
031       * @return self
032       */
033      public function enter()
034      {
035          return new self($this);
036      }
037   
038      /**
039       * Closes current scope and returns parent one.
040       *
041       * @return self|null
042       */
043      public function leave()
044      {
045          $this->left = true;
046   
047          return $this->parent;
048      }
049   
050      /**
051       * Stores data into current scope.
052       *
053       * @param string $key
054       * @param mixed  $value
055       *
056       * @return $this
057       *
058       * @throws \LogicException
059       */
060      public function set($key, $value)
061      {
062          if ($this->left) {
063              throw new \LogicException('Left scope is not mutable.');
064          }
065   
066          $this->data[$key] = $value;
067   
068          return $this;
069      }
070   
071      /**
072       * Tests if a data is visible from current scope.
073       *
074       * @param string $key
075       *
076       * @return bool
077       */
078      public function has($key)
079      {
080          if (\array_key_exists($key, $this->data)) {
081              return true;
082          }
083   
084          if (null === $this->parent) {
085              return false;
086          }
087   
088          return $this->parent->has($key);
089      }
090   
091      /**
092       * Returns data visible from current scope.
093       *
094       * @param string $key
095       * @param mixed  $default
096       *
097       * @return mixed
098       */
099      public function get($key, $default = null)
100      {
101          if (\array_key_exists($key, $this->data)) {
102              return $this->data[$key];
103          }
104   
105          if (null === $this->parent) {
106              return $default;
107          }
108   
109          return $this->parent->get($key, $default);
110      }
111  }
112