Beispiel #1
0
 /**
  * Detect the stub and set it in the pharchive instance.
  *
  * @return void
  *
  * @throws \RuntimeException When the stub is invalid.
  */
 private function detectStub()
 {
     $buffer = '';
     do {
         if ('' === ($chunk = $this->file->read(1024, true))) {
             throw new \RuntimeException('Could not detect the stub\'s end in the phar');
         }
         $buffer .= $chunk;
         unset($chunk);
     } while (!preg_match('{__HALT_COMPILER\\(\\);(?: \\?>)?\\r?\\n}', $buffer, $match, PREG_OFFSET_CAPTURE));
     // detect manifest offset / end of stub
     $stubEnd = $match[0][1] + strlen($match[0][0]);
     $this->file->seek($stubEnd);
     $this->phar->setStub(substr($buffer, 0, $stubEnd));
 }