当前位置: 首页>>代码示例>>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;未经允许,请勿转载。