本文整理匯總了PHP中Phan\Config::projectPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::projectPath方法的具體用法?PHP Config::projectPath怎麽用?PHP Config::projectPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phan\Config
的用法示例。
在下文中一共展示了Config::projectPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: directoryNameToFileList
/**
* @param string $directory_name
* The name of a directory to scan for files ending in `.php`.
*
* @return string[]
* A list of PHP files in the given directory
*/
private function directoryNameToFileList(string $directory_name) : array
{
$file_list = [];
try {
$iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory_name, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS)), '/^.+\\.php$/i', \RecursiveRegexIterator::GET_MATCH);
foreach (array_keys(iterator_to_array($iterator)) as $file_name) {
$file_path = Config::projectPath($file_name);
if (is_file($file_path) && is_readable($file_path)) {
$file_list[] = $file_name;
} else {
error_log("Unable to read file {$file_path}");
}
}
} catch (\Exception $exception) {
error_log($exception->getMessage());
}
return $file_list;
}
示例2: analyzeFile
/**
* Once we know what the universe looks like we
* can scan for more complicated issues.
*
* @param CodeBase $code_base
* The global code base holding all state
*
* @param string $file_path
* A list of files to scan
*
* @return Context
*/
public static function analyzeFile(CodeBase $code_base, string $file_path) : Context
{
// Set the file on the context
$context = (new Context())->withFile($file_path);
// Convert the file to an Abstract Syntax Tree
// before passing it on to the recursive version
// of this method
try {
$node = \ast\parse_file(Config::projectPath($file_path), Config::get()->ast_version);
} catch (\ParseError $parse_error) {
Issue::maybeEmit($code_base, $context, Issue::SyntaxError, $parse_error->getLine(), $parse_error->getMessage());
return $context;
}
// Ensure we have some content
if (empty($node)) {
Issue::maybeEmit($code_base, $context, Issue::EmptyFile, 0, $file_path);
return $context;
}
return (new BlockAnalysisVisitor($code_base, $context))($node);
}