本文整理匯總了PHP中Zend\Code\Generator\MethodGenerator::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP MethodGenerator::getName方法的具體用法?PHP MethodGenerator::getName怎麽用?PHP MethodGenerator::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\Code\Generator\MethodGenerator
的用法示例。
在下文中一共展示了MethodGenerator::getName方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __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\', []);');
}
示例2: addMethodIfNotFinal
/**
* @param ReflectionClass $originalClass
* @param ClassGenerator $classGenerator
* @param MethodGenerator $generatedMethod
*
* @return void|false
*/
public static function addMethodIfNotFinal(ReflectionClass $originalClass, ClassGenerator $classGenerator, MethodGenerator $generatedMethod)
{
$methodName = $generatedMethod->getName();
if ($originalClass->hasMethod($methodName) && $originalClass->getMethod($methodName)->isFinal()) {
return false;
}
$classGenerator->addMethodFromGenerator($generatedMethod);
}
示例3: __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);
}
示例4: generateMethod
/**
* @param \Zend\Code\Reflection\MethodReflection $originalMethod
* @param \Zend\Code\Generator\PropertyGenerator $initializerProperty
* @param \Zend\Code\Generator\MethodGenerator $callInitializer
*
* @return LazyLoadingMethodInterceptor|static
*/
public static function generateMethod(MethodReflection $originalMethod, PropertyGenerator $initializerProperty, ZendMethodGenerator $callInitializer)
{
/* @var $method self */
$method = static::fromReflection($originalMethod);
$parameters = $originalMethod->getParameters();
$methodName = $originalMethod->getName();
$initializerParams = array();
$forwardedParams = array();
foreach ($parameters as $parameter) {
$parameterName = $parameter->getName();
$initializerParams[] = var_export($parameterName, true) . ' => $' . $parameterName;
$forwardedParams[] = '$' . $parameterName;
}
$method->setBody('$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(' . var_export($methodName, true) . ', array(' . implode(', ', $initializerParams) . "));\n\n" . 'return parent::' . $methodName . '(' . implode(', ', $forwardedParams) . ');');
$method->setDocblock('{@inheritDoc}');
return $method;
}
示例5: __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);'));
}
示例6: __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));
}
示例7: setMethod
/**
* setMethod()
*
* @param string|MethodGenerator $method
* @return ClassGenerator
*/
public function setMethod($method)
{
if (is_string($method)) {
$method = new MethodGenerator($method);
}
if (!$method instanceof MethodGenerator) {
throw new Exception\InvalidArgumentException('setMethod() expects either a string method name or an instance of Zend\\Code\\Generator\\MethodGenerator');
}
$methodName = $method->getName();
if (isset($this->methods[$methodName])) {
throw new Exception\InvalidArgumentException('A method by name ' . $methodName . ' already exists in this class.');
}
$this->methods[$methodName] = $method;
return $this;
}
示例8: __construct
/**
* Constructor
*
* @param ReflectionClass $originalClass
* @param PropertyGenerator $initializerProperty
* @param MethodGenerator $callInitializer
*/
public function __construct(ReflectionClass $originalClass, PropertyGenerator $initializerProperty, MethodGenerator $callInitializer)
{
parent::__construct($originalClass, '__clone');
$this->setBody('$this->' . $initializerProperty->getName() . ' && $this->' . $callInitializer->getName() . '(\'__clone\', []);' . ($originalClass->hasMethod('__clone') ? "\n\nparent::__clone();" : ''));
}
示例9: addMethodFromGenerator
/**
* Add Method from MethodGenerator
*
* @param MethodGenerator $method
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
public function addMethodFromGenerator(MethodGenerator $method)
{
$methodName = $method->getName();
if (isset($this->methods[$methodName])) {
throw new Exception\InvalidArgumentException('A method by name ' . $methodName . ' already exists in this class.');
}
$this->methods[$methodName] = $method;
return $this;
}
示例10: addMethodFromGenerator
/**
* Add Method from MethodGenerator
*
* @param MethodGenerator $method
* @throws Exception\InvalidArgumentException
* @return ClassGenerator
*/
public function addMethodFromGenerator(MethodGenerator $method)
{
$methodName = $method->getName();
if ($this->hasMethod($methodName)) {
throw new Exception\InvalidArgumentException(sprintf('A method by name %s already exists in this class.', $methodName));
}
$this->methods[strtolower($methodName)] = $method;
return $this;
}
示例11: addMethodFromGenerator
/**
* Add method from MethodGenerator
*
* @param MethodGenerator $method
* @return $this
* @throws \InvalidArgumentException
*/
public function addMethodFromGenerator(MethodGenerator $method)
{
if (!is_string($method->getName())) {
throw new \InvalidArgumentException('addMethodFromGenerator() expects string for name');
}
return parent::addMethodFromGenerator($method);
}