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

Yaml.php

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