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

MagicUnset.php

Zuletzt modifiziert: 02.04.2025, 15:04 - Dateigröße: 2.40 KiB


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 `__unset` for method interceptor value holder objects
18   *
19   * @author Marco Pivetta <ocramius@gmail.com>
20   * @license MIT
21   */
22  class MagicUnset extends MagicMethodGenerator
23  {
24      /**
25       * Constructor
26       * @param ReflectionClass     $originalClass
27       * @param PropertyGenerator   $valueHolder
28       * @param PropertyGenerator   $prefixInterceptors
29       * @param PropertyGenerator   $suffixInterceptors
30       * @param PublicPropertiesMap $publicProperties
31       *
32       * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
33       * @throws \InvalidArgumentException
34       */
35      public function __construct(
36          ReflectionClass $originalClass,
37          PropertyGenerator $valueHolder,
38          PropertyGenerator $prefixInterceptors,
39          PropertyGenerator $suffixInterceptors,
40          PublicPropertiesMap $publicProperties
41      ) {
42          parent::__construct($originalClass, '__unset', [new ParameterGenerator('name')]);
43   
44          $parent          = GetMethodIfExists::get($originalClass, '__unset');
45          $valueHolderName = $valueHolder->getName();
46   
47          $callParent = PublicScopeSimulator::getPublicAccessSimulationCode(
48              PublicScopeSimulator::OPERATION_UNSET,
49              'name',
50              'value',
51              $valueHolder,
52              'returnValue'
53          );
54   
55          if (! $publicProperties->isEmpty()) {
56              $callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n"
57                  . '    unset($this->' . $valueHolderName . '->$name);'
58                  . "\n} else {\n    $callParent\n}\n\n";
59          }
60   
61          $callParent .= '$returnValue = false;';
62   
63          $this->setBody(InterceptorGenerator::createInterceptedMethodBody(
64              $callParent,
65              $this,
66              $valueHolder,
67              $prefixInterceptors,
68              $suffixInterceptors,
69              $parent
70          ));
71      }
72  }
73