You are here

private function PhpParser::getFileContent in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php \Doctrine\Common\Annotations\PhpParser::getFileContent()

Gets the content of the file right up to the given line number.

Parameters

string $filename The name of the file to load.:

integer $lineNumber The number of lines to read from file.:

Return value

string The content of the file.

1 call to PhpParser::getFileContent()
PhpParser::parseClass in vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php
Parses a class.

File

vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php, line 72

Class

PhpParser
Parses a file for namespaces/use/class declarations.

Namespace

Doctrine\Common\Annotations

Code

private function getFileContent($filename, $lineNumber) {
  if (!is_file($filename)) {
    return null;
  }
  $content = '';
  $lineCnt = 0;
  $file = new SplFileObject($filename);
  while (!$file
    ->eof()) {
    if ($lineCnt++ == $lineNumber) {
      break;
    }
    $content .= $file
      ->fgets();
  }
  return $content;
}