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

AutowireRequiredMethodsPass.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 2.22 KiB


01  <?php
02   
03  /*
04   * This file is part of the Symfony package.
05   *
06   * (c) Fabien Potencier <fabien@symfony.com>
07   *
08   * For the full copyright and license information, please view the LICENSE
09   * file that was distributed with this source code.
10   */
11   
12  namespace Symfony\Component\DependencyInjection\Compiler;
13   
14  use Symfony\Component\DependencyInjection\Definition;
15   
16  /**
17   * Looks for definitions with autowiring enabled and registers their corresponding "@required" methods as setters.
18   *
19   * @author Nicolas Grekas <p@tchwork.com>
20   */
21  class AutowireRequiredMethodsPass extends AbstractRecursivePass
22  {
23      /**
24       * {@inheritdoc}
25       */
26      protected function processValue($value, $isRoot = false)
27      {
28          $value = parent::processValue($value, $isRoot);
29   
30          if (!$value instanceof Definition || !$value->isAutowired() || $value->isAbstract() || !$value->getClass()) {
31              return $value;
32          }
33          if (!$reflectionClass = $this->container->getReflectionClass($value->getClass(), false)) {
34              return $value;
35          }
36   
37          $alreadyCalledMethods = [];
38   
39          foreach ($value->getMethodCalls() as list($method)) {
40              $alreadyCalledMethods[strtolower($method)] = true;
41          }
42   
43          foreach ($reflectionClass->getMethods() as $reflectionMethod) {
44              $r = $reflectionMethod;
45   
46              if ($r->isConstructor() || isset($alreadyCalledMethods[strtolower($r->name)])) {
47                  continue;
48              }
49   
50              while (true) {
51                  if (false !== $doc = $r->getDocComment()) {
52                      if (false !== stripos($doc, '@required') && preg_match('#(?:^/\*\*|\n\s*+\*)\s*+@required(?:\s|\*/$)#i', $doc)) {
53                          $value->addMethodCall($reflectionMethod->name);
54                          break;
55                      }
56                      if (false === stripos($doc, '@inheritdoc') || !preg_match('#(?:^/\*\*|\n\s*+\*)\s*+(?:\{@inheritdoc\}|@inheritdoc)(?:\s|\*/$)#i', $doc)) {
57                          break;
58                      }
59                  }
60                  try {
61                      $r = $r->getPrototype();
62                  } catch (\ReflectionException $e) {
63                      break; // method has no prototype
64                  }
65              }
66          }
67   
68          return $value;
69      }
70  }
71