Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     while ($streamBucket = stream_bucket_make_writeable($in)) {
         $this->sourceCode .= $streamBucket->data;
     }
     if ($closing || feof($this->stream)) {
         $consumed = strlen($this->sourceCode);
         $processedCode = Engine::parse($this->sourceCode);
         $streamBucket = stream_bucket_new($this->stream, $processedCode);
         stream_bucket_append($out, $streamBucket);
         return PSFS_PASS_ON;
     }
     return PSFS_FEED_ME;
 }
 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;
 }
Esempio n. 3
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;
 }