/** * 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)); }
/** * 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 . ');'); }
/** * 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\', []);'); }
public function __construct() { parent::__construct('setIndexOriginalValue'); $this->setParameter(new ParameterGenerator('name', 'string')); $this->setParameter(new ParameterGenerator('value', 'string')); $this->setBody('$this->_original_indices[$name] = $value; return $this;'); }
/** * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetParameter}. * * @param ReflectionClass $originalClass * @param ParameterValuesProperty $parameterValueProperty * @throws InvalidArgumentException */ public function __construct(ReflectionClass $originalClass, ParameterValuesProperty $parameterValueProperty) { parent::__construct('getParameter'); $propertyNameParameter = new ParameterGenerator('propertyName'); $requiredParameter = new ParameterGenerator('required'); $requiredParameter->setDefaultValue(true); $defaultValueParameter = new ParameterGenerator('defaultValue'); $defaultValueParameter->setDefaultValue(null); $body = '$steps = explode(\'.\', $' . $propertyNameParameter->getName() . ');' . PHP_EOL; $body .= '$value = $this->' . $parameterValueProperty->getName() . ';' . PHP_EOL; $body .= '$currentPath = [];' . PHP_EOL; $body .= 'foreach ($steps as $step) {' . PHP_EOL; $body .= ' $currentPath[] = $step;' . PHP_EOL; $body .= ' if (isset($value[$step])) {' . PHP_EOL; $body .= ' $value = $value[$step];' . PHP_EOL; $body .= ' } else {' . PHP_EOL; $body .= ' $value = $' . $defaultValueParameter->getName() . ';' . PHP_EOL; $body .= ' break;' . PHP_EOL; $body .= ' }' . PHP_EOL; $body .= '}' . PHP_EOL . PHP_EOL; $body .= 'if ($' . $requiredParameter->getName() . ' && (null === $value)) {' . PHP_EOL; $body .= ' if (null === $' . $defaultValueParameter->getName() . ') {' . PHP_EOL; $body .= ' throw new \\RuntimeException(\'Parameter "\' .$' . $propertyNameParameter->getName() . '. \'" is required but not defined and no default value provided!\');' . PHP_EOL; $body .= ' }' . PHP_EOL; $body .= ' throw new \\RuntimeException(\'Parameter "\' .$' . $propertyNameParameter->getName() . '. \'" not defined!\');' . PHP_EOL; $body .= '}' . PHP_EOL . PHP_EOL; $body .= 'return $value;' . PHP_EOL; $this->setParameter($propertyNameParameter); $this->setParameter($requiredParameter); $this->setParameter($defaultValueParameter); $this->setVisibility(self::VISIBILITY_PROTECTED); $this->setBody($body); }
/** * 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() . ';'); }
/** * 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;"); }
/** * 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;"); }
/** * 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;'); }
/** * @param ReflectionClass $originalClass * @param string $name * @param array $parameters */ public function __construct(ReflectionClass $originalClass, $name, array $parameters = array()) { parent::__construct($name, $parameters, static::FLAG_PUBLIC, null, $originalClass->hasMethod($name) ? '{@inheritDoc}' : null); $this->setReturnsReference(strtolower($name) === '__get'); if ($originalClass->hasMethod($name)) { $this->setReturnsReference($originalClass->getMethod($name)->returnsReference()); } }
/** * Constructor * * @param ReflectionClass $originalClass Reflection of the class to proxy */ public function __construct(ReflectionClass $originalClass) { parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC); $nullableProperties = array_map(function (ReflectionProperty $publicProperty) { return '$instance->' . $publicProperty->getName() . ' = null;'; }, Properties::fromReflectionClass($originalClass)->getPublicProperties()); $this->setDocblock("Constructor for null object initialization"); $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = (new \\ReflectionClass(get_class()))->newInstanceWithoutConstructor();' . "\n\n" . ($nullableProperties ? implode("\n", $nullableProperties) . "\n\n" : '') . 'return $instance;'); }
/** * 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;"); }
/** * 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;'); }
/** * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\HasAlias}. * * @param ReflectionClass $originalClass * @param AliasesProperty $aliasesProperty * @throws InvalidArgumentException */ public function __construct(ReflectionClass $originalClass, AliasesProperty $aliasesProperty) { parent::__construct('hasAlias'); $aliasParameter = new ParameterGenerator('alias'); $aliasParameter->setType('string'); $this->setParameter($aliasParameter); $this->setVisibility(self::VISIBILITY_PUBLIC); $this->setReturnType('bool'); $this->setBody('return !empty($' . $aliasParameter->getName() . ') && ' . 'isset($this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . ']);'); }
/** * Constructor * * @param PropertyGenerator $suffixInterceptor */ public function __construct(PropertyGenerator $suffixInterceptor) { parent::__construct('setMethodSuffixInterceptor'); $interceptor = new ParameterGenerator('suffixInterceptor'); $interceptor->setType(Closure::class); $interceptor->setDefaultValue(null); $this->setParameter(new ParameterGenerator('methodName', 'string')); $this->setParameter($interceptor); $this->setDocblock('{@inheritDoc}'); $this->setBody('$this->' . $suffixInterceptor->getName() . '[$methodName] = $suffixInterceptor;'); }
/** * Constructor */ public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty) { parent::__construct('__construct'); $this->setParameter(new ParameterGenerator('initializer')); /* @var $publicProperties \ReflectionProperty[] */ $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); $unsetProperties = array(); foreach ($publicProperties as $publicProperty) { $unsetProperties[] = '$this->' . $publicProperty->getName(); } $this->setDocblock("@override constructor for lazy initialization\n\n@param \\Closure|null \$initializer"); $this->setBody(($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') . '$this->' . $initializerProperty->getName() . ' = $initializer;'); }
/** * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\GetAlias}. * * @param ReflectionClass $originalClass * @param AliasesProperty $aliasesProperty * @throws InvalidArgumentException */ public function __construct(ReflectionClass $originalClass, AliasesProperty $aliasesProperty) { parent::__construct('getAlias'); $aliasParameter = new ParameterGenerator('alias'); $aliasParameter->setType('string'); $body = 'if ($this->hasAlias($' . $aliasParameter->getName() . ')) {' . PHP_EOL; $body .= ' $methodname = $this->' . $aliasesProperty->getName() . '[$' . $aliasParameter->getName() . '];' . PHP_EOL; $body .= ' return $this->$methodname();' . PHP_EOL; $body .= '}' . PHP_EOL . PHP_EOL; $body .= 'throw new ' . BeanNotFoundException::class . '(sprintf(\'Alias "%s" is not defined!\', $' . $aliasParameter->getName() . '));' . PHP_EOL; $this->setParameter($aliasParameter); $this->setVisibility(self::VISIBILITY_PUBLIC); $this->setBody($body); }
/** * Constructor * * @param ReflectionClass $originalClass Reflection of the class to proxy */ public function __construct(ReflectionClass $originalClass) { parent::__construct('__construct'); /* @var $publicProperties \ReflectionProperty[] */ $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); $nullableProperties = array(); foreach ($publicProperties as $publicProperty) { $nullableProperties[] = '$this->' . $publicProperty->getName() . ' = null;'; } $this->setDocblock("@override constructor for null object initialization"); if ($nullableProperties) { $this->setBody(implode("\n", $nullableProperties)); } }
/** * Constructor * * @param ReflectionClass $originalClass Reflection of the class to proxy * @param PropertyGenerator $adapter Adapter property */ public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapter) { parent::__construct('__construct'); $adapterName = $adapter->getName(); $this->setParameter(new ParameterGenerator($adapterName, 'ProxyManager\\Factory\\RemoteObject\\AdapterInterface')); $this->setDocblock('@override constructor for remote object control\\n\\n' . '@param \\ProxyManager\\Factory\\RemoteObject\\AdapterInterface \\$adapter'); $body = '$this->' . $adapterName . ' = $' . $adapterName . ';'; foreach ($originalClass->getProperties() as $property) { if ($property->isPublic() && !$property->isStatic()) { $body .= "\nunset(\$this->" . $property->getName() . ');'; } } $this->setBody($body); }
/** * Constructor * * @param ReflectionClass $originalClass * @param PropertyGenerator $prefixInterceptors * @param PropertyGenerator $suffixInterceptors */ public function __construct(ReflectionClass $originalClass, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors) { parent::__construct('bindProxyProperties', [new ParameterGenerator('localizedObject', $originalClass->getName()), new ParameterGenerator('prefixInterceptors', 'array', []), new ParameterGenerator('suffixInterceptors', 'array', [])], static::FLAG_PRIVATE, null, "@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"); $localizedProperties = []; $properties = Properties::fromReflectionClass($originalClass); foreach ($properties->getAccessibleProperties() as $property) { $propertyName = $property->getName(); $localizedProperties[] = '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";"; } foreach ($properties->getPrivateProperties() as $property) { $propertyName = $property->getName(); $localizedProperties[] = "\\Closure::bind(function () use (\$localizedObject) {\n " . '$this->' . $propertyName . ' = & $localizedObject->' . $propertyName . ";\n" . '}, $this, ' . var_export($property->getDeclaringClass()->getName(), true) . ')->__invoke();'; } $this->setBody((empty($localizedProperties) ? '' : implode("\n\n", $localizedProperties) . "\n\n") . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;"); }
/** * Constructor * * @param ReflectionClass $originalClass * @param PropertyGenerator $valueHolder * @param PropertyGenerator $prefixInterceptors * @param PropertyGenerator $suffixInterceptors */ public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolder, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors) { parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC); $prefix = new ParameterGenerator('prefixInterceptors'); $suffix = new ParameterGenerator('suffixInterceptors'); $prefix->setDefaultValue([]); $suffix->setDefaultValue([]); $prefix->setType('array'); $suffix->setType('array'); $this->setParameter(new ParameterGenerator('wrappedObject')); $this->setParameter($prefix); $this->setParameter($suffix); $this->setReturnType($originalClass->getName()); $this->setDocblock("Constructor to setup interceptors\n\n" . "@param \\" . $originalClass->getName() . " \$wrappedObject\n" . "@param \\Closure[] \$prefixInterceptors method interceptors to be used before method logic\n" . "@param \\Closure[] \$suffixInterceptors method interceptors to be used before method logic\n\n" . "@return self"); $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = (new \\ReflectionClass(get_class()))->newInstanceWithoutConstructor();' . "\n\n" . UnsetPropertiesGenerator::generateSnippet(Properties::fromReflectionClass($originalClass), 'instance') . '$instance->' . $valueHolder->getName() . " = \$wrappedObject;\n" . '$instance->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" . '$instance->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;\n\n" . 'return $instance;'); }
/** * Creates a new {@link \bitExpert\Disco\Proxy\LazyBean\MethodGenerator\Constructor}. * * @param ReflectionClass $originalClass * @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty */ public function __construct(ReflectionClass $originalClass, BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty) { parent::__construct('wrapBeanAsLazy'); $this->setParameter(new ParameterGenerator('beanId')); $this->setParameter(new ParameterGenerator('beanType')); $this->setParameter(new ParameterGenerator('instance')); $content = '$factory = new \\' . \bitExpert\Disco\Proxy\LazyBean\LazyBeanFactory::class . '($beanId, $this->' . $beanFactoryConfigurationProperty->getName() . '->getProxyManagerConfiguration());' . PHP_EOL; $content .= '$initializer = function (&$wrappedObject, \\' . \ProxyManager\Proxy\LazyLoadingInterface::class . ' $proxy, $method, array $parameters, &$initializer) use($instance) {' . PHP_EOL; $content .= ' $initializer = null;' . PHP_EOL; $content .= ' $wrappedObject = $instance;' . PHP_EOL; $content .= ' return true;' . PHP_EOL; $content .= '};' . PHP_EOL; $content .= PHP_EOL; $content .= '$initializer->bindTo($this);' . PHP_EOL; $content .= 'return $factory->createProxy($beanType, $initializer);' . PHP_EOL; $this->setBody($content); }
/** * Constructor * * @param ReflectionClass $originalClass */ public function __construct(ReflectionClass $originalClass) { parent::__construct('staticProxyConstructor', [], static::FLAG_PUBLIC | static::FLAG_STATIC); $localizedObject = new ParameterGenerator('localizedObject'); $prefix = new ParameterGenerator('prefixInterceptors'); $suffix = new ParameterGenerator('suffixInterceptors'); $localizedObject->setType($originalClass->getName()); $prefix->setDefaultValue([]); $suffix->setDefaultValue([]); $prefix->setType('array'); $suffix->setType('array'); $this->setParameter($localizedObject); $this->setParameter($prefix); $this->setParameter($suffix); $this->setDocblock("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\n\n" . "@return self"); $this->setBody('static $reflection;' . "\n\n" . '$reflection = $reflection ?: $reflection = new \\ReflectionClass(__CLASS__);' . "\n" . '$instance = $reflection->newInstanceWithoutConstructor();' . "\n\n" . '$instance->bindProxyProperties($localizedObject, $prefixInterceptors, $suffixInterceptors);' . "\n\n" . 'return $instance;'); }
/** * Constructor */ public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolder, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors) { parent::__construct('__construct'); $prefix = new ParameterGenerator('prefixInterceptors'); $suffix = new ParameterGenerator('suffixInterceptors'); $prefix->setDefaultValue(array()); $suffix->setDefaultValue(array()); $prefix->setType('array'); $suffix->setType('array'); $this->setParameter(new ParameterGenerator('wrappedObject')); $this->setParameter($prefix); $this->setParameter($suffix); /* @var $publicProperties \ReflectionProperty[] */ $publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC); $unsetProperties = array(); foreach ($publicProperties as $publicProperty) { $unsetProperties[] = '$this->' . $publicProperty->getName(); } $this->setDocblock("@override constructor to setup interceptors\n\n" . "@param \\" . $originalClass->getName() . " \$wrappedObject\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(($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");\n\n" : '') . '$this->' . $valueHolder->getName() . " = \$wrappedObject;\n" . '$this->' . $prefixInterceptors->getName() . " = \$prefixInterceptors;\n" . '$this->' . $suffixInterceptors->getName() . " = \$suffixInterceptors;"); }
/** * Creates a new {@link \bitExpert\Disco\Proxy\Configuration\MethodGenerator\Constructor}. * * @param ReflectionClass $originalClass * @param ParameterValuesProperty $parameterValuesProperty * @param SessionBeansProperty $sessionBeansProperty * @param BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty * @param BeanPostProcessorsProperty $beanPostProcessorsProperty * @param string[] $beanPostProcessorMethodNames */ public function __construct(ReflectionClass $originalClass, ParameterValuesProperty $parameterValuesProperty, SessionBeansProperty $sessionBeansProperty, BeanFactoryConfigurationProperty $beanFactoryConfigurationProperty, BeanPostProcessorsProperty $beanPostProcessorsProperty, array $beanPostProcessorMethodNames) { parent::__construct('__construct'); $beanFactoryConfigurationParameter = new ParameterGenerator('config'); $beanFactoryConfigurationParameter->setType(BeanFactoryConfiguration::class); $parametersParameter = new ParameterGenerator('params'); $parametersParameter->setDefaultValue([]); $body = '$this->' . $parameterValuesProperty->getName() . ' = $' . $parametersParameter->getName() . ';' . PHP_EOL; $body .= '$this->' . $beanFactoryConfigurationProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() . ';' . PHP_EOL; $body .= '$this->' . $sessionBeansProperty->getName() . ' = $' . $beanFactoryConfigurationParameter->getName() . '->getSessionBeanStore();' . PHP_EOL; $body .= '// register {@link \\bitExpert\\Disco\\BeanPostProcessor} instances' . PHP_EOL; $body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = new \\bitExpert\\Disco\\BeanFactoryPostProcessor();' . PHP_EOL; foreach ($beanPostProcessorMethodNames as $methodName) { $body .= '$this->' . $beanPostProcessorsProperty->getName() . '[] = $this->' . $methodName . '(); '; $body .= PHP_EOL; } $this->setParameter($beanFactoryConfigurationParameter); $this->setParameter($parametersParameter); $this->setBody($body); $this->setDocBlock("@override constructor"); }
public function __construct() { parent::__construct('getIndexOriginalValue'); $this->setParameter(new ParameterGenerator('name', 'string')); $this->setBody('return isset($this->_original_indices[$name]) ? $this->_original_indices[$name] : null;'); }
/** * Constructor * * @param PropertyGenerator $initializerProperty */ public function __construct(PropertyGenerator $initializerProperty) { parent::__construct('getProxyInitializer'); $this->setDocblock('{@inheritDoc}'); $this->setBody('return $this->' . $initializerProperty->getName() . ';'); }
/** * Constructor * * @param PropertyGenerator $initializerProperty */ public function __construct(PropertyGenerator $initializerProperty) { parent::__construct('setProxyInitializer', [(new ParameterGenerator('initializer', 'Closure'))->setDefaultValue(null)], self::FLAG_PUBLIC, '$this->' . $initializerProperty->getName() . ' = $initializer;', '{@inheritDoc}'); }
public function __construct() { parent::__construct('setRelativeModified'); $this->setParameter(new ParameterGenerator('name', 'string')); $this->setBody('$this->_modified_relatives[$name] = true; return $this;'); }
public function __construct() { parent::__construct('setOriginalId'); $this->setParameter(new ParameterGenerator('value', 'string')); $this->setBody('$this->_original_id = $value; return $this;'); }