/usr/share/php/ProxyManager/ProxyGenerator/LazyLoadingValueHolderGenerator.php is in php-proxy-manager 0.3.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | <?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license.
*/
namespace ProxyManager\ProxyGenerator;
use ProxyManager\ProxyGenerator\ValueHolder\MethodGenerator\GetWrappedValueHolderValue;
use ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator\MagicWakeup;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\Constructor;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\GetProxyInitializer;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\IsProxyInitialized;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\LazyLoadingMethodInterceptor;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicClone;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicGet;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicIsset;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSet;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicSleep;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\MagicUnset;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\SetProxyInitializer;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\InitializerProperty;
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\PropertyGenerator\ValueHolderProperty;
use ReflectionClass;
use ReflectionMethod;
use Zend\Code\Generator\ClassGenerator;
use Zend\Code\Reflection\MethodReflection;
/**
* Generator for proxies implementing {@see \ProxyManager\Proxy\ValueHolderInterface}
* and {@see \ProxyManager\Proxy\LazyLoadingInterface}
*
* {@inheritDoc}
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*/
class LazyLoadingValueHolderGenerator implements ProxyGeneratorInterface
{
/**
* {@inheritDoc}
*/
public function generate(ReflectionClass $originalClass, ClassGenerator $classGenerator)
{
$interfaces = array(
'ProxyManager\\Proxy\\LazyLoadingInterface',
'ProxyManager\\Proxy\\ValueHolderInterface',
);
if ($originalClass->isInterface()) {
$interfaces[] = $originalClass->getName();
} else {
$classGenerator->setExtendedClass($originalClass->getName());
}
$classGenerator->setImplementedInterfaces($interfaces);
$classGenerator->addPropertyFromGenerator($valueHolder = new ValueHolderProperty());
$classGenerator->addPropertyFromGenerator($initializer = new InitializerProperty());
$excluded = array(
'__get' => true,
'__set' => true,
'__isset' => true,
'__unset' => true,
'__clone' => true,
'__sleep' => true,
'__wakeup' => true,
);
/* @var $methods \ReflectionMethod[] */
$methods = array_filter(
$originalClass->getMethods(ReflectionMethod::IS_PUBLIC),
function (ReflectionMethod $method) use ($excluded) {
return ! (
$method->isConstructor()
|| isset($excluded[strtolower($method->getName())])
|| $method->isFinal()
|| $method->isStatic()
);
}
);
foreach ($methods as $method) {
$classGenerator->addMethodFromGenerator(
LazyLoadingMethodInterceptor::generateMethod(
new MethodReflection($method->getDeclaringClass()->getName(), $method->getName()),
$initializer,
$valueHolder
)
);
}
$classGenerator->addMethodFromGenerator(new Constructor($originalClass, $initializer));
$classGenerator->addMethodFromGenerator(new MagicGet($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicSet($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicIsset($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicUnset($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicClone($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicSleep($originalClass, $initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new MagicWakeup($originalClass));
$classGenerator->addMethodFromGenerator(new SetProxyInitializer($initializer));
$classGenerator->addMethodFromGenerator(new GetProxyInitializer($initializer));
$classGenerator->addMethodFromGenerator(new InitializeProxy($initializer, $valueHolder));
$classGenerator->addMethodFromGenerator(new IsProxyInitialized($valueHolder));
$classGenerator->addMethodFromGenerator(new GetWrappedValueHolderValue($valueHolder));
}
}
|