getTargetMethods() public method

Interception은 타겟 클래스의 public 메소드만 대상으로 한다.
public getTargetMethods ( ) : ReflectionMetho\ReflectionMethod[]
return ReflectionMetho\ReflectionMethod[] 수정할 메소드 목록
コード例 #1
0
 public function testGetTargetMethods()
 {
     $config = new ProxyConfig('\\Xpressengine\\Tests\\ProxyConfigTest\\TestTargetClass');
     $methods = $config->getTargetMethods();
     $this->assertCount(2, $methods);
     $funA = array_shift($methods);
     $this->assertInstanceOf(ReflectionMethod::class, $funA);
     $this->assertEquals('funcA', $funA->getName());
 }
コード例 #2
0
 /**
  * 주어진 프록시 클래스 템플릿 코드의 메소드 선언부를 변환한다.
  *
  * @param string      $code   프록시 클래스 탬플릿 코드
  * @param ProxyConfig $config 동적으로 생성하려는 프록시 클래스 정보
  *
  * @return string
  */
 public function apply($code, ProxyConfig $config)
 {
     foreach ($config->getTargetMethods() as $method) {
         if ($method->isStatic()) {
             continue;
         }
         $name = $method->getName();
         $methodDef = '    public';
         $methodDef .= ' function ';
         $methodDef .= $method->returnsReference() ? ' & ' : '';
         $methodDef .= $name;
         $methodDef .= $this->renderParams($method);
         $methodDef .= $this->renderMethodBody($name === '__call');
         $code = $this->appendToClass($code, $methodDef);
     }
     return $code;
 }