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

Yaml.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 3.26 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\Component\Yaml;
 013   
 014  use Symfony\Component\Yaml\Exception\ParseException;
 015   
 016  /**
 017   * Yaml offers convenience methods to load and dump YAML.
 018   *
 019   * @author Fabien Potencier <fabien@symfony.com>
 020   *
 021   * @api
 022   */
 023  class Yaml
 024  {
 025      /**
 026       * Parses YAML into a PHP array.
 027       *
 028       * The parse method, when supplied with a YAML stream (string or file),
 029       * will do its best to convert YAML in a file into a PHP array.
 030       *
 031       *  Usage:
 032       *  <code>
 033       *   $array = Yaml::parse('config.yml');
 034       *   print_r($array);
 035       *  </code>
 036       *
 037       * As this method accepts both plain strings and file names as an input,
 038       * you must validate the input before calling this method. Passing a file
 039       * as an input is a deprecated feature and will be removed in 3.0.
 040       *
 041       * @param string  $input                  Path to a YAML file or a string containing YAML
 042       * @param bool    $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise
 043       * @param bool    $objectSupport          True if object support is enabled, false otherwise
 044       *
 045       * @return array The YAML converted to a PHP array
 046       *
 047       * @throws ParseException If the YAML is not valid
 048       *
 049       * @api
 050       */
 051      public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false)
 052      {
 053          // if input is a file, process it
 054          $file = '';
 055          if (strpos($input, "\n") === false && is_file($input)) {
 056              if (false === is_readable($input)) {
 057                  throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input));
 058              }
 059   
 060              $file = $input;
 061              $input = file_get_contents($file);
 062          }
 063   
 064          $yaml = new Parser();
 065   
 066          try {
 067              return $yaml->parse($input, $exceptionOnInvalidType, $objectSupport);
 068          } catch (ParseException $e) {
 069              if ($file) {
 070                  $e->setParsedFile($file);
 071              }
 072   
 073              throw $e;
 074          }
 075      }
 076   
 077      /**
 078       * Dumps a PHP array to a YAML string.
 079       *
 080       * The dump method, when supplied with an array, will do its best
 081       * to convert the array into friendly YAML.
 082       *
 083       * @param array   $array                  PHP array
 084       * @param int     $inline                 The level where you switch to inline YAML
 085       * @param int     $indent                 The amount of spaces to use for indentation of nested nodes.
 086       * @param bool    $exceptionOnInvalidType true if an exception must be thrown on invalid types (a PHP resource or object), false otherwise
 087       * @param bool    $objectSupport          true if object support is enabled, false otherwise
 088       *
 089       * @return string A YAML string representing the original PHP array
 090       *
 091       * @api
 092       */
 093      public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
 094      {
 095          $yaml = new Dumper();
 096          $yaml->setIndentation($indent);
 097   
 098          return $yaml->dump($array, $inline, 0, $exceptionOnInvalidType, $objectSupport);
 099      }
 100  }
 101