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 |
MagicGet.php
01 <?php
02
03 declare(strict_types=1);
04
05 namespace ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator;
06
07 use ProxyManager\Generator\MagicMethodGenerator;
08 use ProxyManager\ProxyGenerator\Util\GetMethodIfExists;
09 use Zend\Code\Generator\ParameterGenerator;
10 use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\Util\InterceptorGenerator;
11 use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap;
12 use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator;
13 use ReflectionClass;
14 use Zend\Code\Generator\PropertyGenerator;
15
16 /**
17 * Magic `__get` for method interceptor value holder objects
18 *
19 * @author Marco Pivetta <ocramius@gmail.com>
20 * @license MIT
21 */
22 class MagicGet extends MagicMethodGenerator
23 {
24 /**
25 * Constructor
26 *
27 * @param ReflectionClass $originalClass
28 * @param PropertyGenerator $valueHolder
29 * @param PropertyGenerator $prefixInterceptors
30 * @param PropertyGenerator $suffixInterceptors
31 * @param PublicPropertiesMap $publicProperties
32 *
33 * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
34 * @throws \InvalidArgumentException
35 */
36 public function __construct(
37 ReflectionClass $originalClass,
38 PropertyGenerator $valueHolder,
39 PropertyGenerator $prefixInterceptors,
40 PropertyGenerator $suffixInterceptors,
41 PublicPropertiesMap $publicProperties
42 ) {
43 parent::__construct($originalClass, '__get', [new ParameterGenerator('name')]);
44
45 $parent = GetMethodIfExists::get($originalClass, '__get');
46 $valueHolderName = $valueHolder->getName();
47
48 $callParent = PublicScopeSimulator::getPublicAccessSimulationCode(
49 PublicScopeSimulator::OPERATION_GET,
50 'name',
51 'value',
52 $valueHolder,
53 'returnValue'
54 );
55
56 if (! $publicProperties->isEmpty()) {
57 $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n"
58 . ' $returnValue = & $this->' . $valueHolderName . '->$name;'
59 . "\n} else {\n $callParent\n}\n\n";
60 }
61
62 $this->setBody(InterceptorGenerator::createInterceptedMethodBody(
63 $callParent,
64 $this,
65 $valueHolder,
66 $prefixInterceptors,
67 $suffixInterceptors,
68 $parent
69 ));
70 }
71 }
72