Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

TokenStream.php

Zuletzt modifiziert: 09.10.2024, 12:57 - Dateigröße: 3.52 KiB


 001  <?php
 002   
 003  /*
 004   * This file is part of Twig.
 005   *
 006   * (c) 2009 Fabien Potencier
 007   * (c) 2009 Armin Ronacher
 008   *
 009   * For the full copyright and license information, please view the LICENSE
 010   * file that was distributed with this source code.
 011   */
 012   
 013  /**
 014   * Represents a token stream.
 015   *
 016   * @author Fabien Potencier <fabien@symfony.com>
 017   */
 018  class Twig_TokenStream
 019  {
 020      protected $tokens;
 021      protected $current;
 022      protected $filename;
 023   
 024      /**
 025       * Constructor.
 026       *
 027       * @param array  $tokens   An array of tokens
 028       * @param string $filename The name of the filename which tokens are associated with
 029       */
 030      public function __construct(array $tokens, $filename = null)
 031      {
 032          $this->tokens     = $tokens;
 033          $this->current    = 0;
 034          $this->filename   = $filename;
 035      }
 036   
 037      /**
 038       * Returns a string representation of the token stream.
 039       *
 040       * @return string
 041       */
 042      public function __toString()
 043      {
 044          return implode("\n", $this->tokens);
 045      }
 046   
 047      public function injectTokens(array $tokens)
 048      {
 049          $this->tokens = array_merge(array_slice($this->tokens, 0, $this->current), $tokens, array_slice($this->tokens, $this->current));
 050      }
 051   
 052      /**
 053       * Sets the pointer to the next token and returns the old one.
 054       *
 055       * @return Twig_Token
 056       */
 057      public function next()
 058      {
 059          if (!isset($this->tokens[++$this->current])) {
 060              throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current - 1]->getLine(), $this->filename);
 061          }
 062   
 063          return $this->tokens[$this->current - 1];
 064      }
 065   
 066      /**
 067       * Tests a token and returns it or throws a syntax error.
 068       *
 069       * @return Twig_Token
 070       */
 071      public function expect($type, $value = null, $message = null)
 072      {
 073          $token = $this->tokens[$this->current];
 074          if (!$token->test($type, $value)) {
 075              $line = $token->getLine();
 076              throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)',
 077                  $message ? $message.'. ' : '',
 078                  Twig_Token::typeToEnglish($token->getType(), $line), $token->getValue(),
 079                  Twig_Token::typeToEnglish($type, $line), $value ? sprintf(' with value "%s"', $value) : ''),
 080                  $line,
 081                  $this->filename
 082              );
 083          }
 084          $this->next();
 085   
 086          return $token;
 087      }
 088   
 089      /**
 090       * Looks at the next token.
 091       *
 092       * @param integer $number
 093       *
 094       * @return Twig_Token
 095       */
 096      public function look($number = 1)
 097      {
 098          if (!isset($this->tokens[$this->current + $number])) {
 099              throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current + $number - 1]->getLine(), $this->filename);
 100          }
 101   
 102          return $this->tokens[$this->current + $number];
 103      }
 104   
 105      /**
 106       * Tests the current token
 107       *
 108       * @return bool
 109       */
 110      public function test($primary, $secondary = null)
 111      {
 112          return $this->tokens[$this->current]->test($primary, $secondary);
 113      }
 114   
 115      /**
 116       * Checks if end of stream was reached
 117       *
 118       * @return bool
 119       */
 120      public function isEOF()
 121      {
 122          return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE;
 123      }
 124   
 125      /**
 126       * Gets the current token
 127       *
 128       * @return Twig_Token
 129       */
 130      public function getCurrent()
 131      {
 132          return $this->tokens[$this->current];
 133      }
 134   
 135      /**
 136       * Gets the filename associated with this stream
 137       *
 138       * @return string
 139       */
 140      public function getFilename()
 141      {
 142          return $this->filename;
 143      }
 144  }
 145