示例#1
0
 public function test_special1()
 {
     $filename = AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . 'reflection_doc_block_test_class.php';
     $file = new AkReflectionFile($filename);
     $this->assertEqual(1, count($file->getClasses()));
     $classes = $file->getClasses();
     $this->assertEqual('ReflectionDocBlockTestClass', $classes[0]->getName());
     $class = $classes[0];
     $this->assertEqual('BaseActiveRecord', $class->getTag('ExtensionPoint'));
 }
示例#2
0
 public function test_remove_methods()
 {
     $this->PluginInstaller->installExtensions('file:' . $this->extenssion_path, 'TEST');
     $reflection = new AkReflectionFile($this->target_path);
     $classes = $reflection->getClasses();
     $this->assertEqual(1, count($classes));
     $extension1 = $classes[0]->getMethod('extension1');
     $this->assertEqual('extension1', $extension1->getName());
     $orgContents = file_get_contents($this->template_path);
     $newContents = file_get_contents($this->target_path);
     $this->assertNotEqual($orgContents, $newContents);
     $this->PluginInstaller->removeExtensions('TEST');
     $orgContents = file_get_contents($this->template_path);
     $newContents = file_get_contents($this->target_path);
     $this->assertEqual($orgContents, $newContents);
 }
示例#3
0
 function test_remove_methods()
 {
     $this->installer->installExtensions('file:' . AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . 'plugin_installer_method_extensions.php', 'TEST');
     $checkFilename = AK_APP_DIR . DS . 'plugin_installer_target_class.php';
     $reflection = new AkReflectionFile($checkFilename);
     $classes = $reflection->getClasses();
     $this->assertEqual(1, count($classes));
     $extension1 = $classes[0]->getMethod('extension1');
     $this->assertEqual('extension1', $extension1->getName());
     $orgContents = file_get_contents($tplFilename = AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . 'plugin_installer_target_class.php.tpl');
     $newContents = file_get_contents($checkFilename);
     $this->assertNotEqual($orgContents, $newContents);
     $this->installer->removeExtensions('TEST');
     $orgContents = file_get_contents($tplFilename = AK_TEST_DIR . DS . 'fixtures' . DS . 'data' . DS . 'plugin_installer_target_class.php.tpl');
     $newContents = file_get_contents($checkFilename);
     $this->assertEqual($orgContents, $newContents);
 }
示例#4
0
 function removeExtensions($pluginIdentifier = null)
 {
     if ($pluginIdentifier == null) {
         $pluginIdentifier = AkInflector::camelize($this->plugin_name);
     }
     foreach ($this->extension_points as $targetClass => $baseFile) {
         $file = AK_APP_DIR . DS . $baseFile;
         $reflection = new AkReflectionFile($file);
         $classes = $reflection->getClasses();
         foreach ($classes as $class) {
             $methods = $class->getMethods(array('tags' => array('Plugin' => $pluginIdentifier)));
             foreach ($methods as $method) {
                 $this->_removeMethodFromClass($file, $method->getName(), $pluginIdentifier);
             }
         }
     }
 }
示例#5
0
 protected function _addMethodToClass($class, $name, $path, $methodString, $pluginName)
 {
     $targetReflection = new AkReflectionFile($path);
     $classes = $targetReflection->getClasses();
     foreach ($classes as $c) {
         $method = $c->getMethod($name);
         if ($method !== false) {
             echo "Method {$name} already exists on class {$class} in file {$path}\n";
             return false;
         }
     }
     $contents = file_exists($path) ? AkFileSystem::file_get_contents($path, array('skip_path_restriction' => true)) : '';
     return AkFileSystem::file_put_contents($path, preg_replace('|class ' . $class . '(.*?)\\n.*?{|i', "class {$class}\\1\n{\n/** AUTOMATED START: {$pluginName}::{$name} */\n{$methodString}\n/** AUTOMATED END: {$pluginName}::{$name} */\n", $contents), array('skip_path_restriction' => true)) > 0 ? true : 'Could not write to ' . $path;
 }
示例#6
0
    $DocInstaller = new DocInstaller($db);
    $DocInstaller->install();
}
$SourceAnalyzer = new SourceAnalyzer();
$SourceAnalyzer->db = $db;
$SourceAnalyzer->storeFilesForIndexing(AK_ACTION_MAILER_DIR);
$SourceAnalyzer->indexFiles();
//unlink($doc_db_file);
return;
$dir_iterator = new RecursiveDirectoryIterator(AK_ACTION_MAILER_DIR);
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file) {
    if ($file->isFile()) {
        echo $file, "\n";
        $original_file = file_get_contents($file);
        $Reflection = new AkReflectionFile($file);
        foreach ($Reflection->getClasses() as $Class) {
            echo 'class: ' . $Class->getName() . "\n";
            $defined_methods = array('public' => array(), 'protected' => array(), 'private' => array());
            foreach ($Class->getMethods() as $Method) {
                $name = $Method->getName();
                $visibility = $Method->getVisibility();
                if ($visibility == 'public' && $name[0] == '_' && !in_array($name, array('__construct', '__destruct', '__call', '__get', '__set'))) {
                    $visibility = 'protected';
                    $content = $Method->toString(4, null, array('visibility' => 'protected'));
                } else {
                    if ($name[0] != '_' && $visibility != 'public') {
                        $name = ltrim($name, '_');
                        $content = $Method->toString(4, $name);
                    } else {
                        $content = $Method->toString(4);