Inheritance: implements Go\Instrument\Transformer\SourceTransformer
示例#1
0
 /**
  * Autoload a class by it's name
  */
 public function loadClass($class)
 {
     if ($file = $this->original->findFile($class)) {
         $isInternal = false;
         foreach ($this->internalNamespaces as $ns) {
             if (strpos($class, $ns) === 0) {
                 $isInternal = true;
                 break;
             }
         }
         include $isInternal ? $file : FilterInjectorTransformer::rewrite($file);
     }
 }
 /**
  * Autoload a class by it's name
  */
 public function loadClass($class)
 {
     if ($file = $this->findFile($class)) {
         $isAop = false;
         foreach ($this->aopNamespaces as $ns) {
             if (strpos($class, $ns) === 0) {
                 $isAop = true;
                 break;
             }
         }
         include !$isAop ? $file : FilterInjectorTransformer::rewrite($file);
     }
 }
示例#3
0
 /**
  * Attempt to load the given class.
  *
  * @param string $className
  * @return void
  */
 public function loadClass($className)
 {
     // Don't do anything if we haven't initialized the aspect kernel yet.
     if (!Danslo_Aop_Model_Observer::$initialized) {
         return;
     }
     // Don't process classes that are part of the test suite.
     // The reason for this is that phpunit and doctrine (used by Go! AOP)
     // annotation checks interfere with eachother.
     // Let's assume we don't want to use AOP for the testcase classes ;)
     if ($this->_isTestClass($className)) {
         return;
     }
     $classFile = stream_resolve_include_path($this->_getClassFile($className));
     if (file_exists($classFile)) {
         include FilterInjectorTransformer::rewrite($classFile);
     }
 }
示例#4
0
<?php

use Go\Instrument\Transformer\FilterInjectorTransformer;
// Load the composer autoloader
include __DIR__ . '/../vendor/autoload.php';
// Load AOP kernel
include __DIR__ . '/aspect.php';
// change the following paths if necessary
$yii = dirname(__FILE__) . '/../vendor/yiisoft/yii/framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG', true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
require_once FilterInjectorTransformer::rewrite($yii);
Yii::createWebApplication($config)->run();
示例#5
0
 /**
  * Includes file and injects aspect pointcuts into int
  *
  * @param $file
  */
 public function loadFile($file)
 {
     include FilterInjectorTransformer::rewrite($file);
 }
 public function testCanTransformWithBraces()
 {
     $this->metadata->source = file_get_contents(__DIR__ . '/_files/yii_style.php');
     self::$transformer->transform($this->metadata);
     $this->assertEquals(file_get_contents(__DIR__ . '/_files/yii_style_output.php'), $this->metadata->source);
 }
示例#7
0
 /**
  * {@inheritDoc}
  */
 public function findFile($class)
 {
     static $isAllowedFilter = null, $isProduction = false;
     if (!$isAllowedFilter) {
         $isAllowedFilter = $this->fileEnumerator->getFilter();
         $isProduction = !$this->options['debug'];
     }
     $file = $this->original->findFile($class);
     if ($file) {
         $cacheState = isset($this->cacheState[$file]) ? $this->cacheState[$file] : null;
         if ($cacheState && $isProduction) {
             $file = $cacheState['cacheUri'] ?: $file;
         } elseif ($isAllowedFilter(new \SplFileInfo($file))) {
             // can be optimized here with $cacheState even for debug mode, but no needed right now
             $file = FilterInjectorTransformer::rewrite($file);
         }
     }
     return $file;
 }
 /**
  * Load source file with transformation
  *
  * @param string $source Original source name
  *
  * @return mixed
  */
 public function load($source)
 {
     return include FilterInjectorTransformer::rewrite($source);
 }
示例#9
0
<?php

include \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($class->method('filename'), __DIR__);
include_once \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($class->method('filename'), __DIR__);
require \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($class->method('filename'), __DIR__);
require_once \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($class->method('filename'), __DIR__);
$y = $z ? include \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($x, __DIR__) : $v;
include \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($z ? $x : $y, __DIR__);
$app->bindInstallPaths(require \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite(__DIR__ . '/paths.php', __DIR__));
示例#10
0
<?php

// autoload.php
spl_autoload_extensions('.class.php');
spl_autoload_register(function ($class) {
    $classesDir = dirname(__FILE__) . "/src/";
    $filePath = "{$classesDir}/{$class}.php";
    if (is_file($filePath)) {
        return require \Go\Instrument\Transformer\FilterInjectorTransformer::rewrite($filePath, __DIR__);
    }
});