1 | <?php |
||
18 | class MethodGenerator extends ZendMethodGenerator |
||
19 | { |
||
20 | /** |
||
21 | * Similar to fromReflection() but without copying the method body and phpdoc. |
||
22 | * |
||
23 | * @see \Zend\Code\Generator\MethodGenerator::fromReflection |
||
24 | */ |
||
25 | 19 | public static function fromReflectionWithoutBodyAndDocBlock(MethodReflection $reflectionMethod) : self |
|
26 | { |
||
27 | 19 | $method = new static(); |
|
28 | |||
29 | 19 | $method->setReturnType(self::extractReturnTypeFromMethodReflection($reflectionMethod)); |
|
30 | 19 | $method->setFinal($reflectionMethod->isFinal()); |
|
31 | |||
32 | 19 | if ($reflectionMethod->isPrivate()) { |
|
33 | 1 | $method->setVisibility(self::VISIBILITY_PRIVATE); |
|
34 | 19 | } elseif ($reflectionMethod->isProtected()) { |
|
35 | 1 | $method->setVisibility(self::VISIBILITY_PROTECTED); |
|
36 | } else { |
||
37 | 19 | $method->setVisibility(self::VISIBILITY_PUBLIC); |
|
38 | } |
||
39 | |||
40 | 19 | $method->setInterface(false); |
|
41 | 19 | $method->setStatic($reflectionMethod->isStatic()); |
|
42 | 19 | $method->setReturnsReference($reflectionMethod->returnsReference()); |
|
43 | 19 | $method->setName($reflectionMethod->getName()); |
|
44 | |||
45 | 19 | foreach ($reflectionMethod->getParameters() as $reflectionParameter) { |
|
46 | 5 | $method->setParameter(ParameterGenerator::fromReflection($reflectionParameter)); |
|
47 | } |
||
48 | |||
49 | 19 | return $method; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @see \Zend\Code\Generator\MethodGenerator::extractReturnTypeFromMethodReflection |
||
54 | */ |
||
55 | 19 | private static function extractReturnTypeFromMethodReflection(MethodReflection $methodReflection) |
|
72 | |||
73 | /** |
||
74 | * @see \Zend\Code\Generator\MethodGenerator::expandLiteralType |
||
75 | */ |
||
76 | 13 | private static function expandLiteralType($literalReturnType, ReflectionMethod $methodReflection) |
|
88 | } |
||
89 |