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


PHP ParameterGenerator::fromReflection方法代碼示例

本文整理匯總了PHP中Zend\Code\Generator\ParameterGenerator::fromReflection方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParameterGenerator::fromReflection方法的具體用法?PHP ParameterGenerator::fromReflection怎麽用?PHP ParameterGenerator::fromReflection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\Code\Generator\ParameterGenerator的用法示例。


在下文中一共展示了ParameterGenerator::fromReflection方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fromReflection

 /**
  * @param  MethodReflection $reflectionMethod
  * @return MethodGenerator
  */
 public static function fromReflection(MethodReflection $reflectionMethod)
 {
     $method = new static();
     $declaringClass = $reflectionMethod->getDeclaringClass();
     $method->setSourceContent($reflectionMethod->getContents(false));
     $method->setSourceDirty(false);
     $method->setReturnType(self::extractReturnTypeFromMethodReflection($reflectionMethod));
     if ($reflectionMethod->getDocComment() != '') {
         $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock()));
     }
     $method->setFinal($reflectionMethod->isFinal());
     if ($reflectionMethod->isPrivate()) {
         $method->setVisibility(self::VISIBILITY_PRIVATE);
     } elseif ($reflectionMethod->isProtected()) {
         $method->setVisibility(self::VISIBILITY_PROTECTED);
     } else {
         $method->setVisibility(self::VISIBILITY_PUBLIC);
     }
     $method->setInterface($declaringClass->isInterface());
     $method->setStatic($reflectionMethod->isStatic());
     $method->setReturnsReference($reflectionMethod->returnsReference());
     $method->setName($reflectionMethod->getName());
     foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
         $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter));
     }
     $method->setBody(static::clearBodyIndention($reflectionMethod->getBody()));
     return $method;
 }
開發者ID:zendframework,項目名稱:zend-code,代碼行數:32,代碼來源:MethodGenerator.php

示例2: fromReflection

    /**
     * fromReflection()
     *
     * @param  MethodReflection $reflectionMethod
     * @return MethodGenerator
     */
    public static function fromReflection(MethodReflection $reflectionMethod)
    {
        $method = new self();

        $method->setSourceContent($reflectionMethod->getContents(false));
        $method->setSourceDirty(false);

        if ($reflectionMethod->getDocComment() != '') {
            $method->setDocBlock(DocBlockGenerator::fromReflection($reflectionMethod->getDocBlock()));
        }

        $method->setFinal($reflectionMethod->isFinal());

        if ($reflectionMethod->isPrivate()) {
            $method->setVisibility(self::VISIBILITY_PRIVATE);
        } elseif ($reflectionMethod->isProtected()) {
            $method->setVisibility(self::VISIBILITY_PROTECTED);
        } else {
            $method->setVisibility(self::VISIBILITY_PUBLIC);
        }

        $method->setStatic($reflectionMethod->isStatic());

        $method->setName($reflectionMethod->getName());

        foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
            $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter));
        }

        $method->setBody($reflectionMethod->getBody());

        return $method;
    }
開發者ID:necrogami,項目名稱:zf2,代碼行數:39,代碼來源:MethodGenerator.php

示例3: testFromReflectionGenerate

 /**
  * @dataProvider dataFromReflectionGenerate
  * @param string $methodName
  * @param string $expectedCode
  */
 public function testFromReflectionGenerate($methodName, $expectedCode)
 {
     //$this->markTestSkipped('Test may not be necessary any longer');
     $reflectionParameter = $this->getFirstReflectionParameter($methodName);
     $codeGenParam = ParameterGenerator::fromReflection($reflectionParameter);
     $this->assertEquals($expectedCode, $codeGenParam->generate());
 }
開發者ID:rikaix,項目名稱:zf2,代碼行數:12,代碼來源:ParameterGeneratorTest.php

示例4: testFromReflectionGenerate

    /**
     * @dataProvider dataFromReflectionGenerate
     * @param string $methodName
     * @param string $expectedCode
     */
    public function testFromReflectionGenerate($methodName, $expectedCode)
    {
        $reflectionParameter = $this->getFirstReflectionParameter($methodName);
        $codeGenParam = ParameterGenerator::fromReflection($reflectionParameter);

        $this->assertEquals($expectedCode, $codeGenParam->generate());
    }
開發者ID:benivaldo,項目名稱:zf2-na-pratica,代碼行數:12,代碼來源:ParameterGeneratorTest.php

示例5: testTypehintsWithNamespaceInNamepsacedClassReturnTypewithBackslash

 /**
  * @group 5193
  */
 public function testTypehintsWithNamespaceInNamepsacedClassReturnTypewithBackslash()
 {
     require_once __DIR__ . '/TestAsset/NamespaceTypeHintClass.php';
     $reflClass = new \Zend\Code\Reflection\ClassReflection('Namespaced\\TypeHint\\Bar');
     $params = $reflClass->getMethod('method')->getParameters();
     $param = ParameterGenerator::fromReflection($params[0]);
     $this->assertEquals('\\OtherNamespace\\ParameterClass', $param->getType());
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:11,代碼來源:ParameterGeneratorTest.php

示例6: fromReflection

 /**
  * @override Enforces generation of \ProxyManager\Generator\MethodGenerator.
  *
  * {@inheritDoc}
  * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  */
 public static function fromReflection(MethodReflection $reflectionMethod) : MethodGenerator
 {
     $method = parent::fromReflection($reflectionMethod);
     /*
      * When overwriting methods PHP 7 enforces the same method parameters to be defined as in the base class. Since
      * the {@link \bitExpert\Disco\AnnotationBeanFactory} calls the generated methods without any parameters we
      * simply set a default value of null for each of the method parameters.
      */
     $method->setParameters([]);
     foreach ($reflectionMethod->getParameters() as $reflectionParameter) {
         $parameter = ParameterGenerator::fromReflection($reflectionParameter);
         $parameter->setDefaultValue(null);
         $method->setParameter($parameter);
     }
     return $method;
 }
開發者ID:bitexpert,項目名稱:disco,代碼行數:22,代碼來源:BeanMethod.php


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