当前位置: 首页>>代码示例>>PHP>>正文


PHP Generator\PropertyGenerator类代码示例

本文整理汇总了PHP中Zend\Code\Generator\PropertyGenerator的典型用法代码示例。如果您正苦于以下问题:PHP PropertyGenerator类的具体用法?PHP PropertyGenerator怎么用?PHP PropertyGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PropertyGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Static constructor
  *
  * @param PropertyGenerator $initializerProperty
  * @param Properties        $properties
  */
 public function __construct(PropertyGenerator $initializerProperty, Properties $properties)
 {
     parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC);
     $this->setParameter(new ParameterGenerator('initializer'));
     $this->setDocblock("Constructor for lazy initialization\n\n@param \\Closure|null \$initializer");
     $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = (new \\ReflectionClass(get_class()))->newInstanceWithoutConstructor();' . "\n\n" . $this->generateUnsetPropertiesCode($properties) . '$instance->' . $initializerProperty->getName() . ' = $initializer;' . "\n\n" . 'return $instance;');
 }
开发者ID:andywooyay,项目名称:ProxyManager,代码行数:13,代码来源:StaticProxyConstructor.php

示例2: __construct

 /**
  * Constructor
  *
  * @param PropertyGenerator   $initializerProperty
  * @param ZendMethodGenerator $callInitializer
  */
 public function __construct(PropertyGenerator $initializerProperty, ZendMethodGenerator $callInitializer)
 {
     parent::__construct('initializeProxy');
     $this->setDocblock('{@inheritDoc}');
     $this->setReturnType('bool');
     $this->setBody('return $this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(\'initializeProxy\', []);');
 }
开发者ID:jbafford,项目名称:ProxyManager,代码行数:13,代码来源:InitializeProxy.php

示例3: __construct

    /**
     * Constructor
     *
     * @param PropertyGenerator $initializerProperty
     * @param PropertyGenerator $initTracker
     * @param Properties        $properties
     */
    public function __construct(PropertyGenerator $initializerProperty, PropertyGenerator $initTracker, Properties $properties)
    {
        $docblock = <<<'DOCBLOCK'
Triggers initialization logic for this ghost object

@param string  $methodName
@param mixed[] $parameters

@return mixed
DOCBLOCK;
        parent::__construct(UniqueIdentifierGenerator::getIdentifier('callInitializer'), [new ParameterGenerator('methodName'), new ParameterGenerator('parameters', 'array')], static::VISIBILITY_PRIVATE, null, $docblock);
        $initializer = $initializerProperty->getName();
        $initialization = $initTracker->getName();
        $bodyTemplate = <<<'PHP'
if ($this->%s || ! $this->%s) {
    return;
}

$this->%s = true;

%s
%s

$result = $this->%s->__invoke($this, $methodName, $parameters, $this->%s, $properties);
$this->%s = false;

return $result;
PHP;
        $this->setBody(sprintf($bodyTemplate, $initialization, $initializer, $initialization, $this->propertiesInitializationCode($properties), $this->propertiesReferenceArrayCode($properties), $initializer, $initializer, $initialization));
    }
开发者ID:FanHa,项目名称:ProxyManager,代码行数:37,代码来源:CallInitializer.php

示例4: __construct

 /**
  * Constructor
  *
  * @param ReflectionClass   $originalClass
  * @param PropertyGenerator $initializerProperty
  * @param PropertyGenerator $valueHolderProperty
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty)
 {
     parent::__construct($originalClass, '__sleep');
     $initializer = $initializerProperty->getName();
     $valueHolder = $valueHolderProperty->getName();
     $this->setBody('$this->' . $initializer . ' && $this->' . $initializer . '->__invoke($this->' . $valueHolder . ', $this, \'__sleep\', array(), $this->' . $initializer . ');' . "\n\n" . 'return array(' . var_export($valueHolder, true) . ');');
 }
开发者ID:FanHa,项目名称:ProxyManager,代码行数:14,代码来源:MagicSleep.php

示例5: __construct

 /**
  * Constructor
  *
  * @param ReflectionClass   $originalClass
  * @param PropertyGenerator $initializerProperty
  * @param PropertyGenerator $valueHolderProperty
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty)
 {
     parent::__construct($originalClass, '__clone');
     $initializer = $initializerProperty->getName();
     $valueHolder = $valueHolderProperty->getName();
     $this->setBody('$this->' . $initializer . ' && $this->' . $initializer . '->__invoke($this->' . $valueHolder . ', $this, \'__clone\', array(), $this->' . $initializer . ');' . "\n\n" . '$this->' . $valueHolder . ' = clone $this->' . $valueHolder . ';');
 }
开发者ID:FanHa,项目名称:ProxyManager,代码行数:14,代码来源:MagicClone.php

示例6: __construct

 /**
  * Constructor
  */
 public function __construct(PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty)
 {
     parent::__construct('initializeProxy');
     $this->setDocblock('{@inheritDoc}');
     $initializer = $initializerProperty->getName();
     $this->setBody('return $this->' . $initializer . ' && $this->' . $initializer . '->__invoke($this->' . $valueHolderProperty->getName() . ', $this, \'initializeProxy\', array(), $this->' . $initializer . ');');
 }
