本文整理汇总了PHP中ProxyManager\Generator\MagicMethodGenerator类的典型用法代码示例。如果您正苦于以下问题:PHP MagicMethodGenerator类的具体用法?PHP MagicMethodGenerator怎么用?PHP MagicMethodGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MagicMethodGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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 . ';');
}
示例2: __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);
}
示例3: __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) . ');');
}
示例4: __construct
/**
* Constructor
*
* @param ReflectionClass $originalClass
*/
public function __construct(ReflectionClass $originalClass)
{
parent::__construct($originalClass, '__wakeup');
$unsetProperties = array_map(function (ReflectionProperty $property) {
return '$this->' . $property->getName();
}, Properties::fromReflectionClass($originalClass)->getPublicProperties());
$this->setBody($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");" : '');
}
示例5: __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" . "}");
}
示例6: __construct
/**
* Constructor
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty, PublicPropertiesMap $publicProperties)
{
parent::__construct($originalClass, '__get', array(new ParameterGenerator('name')));
$this->setDocblock(($originalClass->hasMethod('__get') ? "{@inheritDoc}\n" : '') . '@param string $name');
$initializer = $initializerProperty->getName();
$valueHolder = $valueHolderProperty->getName();
$callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" . ' return $this->' . $valueHolder . '->$name;' . "\n}\n\n";
$callParent .= PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_GET, 'name', null, $valueHolderProperty);
$this->setBody('$this->' . $initializer . ' && $this->' . $initializer . '->__invoke($this->' . $valueHolder . ', $this, \'__get\', array(\'name\' => $name), $this->' . $initializer . ');' . "\n\n" . $callParent);
}
示例7: __construct
/**
* Constructor
*/
public function __construct(ReflectionClass $originalClass)
{
parent::__construct($originalClass, '__wakeup');
/* @var $publicProperties \ReflectionProperty[] */
$publicProperties = $originalClass->getProperties(ReflectionProperty::IS_PUBLIC);
$unsetProperties = array();
foreach ($publicProperties as $publicProperty) {
$unsetProperties[] = '$this->' . $publicProperty->getName();
}
$this->setBody($unsetProperties ? 'unset(' . implode(', ', $unsetProperties) . ");" : '');
}
示例8: __construct
/**
* @param \ReflectionClass $originalClass
* @param \Zend\Code\Generator\PropertyGenerator $prefixInterceptors
* @param \Zend\Code\Generator\PropertyGenerator $suffixInterceptors
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors)
{
parent::__construct($originalClass, '__set', array(new ParameterGenerator('name'), new ParameterGenerator('value')));
$override = $originalClass->hasMethod('__set');
$this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name');
if ($override) {
$callParent = '$returnValue = & parent::__set($name, $value);';
} else {
$callParent = PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'name', 'value', null, 'returnValue');
}
$this->setBody(InterceptorGenerator::createInterceptedMethodBody($callParent, $this, $prefixInterceptors, $suffixInterceptors));
}
示例9: __construct
/**
* Constructor
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $valueHolder, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors, PublicPropertiesMap $publicProperties)
{
parent::__construct($originalClass, '__set', array(new ParameterGenerator('name'), new ParameterGenerator('value')));
$override = $originalClass->hasMethod('__set');
$valueHolderName = $valueHolder->getName();
$this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name');
$callParent = PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'name', 'value', $valueHolder, 'returnValue');
if (!$publicProperties->isEmpty()) {
$callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" . ' $returnValue = ($this->' . $valueHolderName . '->$name = $value);' . "\n} else {\n {$callParent}\n}\n\n";
}
$this->setBody(InterceptorGenerator::createInterceptedMethodBody($callParent, $this, $valueHolder, $prefixInterceptors, $suffixInterceptors));
}
示例10: __construct
/**
* Constructor
*
* @param ReflectionClass $originalClass
* @param PropertyGenerator $initializerProperty
* @param PropertyGenerator $valueHolderProperty
* @param PublicPropertiesMap $publicProperties
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, PropertyGenerator $valueHolderProperty, PublicPropertiesMap $publicProperties)
{
parent::__construct($originalClass, '__set', [new ParameterGenerator('name'), new ParameterGenerator('value')]);
$initializer = $initializerProperty->getName();
$valueHolder = $valueHolderProperty->getName();
$callParent = '';
$this->setDocblock(($originalClass->hasMethod('__set') ? "{@inheritDoc}\n" : '') . "@param string \$name\n@param mixed \$value");
if (!$publicProperties->isEmpty()) {
$callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" . ' return ($this->' . $valueHolder . '->$name = $value);' . "\n}\n\n";
}
$callParent .= PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'name', 'value', $valueHolderProperty);
$this->setBody('$this->' . $initializer . ' && $this->' . $initializer . '->__invoke($this->' . $valueHolder . ', $this, ' . '\'__set\', array(\'name\' => $name, \'value\' => $value), $this->' . $initializer . ');' . "\n\n" . $callParent);
}
示例11: __construct
/**
* @param \ReflectionClass $originalClass
* @param \Zend\Code\Generator\PropertyGenerator $initializerProperty
* @param \Zend\Code\Generator\MethodGenerator $callInitializer
* @param \ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap $publicProperties
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, MethodGenerator $callInitializer, PublicPropertiesMap $publicProperties)
{
parent::__construct($originalClass, '__get', array(new ParameterGenerator('name')));
$override = $originalClass->hasMethod('__get');
$callParent = '';
$this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name');
if (!$publicProperties->isEmpty()) {
$callParent = 'if (isset(self::$' . $publicProperties->getName() . "[\$name])) {\n" . ' return $this->$name;' . "\n}\n\n";
}
if ($override) {
$callParent .= 'return parent::__get($name);';
} else {
$callParent .= PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_GET, 'name');
}
$this->setBody('$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(\'__get\', array(\'name\' => $name));' . "\n\n" . $callParent);
}
示例12: __construct
/**
* Constructor
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, MethodGenerator $callInitializer)
{
parent::__construct($originalClass, '__sleep');
$this->setBody('$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(\'__sleep\', array());' . "\n\n" . ($originalClass->hasMethod('__sleep') ? 'return parent::__sleep();' : 'return array_keys((array) $this);'));
}
示例13: __construct
/**
* @param ReflectionClass $originalClass
* @param PropertyGenerator $initializerProperty
* @param MethodGenerator $callInitializer
* @param PublicPropertiesMap $publicProperties
* @param ProtectedPropertiesMap $protectedProperties
* @param PrivatePropertiesMap $privateProperties
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, MethodGenerator $callInitializer, PublicPropertiesMap $publicProperties, ProtectedPropertiesMap $protectedProperties, PrivatePropertiesMap $privateProperties)
{
parent::__construct($originalClass, '__set', [new ParameterGenerator('name'), new ParameterGenerator('value')]);
$override = $originalClass->hasMethod('__set');
$this->setDocblock(($override ? "{@inheritDoc}\n" : '') . '@param string $name');
$parentAccess = 'return parent::__set($name, $value);';
if (!$override) {
$parentAccess = PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'name', 'value');
}
$this->setBody(sprintf($this->callParentTemplate, '$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(\'__set\', array(\'name\' => $name, \'value\' => $value));', $publicProperties->getName(), $protectedProperties->getName(), $protectedProperties->getName(), $privateProperties->getName(), $privateProperties->getName(), $privateProperties->getName(), $parentAccess));
}
示例14: __construct
/**
* Constructor
* @param ReflectionClass $originalClass
* @param \Zend\Code\Generator\PropertyGenerator $adapterProperty
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty)
{
parent::__construct($originalClass, '__set', array(new ParameterGenerator('name'), new ParameterGenerator('value')));
$this->setDocblock('@param string \\$name\\n@param mixed \\$value');
$this->setBody('$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true) . ', \'__set\', array($name, $value));' . "\n\n" . 'return $return;');
}
示例15: __construct
/**
* Constructor
*
* @param ReflectionClass $originalClass
* @param PropertyGenerator $prefixInterceptors
* @param PropertyGenerator $suffixInterceptors
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $prefixInterceptors, PropertyGenerator $suffixInterceptors)
{
parent::__construct($originalClass, '__clone');
$this->setBody(InterceptorGenerator::createInterceptedMethodBody($originalClass->hasMethod('__clone') ? '$returnValue = parent::__clone();' : '$returnValue = null;', $this, $prefixInterceptors, $suffixInterceptors));
}