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

NameInformation.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 3.85 KiB


 001  <?php
 002  /**
 003   * Zend Framework (http://framework.zend.com/)
 004   *
 005   * @link      http://github.com/zendframework/zf2 for the canonical source repository
 006   * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
 007   * @license   http://framework.zend.com/license/new-bsd New BSD License
 008   */
 009   
 010  namespace Zend\Code;
 011   
 012  use function array_key_exists;
 013  use function array_search;
 014  use function is_array;
 015  use function is_int;
 016  use function is_string;
 017  use function ltrim;
 018  use function strlen;
 019  use function strpos;
 020  use function strrpos;
 021  use function substr;
 022  use function substr_replace;
 023  use function trim;
 024   
 025  class NameInformation
 026  {
 027      /**
 028       * @var string
 029       */
 030      protected $namespace;
 031   
 032      /**
 033       * @var array
 034       */
 035      protected $uses = [];
 036   
 037      /**
 038       * @param  string $namespace
 039       * @param  array $uses
 040       */
 041      public function __construct($namespace = null, array $uses = [])
 042      {
 043          if ($namespace) {
 044              $this->setNamespace($namespace);
 045          }
 046          if ($uses) {
 047              $this->setUses($uses);
 048          }
 049      }
 050   
 051      /**
 052       * @param  string $namespace
 053       * @return NameInformation
 054       */
 055      public function setNamespace($namespace)
 056      {
 057          $this->namespace = (string) $namespace;
 058          return $this;
 059      }
 060   
 061      /**
 062       * @return string
 063       */
 064      public function getNamespace()
 065      {
 066          return $this->namespace;
 067      }
 068   
 069      /**
 070       * @return bool
 071       */
 072      public function hasNamespace()
 073      {
 074          return $this->namespace !== null;
 075      }
 076   
 077      /**
 078       * @param  array $uses
 079       * @return NameInformation
 080       */
 081      public function setUses(array $uses)
 082      {
 083          $this->uses = [];
 084          $this->addUses($uses);
 085   
 086          return $this;
 087      }
 088   
 089      /**
 090       * @param  array $uses
 091       * @return NameInformation
 092       */
 093      public function addUses(array $uses)
 094      {
 095          foreach ($uses as $use => $as) {
 096              if (is_int($use)) {
 097                  $this->addUse($as);
 098              } elseif (is_string($use)) {
 099                  $this->addUse($use, $as);
 100              }
 101          }
 102   
 103          return $this;
 104      }
 105   
 106      /**
 107       * @param  array|string $use
 108       * @param  string $as
 109       */
 110      public function addUse($use, $as = null)
 111      {
 112          if (is_array($use) && array_key_exists('use', $use) && array_key_exists('as', $use)) {
 113              $uses = $use;
 114              $use  = $uses['use'];
 115              $as   = $uses['as'];
 116          }
 117   
 118          $use = trim($use, '\\');
 119          if ($as === null) {
 120              $as                  = trim($use, '\\');
 121              $nsSeparatorPosition = strrpos($as, '\\');
 122              if ($nsSeparatorPosition !== false && $nsSeparatorPosition !== 0 && $nsSeparatorPosition != strlen($as)) {
 123                  $as = substr($as, $nsSeparatorPosition + 1);
 124              }
 125          }
 126   
 127          $this->uses[$use] = $as;
 128      }
 129   
 130      /**
 131       * @return array
 132       */
 133      public function getUses()
 134      {
 135          return $this->uses;
 136      }
 137   
 138      /**
 139       * @param  string $name
 140       * @return string
 141       */
 142      public function resolveName($name)
 143      {
 144          if ($this->namespace && ! $this->uses && strlen($name) > 0 && $name[0] != '\\') {
 145              return $this->namespace . '\\' . $name;
 146          }
 147   
 148          if (! $this->uses || strlen($name) <= 0 || $name[0] == '\\') {
 149              return ltrim($name, '\\');
 150          }
 151   
 152          if ($this->namespace || $this->uses) {
 153              $firstPart = $name;
 154              if (($firstPartEnd = strpos($firstPart, '\\')) !== false) {
 155                  $firstPart = substr($firstPart, 0, $firstPartEnd);
 156              } else {
 157                  $firstPartEnd = strlen($firstPart);
 158              }
 159              if (($fqns = array_search($firstPart, $this->uses)) !== false) {
 160                  return substr_replace($name, $fqns, 0, $firstPartEnd);
 161              }
 162              if ($this->namespace) {
 163                  return $this->namespace . '\\' . $name;
 164              }
 165          }
 166   
 167          return $name;
 168      }
 169  }
 170