/** * Use this if you intend on generating code generation objects based on the same file. * This will keep previous changes to the file in tact during the same PHP process * * @param string $filePath * @param bool $includeIfNotAlreadyIncluded * @throws Exception\InvalidArgumentException * @return FileGenerator */ public static function fromReflectedFileName($filePath, $includeIfNotAlreadyIncluded = true) { $realpath = realpath($filePath); if ($realpath === false && ($realpath = FileReflection::findRealpathInIncludePath($filePath)) === false) { throw new Exception\InvalidArgumentException(sprintf('No file for %s was found.', $realpath)); } if ($includeIfNotAlreadyIncluded && !in_array($realpath, get_included_files())) { include $realpath; } $fileReflector = new FileReflection($realpath); $codeGenerator = static::fromReflection($fileReflector); return $codeGenerator; }