[ Index ] |
PHP Cross Reference of phpBB-3.3.9-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 9 * 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 declare(strict_types=1); 20 21 namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator; 22 23 use ProxyManager\Generator\MethodGenerator; 24 use Zend\Code\Generator\ParameterGenerator; 25 use ProxyManager\ProxyGenerator\Util\Properties; 26 use ReflectionClass; 27 use Zend\Code\Generator\PropertyGenerator; 28 29 /** 30 * The `bindProxyProperties` method implementation for access interceptor scope localizers 31 * 32 * @author Marco Pivetta <ocramius@gmail.com> 33 * @license MIT 34 */ 35 class BindProxyProperties extends MethodGenerator 36 { 37 /** 38 * Constructor 39 * 40 * @param ReflectionClass $originalClass 41 * @param PropertyGenerator $prefixInterceptors 42 * @param PropertyGenerator $suffixInterceptors 43 */ 44 public function __construct( 45 ReflectionClass $originalClass, 46 PropertyGenerator $prefixInterceptors, 47 PropertyGenerator $suffixInterceptors 48 ) { 49 parent::__construct( 50 'bindProxyProperties', 51 [ 52 new ParameterGenerator('localizedObject', $originalClass->getName()), 53 new ParameterGenerator('prefixInterceptors', 'array', []), 54 new ParameterGenerator('suffixInterceptors', 'array', []), 55 ], 56 static::FLAG_PRIVATE, 57 null, 58 "@override constructor to setup interceptors\n\n" 59 . "@param \\" . $originalClass->getName() . " \$localizedObject\n" 60 . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" 61 . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic" 62 ); 63 64 $localizedProperties = []; 65 66 $properties = Properties::fromReflectionClass($originalClass); 67 68 foreach ($properties->getAccessibleProperties() as $property) { 69 $propertyName = $property->getName(); 70 71 $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ';'; 72 } 73 74 foreach ($properties->getPrivateProperties() as $property) { 75 $propertyName = $property->getName(); 76 77 $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n " 78 . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n" 79 . '}, $this, ' . var_export($property->getDeclaringClass()->getName(), true) 80 . ')->__invoke();'; 81 } 82 83 $this->setBody( 84 ($localizedProperties ? implode("\n\n", $localizedProperties) . "\n\n" : '') 85 . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" 86 . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;" 87 ); 88 } 89 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 7 15:09:22 2022 | Cross-referenced by PHPXref 0.7.1 |