Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
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 |
Constructor.php
01 <?php
02 /*
03 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
04 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
05 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
06 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
07 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
08 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
09 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14 *
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license.
17 */
18
19 namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator;
20
21 use ProxyManager\Exception\UnsupportedProxiedClassException;
22 use ProxyManager\Generator\MethodGenerator;
23 use ProxyManager\Generator\ParameterGenerator;
24 use ReflectionClass;
25 use Zend\Code\Generator\PropertyGenerator;
26
27 /**
28 * The `__construct` implementation for lazy loading proxies
29 *
30 * @author Marco Pivetta <ocramius@gmail.com>
31 * @license MIT
32 */
33 class Constructor extends MethodGenerator
34 {
35 /**
36 * Constructor
37 */
38 public function __construct(
39 ReflectionClass $originalClass,
40 PropertyGenerator $prefixInterceptors,
41 PropertyGenerator $suffixInterceptors
42 ) {
43 parent::__construct('__construct');
44
45 $localizedObject = new ParameterGenerator('localizedObject');
46 $prefix = new ParameterGenerator('prefixInterceptors');
47 $suffix = new ParameterGenerator('suffixInterceptors');
48
49 $localizedObject->setType($originalClass->getName());
50 $prefix->setDefaultValue(array());
51 $suffix->setDefaultValue(array());
52 $prefix->setType('array');
53 $suffix->setType('array');
54
55 $this->setParameter($localizedObject);
56 $this->setParameter($prefix);
57 $this->setParameter($suffix);
58
59 $localizedProperties = array();
60
61 foreach ($originalClass->getProperties() as $originalProperty) {
62 if ((! method_exists('Closure', 'bind')) && $originalProperty->isPrivate()) {
63 // @codeCoverageIgnoreStart
64 throw UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty($originalProperty);
65 // @codeCoverageIgnoreEnd
66 }
67
68 $propertyName = $originalProperty->getName();
69
70 if ($originalProperty->isPrivate()) {
71 $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n "
72 . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n"
73 . '}, $this, ' . var_export($originalProperty->getDeclaringClass()->getName(), true)
74 . ')->__invoke();';
75 } else {
76 $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";";
77 }
78 }
79
80 $this->setDocblock(
81 "@override constructor to setup interceptors\n\n"
82 . "@param \\" . $originalClass->getName() . " \$localizedObject\n"
83 . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n"
84 . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic"
85 );
86 $this->setBody(
87 (empty($localizedProperties) ? '' : implode("\n\n", $localizedProperties) . "\n\n")
88 . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n"
89 . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;"
90 );
91 }
92 }
93