function 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.:
int $lineNumber The number of lines to read from file.:
Return value
string|null The content of the file or null if the file does not exist.
1 call to PhpParser::getFileContent()
- PhpParser::parseUseStatements in vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ PhpParser.php - Parse a class or function for use statements.
File
-
vendor/
doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ PhpParser.php, line 59
Class
- PhpParser
- Parses a file for namespaces/use/class declarations.
Namespace
Doctrine\Common\AnnotationsCode
private function getFileContent(string $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;
}