You are here

private function PhpParser::getFileContent in Plug 7

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 lib/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php
Parses a class.

File

lib/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;
}