function Common::realpath
CodeSniffer alternative for realpath.
Allows for PHAR support.
Parameters
string $path The path to use.:
Return value
string|false
14 calls to Common::realpath()
- Cache::load in vendor/
squizlabs/ php_codesniffer/ src/ Util/ Cache.php - Loads existing cache data for the run, if any.
- Config::processFilePath in vendor/
squizlabs/ php_codesniffer/ src/ Config.php - Processes a file path and add it to the file list.
- Config::processLongArgument in vendor/
squizlabs/ php_codesniffer/ src/ Config.php - Processes a long (--example) command-line argument.
- ExactMatch::accept in vendor/
squizlabs/ php_codesniffer/ src/ Filters/ ExactMatch.php - Check whether the current element of the iterator is acceptable.
- Filter::accept in vendor/
squizlabs/ php_codesniffer/ src/ Filters/ Filter.php - Check whether the current element of the iterator is acceptable.
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Util/ Common.php, line 91
Class
Namespace
PHP_CodeSniffer\UtilCode
public static function realpath($path) {
// Support the path replacement of ~ with the user's home directory.
if (substr($path, 0, 2) === '~/') {
$homeDir = getenv('HOME');
if ($homeDir !== false) {
$path = $homeDir . substr($path, 1);
}
}
// Check for process substitution.
if (strpos($path, '/dev/fd') === 0) {
return str_replace('/dev/fd', 'php://fd', $path);
}
// No extra work needed if this is not a phar file.
if (self::isPharFile($path) === false) {
return realpath($path);
}
// Before trying to break down the file path,
// check if it exists first because it will mostly not
// change after running the below code.
if (file_exists($path) === true) {
return $path;
}
$phar = Phar::running(false);
$extra = str_replace('phar://' . $phar, '', $path);
$path = realpath($phar);
if ($path === false) {
return false;
}
$path = 'phar://' . $path . $extra;
if (file_exists($path) === true) {
return $path;
}
return false;
}