开发者ID:John-Eddy,项目名称:ProjetCastor,代码行数:10,代码来源:InitializeProxy.php

示例7: __construct

 /**
  * Constructor
  *
  * @param PropertyGenerator $valueHolderProperty
  */
 public function __construct(PropertyGenerator $valueHolderProperty)
 {
     parent::__construct('isProxyInitialized');
     $this->setDocblock('{@inheritDoc}');
     $this->setReturnType('bool');
     $this->setBody('return null !== $this->' . $valueHolderProperty->getName() . ';');
 }
开发者ID:jbafford,项目名称:ProxyManager,代码行数:12,代码来源:IsProxyInitialized.php

示例8: __construct

 /**
  * Constructor
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors)
 {
     parent::__construct('__construct');
     $localizedObject = new ParameterGenerator('localizedObject');
     $prefix = new ParameterGenerator('prefixInterceptors');
     $suffix = new ParameterGenerator('suffixInterceptors');
     $localizedObject->setType($originalClass->getName());
     $prefix->setDefaultValue(array());
     $suffix->setDefaultValue(array());
     $prefix->setType('array');
     $suffix->setType('array');
     $this->setParameter($localizedObject);
     $this->setParameter($prefix);
     $this->setParameter($suffix);
     $localizedProperties = array();
     foreach ($originalClass->getProperties() as $originalProperty) {
         if (!method_exists('Closure', 'bind') && $originalProperty->isPrivate()) {
             // @codeCoverageIgnoreStart
             throw UnsupportedProxiedClassException::unsupportedLocalizedReflectionProperty($originalProperty);
             // @codeCoverageIgnoreEnd
         }
         $propertyName = $originalProperty->getName();
         if ($originalProperty->isPrivate()) {
             $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n    " . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n" . '}, $this, ' . var_export($originalProperty->getDeclaringClass()->getName(), true) . ')->__invoke();';
         } else {
             $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";";
         }
     }
     $this->setDocblock("@override constructor to setup interceptors\n\n" . "@param \\" . $originalClass->getName() . " \$localizedObject\n" . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic");
     $this->setBody((empty($localizedProperties) ? '' : implode("\n\n", $localizedProperties) . "\n\n") . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;");
 }
开发者ID:John-Eddy,项目名称:ProjetCastor,代码行数:34,代码来源:Constructor.php

示例9: __construct

 /**
  * Constructor
  *
  * @param ReflectionClass   $originalClass Reflection of the class to proxy
  * @param PropertyGenerator $adapter       Adapter property
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapter)
 {
     $adapterName = $adapter->getName();
     parent::__construct('staticProxyConstructor', [new ParameterGenerator($adapterName, AdapterInterface::class)], MethodGenerator::FLAG_PUBLIC | MethodGenerator::FLAG_STATIC, null, 'Constructor for remote object control\\n\\n' . '@param \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface \\$adapter');
     $body = 'static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = (new \\ReflectionClass(get_class()))->newInstanceWithoutConstructor();' . "\n\n" . '$instance->' . $adapterName . ' = $' . $adapterName . ";\n\n" . UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'instance');
     $this->setBody($body . "\n\nreturn \$instance;");
 }
开发者ID:jbafford,项目名称:ProxyManager,代码行数:13,代码来源:StaticProxyConstructor.php

示例10: getProperty

 /**
  * @param  string            $name
  * @param  string            $type
  * @return PropertyGenerator
  */
 protected function getProperty($name, $type)
 {
     $property = new PropertyGenerator($name, null, PropertyGenerator::FLAG_PROTECTED);
     $property->setDocBlock(new DocBlockGenerator());
     $property->getDocBlock()->setTag(new Tag\GenericTag('var', $type));
     return $property;
 }
开发者ID:enlitepro,项目名称:zf2-scaffold,代码行数:12,代码来源:AbstractBuilder.php

