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

DeclareStatement.php

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


 001  <?php
 002   
 003  namespace Zend\Code;
 004   
 005  use Zend\Code\Exception\InvalidArgumentException;
 006   
 007  class DeclareStatement
 008  {
 009      public const TICKS = 'ticks';
 010      public const STRICT_TYPES = 'strict_types';
 011      public const ENCODING = 'encoding';
 012   
 013      private const ALLOWED = [
 014          self::TICKS        => 'integer',
 015          self::STRICT_TYPES => 'integer',
 016          self::ENCODING     => 'string',
 017      ];
 018   
 019      /**
 020       * @var string
 021       */
 022      protected $directive;
 023   
 024      /**
 025       * @var int|string
 026       */
 027      protected $value;
 028   
 029      private function __construct(string $directive, $value)
 030      {
 031          $this->directive = $directive;
 032          $this->value = $value;
 033      }
 034   
 035      /**
 036       * @return string
 037       */
 038      public function getDirective(): string
 039      {
 040          return $this->directive;
 041      }
 042   
 043      /**
 044       * @return int|string
 045       */
 046      public function getValue()
 047      {
 048          return $this->value;
 049      }
 050   
 051      /**
 052       * @param int $value
 053       * @return self
 054       */
 055      public static function ticks(int $value): self
 056      {
 057          return new self(self::TICKS, $value);
 058      }
 059   
 060      /**
 061       * @param int $value
 062       * @return self
 063       */
 064      public static function strictTypes(int $value): self
 065      {
 066          return new self(self::STRICT_TYPES, $value);
 067      }
 068   
 069      /**
 070       * @param string $value
 071       * @return self
 072       */
 073      public static function encoding(string $value): self
 074      {
 075          return new self(self::ENCODING, $value);
 076      }
 077   
 078      public static function fromArray(array $config): self
 079      {
 080          $directive = key($config);
 081          $value = $config[$directive];
 082   
 083          if (! isset(self::ALLOWED[$directive])) {
 084              throw new InvalidArgumentException(
 085                  sprintf(
 086                      'Declare directive must be one of: %s.',
 087                      implode(', ', array_keys(self::ALLOWED))
 088                  )
 089              );
 090          }
 091   
 092          if (gettype($value) !== self::ALLOWED[$directive]) {
 093              throw new InvalidArgumentException(
 094                  sprintf(
 095                      'Declare value invalid. Expected %s, got %s.',
 096                      self::ALLOWED[$directive],
 097                      gettype($value)
 098                  )
 099              );
 100          }
 101   
 102          $method = str_replace('_', '', lcfirst(ucwords($directive, '_')));
 103   
 104          return self::{$method}($value);
 105      }
 106   
 107      /**
 108       * @return string
 109       */
 110      public function getStatement(): string
 111      {
 112          $value = is_string($this->value) ? '\'' . $this->value . '\'' : $this->value;
 113   
 114          return sprintf('declare(%s=%s);', $this->directive, $value);
 115      }
 116  }
 117