[ Index ] |
PHP Cross Reference of phpBB-3.2.11-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 namespace ProxyManager\ProxyGenerator; 20 21 use ProxyManager\Generator\Util\ClassGeneratorUtils; 22 use ProxyManager\ProxyGenerator\Assertion\CanProxyAssertion; 23 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\Constructor; 24 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicGet; 25 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicIsset; 26 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicSet; 27 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\MagicUnset; 28 use ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator\RemoteObjectMethod; 29 use ProxyManager\ProxyGenerator\RemoteObject\PropertyGenerator\AdapterProperty; 30 use ProxyManager\ProxyGenerator\Util\ProxiedMethodsFilter; 31 use ReflectionClass; 32 use ReflectionMethod; 33 use Zend\Code\Generator\ClassGenerator; 34 use Zend\Code\Generator\MethodGenerator; 35 use Zend\Code\Reflection\MethodReflection; 36 37 /** 38 * Generator for proxies implementing {@see \ProxyManager\Proxy\RemoteObjectInterface} 39 * 40 * {@inheritDoc} 41 * 42 * @author Vincent Blanchon <blanchon.vincent@gmail.com> 43 * @license MIT 44 */ 45 class RemoteObjectGenerator implements ProxyGeneratorInterface 46 { 47 /** 48 * {@inheritDoc} 49 */ 50 public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator) 51 { 52 CanProxyAssertion::assertClassCanBeProxied($originalClass); 53 54 $interfaces = array('ProxyManager\\Proxy\\RemoteObjectInterface'); 55 56 if ($originalClass->isInterface()) { 57 $interfaces[] = $originalClass->getName(); 58 } else { 59 $classGenerator->setExtendedClass($originalClass->getName()); 60 } 61 62 $classGenerator->setImplementedInterfaces($interfaces); 63 $classGenerator->addPropertyFromGenerator($adapter = new AdapterProperty()); 64 65 array_map( 66 function (MethodGenerator $generatedMethod) use ($originalClass, $classGenerator) { 67 ClassGeneratorUtils::addMethodIfNotFinal($originalClass, $classGenerator, $generatedMethod); 68 }, 69 array_merge( 70 array_map( 71 function (ReflectionMethod $method) use ($adapter, $originalClass) { 72 return RemoteObjectMethod::generateMethod( 73 new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()), 74 $adapter, 75 $originalClass 76 ); 77 }, 78 ProxiedMethodsFilter::getProxiedMethods( 79 $originalClass, 80 array('__get', '__set', '__isset', '__unset') 81 ) 82 ), 83 array( 84 new Constructor($originalClass, $adapter), 85 new MagicGet($originalClass, $adapter), 86 new MagicSet($originalClass, $adapter), 87 new MagicIsset($originalClass, $adapter), 88 new MagicUnset($originalClass, $adapter), 89 ) 90 ) 91 ); 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |