コード例 #1
0
 /**
  * @dataProvider providerExportFunction
  *
  * @param string  $method
  * @param integer $excludeModifiers
  * @param string  $expected
  */
 public function testExportFunction($method, $excludeModifiers, $expected)
 {
     $tools = new ReflectionTools();
     $function = new \ReflectionMethod(__NAMESPACE__ . '\\Export', $method);
     $this->assertSame($expected, $tools->exportFunction($function, $excludeModifiers));
 }
コード例 #2
0
ファイル: proxy-generate.php プロジェクト: brick/geo
$reflectionTools = new ReflectionTools();
foreach ($classes as $class) {
    $class = new ReflectionClass($classNamespace . '\\' . $class);
    if ($class->getName() == CoordinateSystem::class) {
        continue;
    }
    $methods = '';
    foreach ($class->getMethods(ReflectionMethod::IS_PUBLIC) as $method) {
        if ($method->isConstructor() || $method->isStatic()) {
            continue;
        }
        if (strpos($method->getDocComment(), '@noproxy') !== false) {
            continue;
        }
        $methodCode = $methodTemplate;
        $methodCode = str_replace('function _TEMPLATE_()', $reflectionTools->exportFunction($method, \ReflectionMethod::IS_ABSTRACT), $methodCode);
        $parameterCode = $method->getShortName() . '(';
        foreach ($method->getParameters() as $key => $parameter) {
            if ($key !== 0) {
                $parameterCode .= ', ';
            }
            $parameterCode .= '$' . $parameter->getName();
        }
        $parameterCode .= ')';
        $methodCode = str_replace('_METHOD_()', $parameterCode, $methodCode);
        $methods .= $methodCode;
    }
    $proxyCode = $proxyTemplate;
    $proxyCode = str_replace('_CLASSNAME_', $class->getShortName(), $proxyCode);
    $proxyCode = str_replace('// METHODS', $methods, $proxyCode);
    file_put_contents($proxyDir . $class->getShortName() . 'Proxy.php', $proxyCode);