public static function Project::getCoreVersion in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/DrupalPractice/Project.php \DrupalPractice\Project::getCoreVersion()
- 8.3.x coder_sniffer/DrupalPractice/Project.php \DrupalPractice\Project::getCoreVersion()
Determines the Drupal core version a file might be associated with.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
Return value
string|false The core version string or false if it could not be derived.
7 calls to Project::getCoreVersion()
- DbQuerySniff::processFunctionCall in coder_sniffer/
DrupalPractice/ Sniffs/ FunctionCalls/ DbQuerySniff.php - Processes this function call.
- DisallowLongArraySyntaxSniff::process in coder_sniffer/
Drupal/ Sniffs/ Arrays/ DisallowLongArraySyntaxSniff.php - Processes this test, when one of its tokens is encountered.
- GlobalConstantSniff::process in coder_sniffer/
DrupalPractice/ Sniffs/ Constants/ GlobalConstantSniff.php - Processes this test, when one of its tokens is encountered.
- GlobalDefineSniff::processFunctionCall in coder_sniffer/
DrupalPractice/ Sniffs/ Constants/ GlobalDefineSniff.php - Processes this function call.
- HookInitCssSniff::processFunction in coder_sniffer/
DrupalPractice/ Sniffs/ FunctionDefinitions/ HookInitCssSniff.php - Process this function definition.
File
- coder_sniffer/
DrupalPractice/ Project.php, line 240
Class
- Project
- Helper class to retrieve project information like module/theme name for a file.
Namespace
DrupalPracticeCode
public static function getCoreVersion(File $phpcsFile) {
$infoFile = static::getInfoFile($phpcsFile);
if ($infoFile === false) {
return false;
}
$pathParts = pathinfo($infoFile);
// Drupal 6 and 7 use the .info file extension.
if ($pathParts['extension'] === 'info') {
$info_settings = ClassFilesSniff::drupalParseInfoFormat(file_get_contents($infoFile));
if (isset($info_settings['core']) === true) {
return $info_settings['core'];
}
}
else {
// Drupal 8 uses the .yml file extension.
// @todo Revisit for Drupal 9, but I don't want to do YAML parsing
// for now.
return '8.x';
}
}