Verzeichnisstruktur phpBB-3.3.15


Veröffentlicht
28.08.2024

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

DataCollector.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.94 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\HttpKernel\DataCollector;
013   
014  use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
015  use Symfony\Component\VarDumper\Caster\CutStub;
016  use Symfony\Component\VarDumper\Cloner\ClonerInterface;
017  use Symfony\Component\VarDumper\Cloner\Data;
018  use Symfony\Component\VarDumper\Cloner\Stub;
019  use Symfony\Component\VarDumper\Cloner\VarCloner;
020   
021  /**
022   * DataCollector.
023   *
024   * Children of this class must store the collected data in the data property.
025   *
026   * @author Fabien Potencier <fabien@symfony.com>
027   * @author Bernhard Schussek <bschussek@symfony.com>
028   */
029  abstract class DataCollector implements DataCollectorInterface, \Serializable
030  {
031      /**
032       * @var array|Data
033       */
034      protected $data = [];
035   
036      /**
037       * @var ValueExporter
038       */
039      private $valueExporter;
040   
041      /**
042       * @var ClonerInterface
043       */
044      private $cloner;
045   
046      public function serialize()
047      {
048          $trace = debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT, 2);
049          $isCalledFromOverridingMethod = isset($trace[1]['function'], $trace[1]['object']) && 'serialize' === $trace[1]['function'] && $this === $trace[1]['object'];
050   
051          return $isCalledFromOverridingMethod ? $this->data : serialize($this->data);
052      }
053   
054      public function unserialize($data)
055      {
056          $this->data = \is_array($data) ? $data : unserialize($data);
057      }
058   
059      /**
060       * Converts the variable into a serializable Data instance.
061       *
062       * This array can be displayed in the template using
063       * the VarDumper component.
064       *
065       * @param mixed $var
066       *
067       * @return Data
068       */
069      protected function cloneVar($var)
070      {
071          if ($var instanceof Data) {
072              return $var;
073          }
074          if (null === $this->cloner) {
075              if (class_exists(CutStub::class)) {
076                  $this->cloner = new VarCloner();
077                  $this->cloner->setMaxItems(-1);
078                  $this->cloner->addCasters($this->getCasters());
079              } else {
080                  @trigger_error(sprintf('Using the %s() method without the VarDumper component is deprecated since Symfony 3.2 and won\'t be supported in 4.0. Install symfony/var-dumper version 3.2 or above.', __METHOD__), \E_USER_DEPRECATED);
081                  $this->cloner = false;
082              }
083          }
084          if (false === $this->cloner) {
085              if (null === $this->valueExporter) {
086                  $this->valueExporter = new ValueExporter();
087              }
088   
089              return $this->valueExporter->exportValue($var);
090          }
091   
092          return $this->cloner->cloneVar($var);
093      }
094   
095      /**
096       * Converts a PHP variable to a string.
097       *
098       * @param mixed $var A PHP variable
099       *
100       * @return string The string representation of the variable
101       *
102       * @deprecated since version 3.2, to be removed in 4.0. Use cloneVar() instead.
103       */
104      protected function varToString($var)
105      {
106          @trigger_error(sprintf('The %s() method is deprecated since Symfony 3.2 and will be removed in 4.0. Use cloneVar() instead.', __METHOD__), \E_USER_DEPRECATED);
107   
108          if (null === $this->valueExporter) {
109              $this->valueExporter = new ValueExporter();
110          }
111   
112          return $this->valueExporter->exportValue($var);
113      }
114   
115      /**
116       * @return callable[] The casters to add to the cloner
117       */
118      protected function getCasters()
119      {
120          return [
121              '*' => function ($v, array $a, Stub $s, $isNested) {
122                  if (!$v instanceof Stub) {
123                      foreach ($a as $k => $v) {
124                          if (\is_object($v) && !$v instanceof \DateTimeInterface && !$v instanceof Stub) {
125                              $a[$k] = new CutStub($v);
126                          }
127                      }
128                  }
129   
130                  return $a;
131              },
132          ];
133      }
134  }
135