public function stream_open($path, $mode, $options, &$openedPath)
 {
     $this->deactivateHook();
     $isFileIncluding = (bool) ($options & self::STREAM_OPEN_FOR_INCLUDE);
     if ($isFileIncluding && Engine::shouldProcess($path)) {
         $path = AstSourceFilter::getTransformedSourcePath($path);
         // todo: for production mode we should fill $openedPath with cache path to be opcache friendly
     }
     if (isset($this->context)) {
         $this->resource = fopen($path, $mode, $options, $this->context);
     } else {
         $this->resource = fopen($path, $mode, $options);
     }
     $this->activateHook();
     return $this->resource !== false;
 }
示例#2
0
 /**
  * Finds the path to the file where the class is defined.
  *
  * @param string $class The name of the class
  *
  * @return string|false The path if found, false otherwise
  *
  * @see \Composer\Autoload\ClassLoader::findFile
  */
 public function findFile($class)
 {
     $file = $this->original->findFile($class);
     if ($file) {
         $cacheState = isset($this->cacheState[$file]) ? $this->cacheState[$file] : null;
         if ($cacheState && self::$isProductionMode) {
             $file = $cacheState['cacheUri'] ?: $file;
         } elseif (Engine::shouldProcess($file)) {
             // can be optimized here with $cacheState even for debug mode, but no needed right now
             $file = AstSourceFilter::getTransformedSourcePath($file);
         }
     }
     return $file;
 }
示例#3
0
 /**
  * Performs initialization of library
  */
 public static function init()
 {
     self::$lexer = new Lexer();
     self::$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7, self::$lexer);
     self::$traverser = new NodeTraverser();
     self::$printer = new PrettyPrinterStandard();
     AstSourceFilter::register();
 }