示例11: __construct

 /**
  * Creates a new {@link \bitExpert\Disco\Proxy\MethodGenerator\MagicWakeup}.
  *
  * @param ReflectionClass $originalClass
  * @param PropertyGenerator $valueHolderProperty
  * @param PropertyGenerator $valueHolderBeanIdProperty
  * @throws InvalidArgumentException
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolderProperty, PropertyGenerator $valueHolderBeanIdProperty)
 {
     parent::__construct($originalClass, '__wakeup');
     $valueHolder = $valueHolderProperty->getName();
     $valueHolderBeanId = $valueHolderBeanIdProperty->getName();
     $this->setBody('$beanFactory = \\' . BeanFactoryRegistry::class . '::getInstance();' . PHP_EOL . PHP_EOL . '$this->' . $valueHolder . ' = $beanFactory->get($this->' . $valueHolderBeanId . ');' . PHP_EOL . 'if ($this->' . $valueHolder . ' instanceof \\' . VirtualProxyInterface::class . ') {' . PHP_EOL . '    $this->' . $valueHolder . ' = $this->' . $valueHolder . '->getWrappedValueHolderValue();' . PHP_EOL . '}' . PHP_EOL);
 }
开发者ID:bitexpert,项目名称:disco,代码行数:15,代码来源:MagicWakeup.php

示例12: __construct

 /**
  * Constructor
  */
 public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolderProperty, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors)
 {
     parent::__construct($originalClass, '__clone');
     $valueHolder = $valueHolderProperty->getName();
     $prefix = $prefixInterceptors->getName();
     $suffix = $suffixInterceptors->getName();
     $this->setBody("\$this->{$valueHolder} = clone \$this->{$valueHolder};\n\n" . "foreach (\$this->{$prefix} as \$key => \$value) {\n" . "    \$this->{$prefix}" . "[\$key] = clone \$value;\n" . "}\n\n" . "foreach (\$this->{$suffix} as \$key => \$value) {\n" . "    \$this->{$suffix}" . "[\$key] = clone \$value;\n" . "}");
 }
开发者ID:tillk,项目名称:vufind,代码行数:11,代码来源:MagicClone.php

示例13: __construct

 /**
  * Constructor
  */
 public function __construct(PropertyGenerator $initializerProperty)
 {
     parent::__construct('setProxyInitializer');
     $initializerParameter = new ParameterGenerator('initializer');
     $initializerParameter->setType('Closure');
     $initializerParameter->setDefaultValue(null);
     $this->setParameter($initializerParameter);
     $this->setDocblock('{@inheritDoc}');
     $this->setBody('$this->' . $initializerProperty->getName() . ' = $initializer;');
 }
开发者ID:John-Eddy,项目名称:ProjetCastor,代码行数:13,代码来源:SetProxyInitializer.php

示例14: __construct

 /**
  * Constructor
  */
 public function __construct(PropertyGenerator $initializerProperty, PropertyGenerator $publicPropertiesDefaults, PropertyGenerator $initializationTracker)
 {
     parent::__construct(UniqueIdentifierGenerator::getIdentifier('callInitializer'));
     $this->setDocblock("Triggers initialization logic for this ghost object");
     $this->setParameters(array(new ParameterGenerator('methodName'), new ParameterGenerator('parameters', 'array')));
     $this->setVisibility(static::VISIBILITY_PRIVATE);
     $initializer = $initializerProperty->getName();
     $initialization = $initializationTracker->getName();
     $this->setBody('if ($this->' . $initialization . ' || ! $this->' . $initializer . ') {' . "\n    return;\n}\n\n" . "\$this->" . $initialization . " = true;\n\n" . "foreach (self::\$" . $publicPropertiesDefaults->getName() . " as \$key => \$default) {\n" . "    \$this->\$key = \$default;\n" . "}\n\n" . '$this->' . $initializer . '->__invoke' . '($this, $methodName, $parameters, $this->' . $initializer . ');' . "\n\n" . "\$this->" . $initialization . " = false;");
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:13,代码来源:CallInitializer.php

示例15: generateMethod

 /**
  * Constructor
  *
  * @param ReflectionClass   $originalClass
  * @param PropertyGenerator $valueHolder
  *
  * @return MethodGenerator
  */
 public static function generateMethod(ReflectionClass $originalClass, PropertyGenerator $valueHolder)
 {
     $originalConstructor = self::getConstructor($originalClass);
     $constructor = $originalConstructor ? self::fromReflection($originalConstructor) : new self('__construct');
     $constructor->setDocblock('{@inheritDoc}');
     $constructor->setBody('static $reflection;' . "\n\n" . 'if (! $this->' . $valueHolder->getName() . ') {' . "\n" . '    $reflection = $reflection ?: new \\ReflectionClass(' . var_export($originalClass->getName(), true) . ");\n" . '    $this->' . $valueHolder->getName() . ' = $reflection->newInstanceWithoutConstructor();' . "\n" . self::getUnsetPropertiesString($originalClass) . "}\n\n" . '$this->' . $valueHolder->getName() . '->' . $constructor->getName() . '(' . implode(', ', array_map(function (ParameterGenerator $parameter) {
         return ($parameter->getVariadic() ? '...' : '') . '$' . $parameter->getName();
     }, $constructor->getParameters())) . ');');
     return $constructor;
 }
开发者ID:andywooyay,项目名称:ProxyManager,代码行数:18,代码来源:Constructor.php


注:本文中的Zend\Code\Generator\PropertyGenerator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。