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

PassConfig.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 7.70 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\DependencyInjection\Compiler;
013   
014  use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
015   
016  /**
017   * Compiler Pass Configuration.
018   *
019   * This class has a default configuration embedded.
020   *
021   * @author Johannes M. Schmitt <schmittjoh@gmail.com>
022   */
023  class PassConfig
024  {
025      const TYPE_AFTER_REMOVING = 'afterRemoving';
026      const TYPE_BEFORE_OPTIMIZATION = 'beforeOptimization';
027      const TYPE_BEFORE_REMOVING = 'beforeRemoving';
028      const TYPE_OPTIMIZE = 'optimization';
029      const TYPE_REMOVE = 'removing';
030   
031      private $mergePass;
032      private $afterRemovingPasses = [];
033      private $beforeOptimizationPasses = [];
034      private $beforeRemovingPasses = [];
035      private $optimizationPasses;
036      private $removingPasses;
037   
038      public function __construct()
039      {
040          $this->mergePass = new MergeExtensionConfigurationPass();
041   
042          $this->beforeOptimizationPasses = [
043              100 => [
044                  $resolveClassPass = new ResolveClassPass(),
045                  new ResolveInstanceofConditionalsPass(),
046                  new RegisterEnvVarProcessorsPass(),
047              ],
048              -1000 => [new ExtensionCompilerPass()],
049          ];
050   
051          $this->optimizationPasses = [[
052              new ResolveChildDefinitionsPass(),
053              new ServiceLocatorTagPass(),
054              new RegisterServiceSubscribersPass(),
055              new DecoratorServicePass(),
056              new ResolveParameterPlaceHoldersPass(false, false),
057              new ResolveFactoryClassPass(),
058              new FactoryReturnTypePass($resolveClassPass),
059              new CheckDefinitionValidityPass(),
060              new ResolveNamedArgumentsPass(),
061              new AutowireRequiredMethodsPass(),
062              new ResolveBindingsPass(),
063              new AutowirePass(false),
064              new ResolveTaggedIteratorArgumentPass(),
065              new ResolveServiceSubscribersPass(),
066              new ResolveReferencesToAliasesPass(),
067              new ResolveInvalidReferencesPass(),
068              new AnalyzeServiceReferencesPass(true),
069              new CheckCircularReferencesPass(),
070              new CheckReferenceValidityPass(),
071              new CheckArgumentsValidityPass(false),
072          ]];
073   
074          $this->beforeRemovingPasses = [
075              -100 => [
076                  new ResolvePrivatesPass(),
077              ],
078          ];
079   
080          $this->removingPasses = [[
081              new RemovePrivateAliasesPass(),
082              new ReplaceAliasByActualDefinitionPass(),
083              new RemoveAbstractDefinitionsPass(),
084              new RepeatedPass([
085                  new AnalyzeServiceReferencesPass(),
086                  new InlineServiceDefinitionsPass(),
087                  new AnalyzeServiceReferencesPass(),
088                  new RemoveUnusedDefinitionsPass(),
089              ]),
090              new DefinitionErrorExceptionPass(),
091              new CheckExceptionOnInvalidReferenceBehaviorPass(),
092              new ResolveHotPathPass(),
093          ]];
094      }
095   
096      /**
097       * Returns all passes in order to be processed.
098       *
099       * @return CompilerPassInterface[]
100       */
101      public function getPasses()
102      {
103          return array_merge(
104              [$this->mergePass],
105              $this->getBeforeOptimizationPasses(),
106              $this->getOptimizationPasses(),
107              $this->getBeforeRemovingPasses(),
108              $this->getRemovingPasses(),
109              $this->getAfterRemovingPasses()
110          );
111      }
112   
113      /**
114       * Adds a pass.
115       *
116       * @param CompilerPassInterface $pass A Compiler pass
117       * @param string                $type The pass type
118       *
119       * @throws InvalidArgumentException when a pass type doesn't exist
120       */
121      public function addPass(CompilerPassInterface $pass, $type = self::TYPE_BEFORE_OPTIMIZATION/*, int $priority = 0*/)
122      {
123          if (\func_num_args() >= 3) {
124              $priority = func_get_arg(2);
125          } else {
126              if (__CLASS__ !== static::class) {
127                  $r = new \ReflectionMethod($this, __FUNCTION__);
128                  if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
129                      @trigger_error(sprintf('Method %s() will have a third `int $priority = 0` argument in version 4.0. Not defining it is deprecated since Symfony 3.2.', __METHOD__), \E_USER_DEPRECATED);
130                  }
131              }
132   
133              $priority = 0;
134          }
135   
136          $property = $type.'Passes';
137          if (!isset($this->$property)) {
138              throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
139          }
140   
141          $passes = &$this->$property;
142   
143          if (!isset($passes[$priority])) {
144              $passes[$priority] = [];
145          }
146          $passes[$priority][] = $pass;
147      }
148   
149      /**
150       * Gets all passes for the AfterRemoving pass.
151       *
152       * @return CompilerPassInterface[]
153       */
154      public function getAfterRemovingPasses()
155      {
156          return $this->sortPasses($this->afterRemovingPasses);
157      }
158   
159      /**
160       * Gets all passes for the BeforeOptimization pass.
161       *
162       * @return CompilerPassInterface[]
163       */
164      public function getBeforeOptimizationPasses()
165      {
166          return $this->sortPasses($this->beforeOptimizationPasses);
167      }
168   
169      /**
170       * Gets all passes for the BeforeRemoving pass.
171       *
172       * @return CompilerPassInterface[]
173       */
174      public function getBeforeRemovingPasses()
175      {
176          return $this->sortPasses($this->beforeRemovingPasses);
177      }
178   
179      /**
180       * Gets all passes for the Optimization pass.
181       *
182       * @return CompilerPassInterface[]
183       */
184      public function getOptimizationPasses()
185      {
186          return $this->sortPasses($this->optimizationPasses);
187      }
188   
189      /**
190       * Gets all passes for the Removing pass.
191       *
192       * @return CompilerPassInterface[]
193       */
194      public function getRemovingPasses()
195      {
196          return $this->sortPasses($this->removingPasses);
197      }
198   
199      /**
200       * Gets the Merge pass.
201       *
202       * @return CompilerPassInterface
203       */
204      public function getMergePass()
205      {
206          return $this->mergePass;
207      }
208   
209      public function setMergePass(CompilerPassInterface $pass)
210      {
211          $this->mergePass = $pass;
212      }
213   
214      /**
215       * Sets the AfterRemoving passes.
216       *
217       * @param CompilerPassInterface[] $passes
218       */
219      public function setAfterRemovingPasses(array $passes)
220      {
221          $this->afterRemovingPasses = [$passes];
222      }
223   
224      /**
225       * Sets the BeforeOptimization passes.
226       *
227       * @param CompilerPassInterface[] $passes
228       */
229      public function setBeforeOptimizationPasses(array $passes)
230      {
231          $this->beforeOptimizationPasses = [$passes];
232      }
233   
234      /**
235       * Sets the BeforeRemoving passes.
236       *
237       * @param CompilerPassInterface[] $passes
238       */
239      public function setBeforeRemovingPasses(array $passes)
240      {
241          $this->beforeRemovingPasses = [$passes];
242      }
243   
244      /**
245       * Sets the Optimization passes.
246       *
247       * @param CompilerPassInterface[] $passes
248       */
249      public function setOptimizationPasses(array $passes)
250      {
251          $this->optimizationPasses = [$passes];
252      }
253   
254      /**
255       * Sets the Removing passes.
256       *
257       * @param CompilerPassInterface[] $passes
258       */
259      public function setRemovingPasses(array $passes)
260      {
261          $this->removingPasses = [$passes];
262      }
263   
264      /**
265       * Sort passes by priority.
266       *
267       * @param array $passes CompilerPassInterface instances with their priority as key
268       *
269       * @return CompilerPassInterface[]
270       */
271      private function sortPasses(array $passes)
272      {
273          if (0 === \count($passes)) {
274              return [];
275          }
276   
277          krsort($passes);
278   
279          // Flatten the array
280          return \call_user_func_array('array_merge', $passes);
281      }
282  }
283