Skip to content

Commit

Permalink
fix php 8.0 issue in exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikuzn committed Feb 18, 2021
1 parent 5f8dc54 commit 207d424
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Exporter.php
Expand Up @@ -138,11 +138,21 @@ public static function getMeta($refobj)
$fname = $refobj->getFileName();
$lines = file_get_contents($fname);
$file = new \SplFileObject($fname);
$file->seek($refobj->getStartLine() - 2);

$start = $refobj->getStartLine() - 2;
$end = $refobj->getEndLine() - 1;

if (version_compare(\PHP_VERSION, '8.0.0') >= 0) {
$start++;
$end++;
}

$file->seek($start);
$spos = $file->ftell();
$file->seek($refobj->getEndLine() - 1);
$file->seek($end);
$epos = $file->ftell();
unset($file);

return array(
'name' => $refobj->getName(),
'code' => substr($lines, $spos, $epos - $spos)
Expand Down

0 comments on commit 207d424

Please sign in to comment.