當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MethodGenerator::getName方法代碼示例

本文整理匯總了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\', []);');
 }
開發者ID:jbafford,項目名稱:ProxyManager,代碼行數:13,代碼來源:InitializeProxy.php

示例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);
 }
開發者ID:John-Eddy,項目名稱:ProjetCastor,代碼行數:15,代碼來源:ClassGeneratorUtils.php

示例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);
 }
開發者ID:Clon450,項目名稱:batata,代碼行數:22,代碼來源:MagicGet.php

示例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;
 }
開發者ID:Clon450,項目名稱:batata,代碼行數:24,代碼來源:LazyLoadingMethodInterceptor.php

示例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);'));
 }
開發者ID:John-Eddy,項目名稱:ProjetCastor,代碼行數:8,代碼來源:MagicSleep.php

示例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));
 }
開發者ID:andywooyay,項目名稱:ProxyManager,代碼行數:19,代碼來源:MagicSet.php

示例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;
 }
開發者ID:brikou,項目名稱:zend_code,代碼行數:21,代碼來源:ClassGenerator.php

示例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();" : ''));
 }
開發者ID:jbafford,項目名稱:ProxyManager,代碼行數:12,代碼來源:MagicClone.php

示例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;
    }
開發者ID:necrogami,項目名稱:zf2,代碼行數:18,代碼來源:ClassGenerator.php

示例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;
 }
開發者ID:vrann,項目名稱:magento2-from-vendor,代碼行數:16,代碼來源:ClassGenerator.php

示例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);
 }
開發者ID:IlyaGluschenko,項目名稱:test001,代碼行數:14,代碼來源:ClassGenerator.php


注:本文中的Zend\Code\Generator\MethodGenerator::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。