This commit is contained in:
2021-03-25 18:05:31 +08:00
parent 3ff158c337
commit 4d331d2765
2 changed files with 37 additions and 3 deletions
+23
View File
@@ -126,6 +126,29 @@ abstract class GiiBase
}
/**
* @param string $fileName
* @param ReflectionClass $class
* @return string
*/
protected function getImports(string $fileName, ReflectionClass $class): string
{
$startLine = 1;
$array = [];
$fileOpen = fopen($fileName, 'r');
while (($content = fgets($fileOpen)) !== false) {
if (str_starts_with($content, 'use ')) {
$array[] = $content;
}
if ($startLine == $class->getStartLine()) {
break;
}
++$startLine;
}
return implode($array);
}
/**
* @param $fields
* @return mixed 返回表主键