Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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: 09.10.2024, 12:56 - Dateigröße: 2.23 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      /**
020       * @var Scope|null
021       */
022      private $parent;
023   
024      /**
025       * @var array
026       */
027      private $data = array();
028   
029      /**
030       * @var bool
031       */
032      private $left = false;
033   
034      /**
035       * @param Scope $parent
036       */
037      public function __construct(Scope $parent = null)
038      {
039          $this->parent = $parent;
040      }
041   
042      /**
043       * Opens a new child scope.
044       *
045       * @return Scope
046       */
047      public function enter()
048      {
049          return new self($this);
050      }
051   
052      /**
053       * Closes current scope and returns parent one.
054       *
055       * @return Scope|null
056       */
057      public function leave()
058      {
059          $this->left = true;
060   
061          return $this->parent;
062      }
063   
064      /**
065       * Stores data into current scope.
066       *
067       * @param string $key
068       * @param mixed  $value
069       *
070       * @return Scope Current scope
071       *
072       * @throws \LogicException
073       */
074      public function set($key, $value)
075      {
076          if ($this->left) {
077              throw new \LogicException('Left scope is not mutable.');
078          }
079   
080          $this->data[$key] = $value;
081   
082          return $this;
083      }
084   
085      /**
086       * Tests if a data is visible from current scope.
087       *
088       * @param string $key
089       *
090       * @return bool
091       */
092      public function has($key)
093      {
094          if (array_key_exists($key, $this->data)) {
095              return true;
096          }
097   
098          if (null === $this->parent) {
099              return false;
100          }
101   
102          return $this->parent->has($key);
103      }
104   
105      /**
106       * Returns data visible from current scope.
107       *
108       * @param string $key
109       * @param mixed  $default
110       *
111       * @return mixed
112       */
113      public function get($key, $default = null)
114      {
115          if (array_key_exists($key, $this->data)) {
116              return $this->data[$key];
117          }
118   
119          if (null === $this->parent) {
120              return $default;
121          }
122   
123          return $this->parent->get($key, $default);
124      }
125  }
126