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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
StaticProxyConstructor.php
01 <?php
02
03 declare(strict_types=1);
04
05 namespace ProxyManager\ProxyGenerator\NullObject\MethodGenerator;
06
07 use ProxyManager\Generator\MethodGenerator;
08 use ProxyManager\ProxyGenerator\Util\Properties;
09 use ReflectionClass;
10 use ReflectionProperty;
11
12 /**
13 * The `staticProxyConstructor` implementation for null object proxies
14 *
15 * @author Marco Pivetta <ocramius@gmail.com>
16 * @license MIT
17 */
18 class StaticProxyConstructor extends MethodGenerator
19 {
20 /**
21 * Constructor
22 *
23 * @param ReflectionClass $originalClass Reflection of the class to proxy
24 *
25 * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
26 */
27 public function __construct(ReflectionClass $originalClass)
28 {
29 parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC);
30
31 $nullableProperties = array_map(
32 function (ReflectionProperty $publicProperty) : string {
33 return '$instance->' . $publicProperty->getName() . ' = null;';
34 },
35 Properties::fromReflectionClass($originalClass)->getPublicProperties()
36 );
37
38 $this->setDocBlock('Constructor for null object initialization');
39 $this->setBody(
40 'static $reflection;' . "\n\n"
41 . '$reflection = $reflection ?? $reflection = new \ReflectionClass(__CLASS__);' . "\n"
42 . '$instance = $reflection->newInstanceWithoutConstructor();' . "\n\n"
43 . ($nullableProperties ? implode("\n", $nullableProperties) . "\n\n" : '')
44 . 'return $instance;'
45 );
46 }
47 }
48