Aggiornato Composer
This commit is contained in:
103
vendor/psy/psysh/src/ConfigPaths.php
vendored
103
vendor/psy/psysh/src/ConfigPaths.php
vendored
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
* This file is part of Psy Shell.
|
||||
*
|
||||
* (c) 2012-2022 Justin Hileman
|
||||
* (c) 2012-2023 Justin Hileman
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
@@ -31,10 +31,11 @@ class ConfigPaths
|
||||
* @param string[] $overrides Directory overrides
|
||||
* @param EnvInterface $env
|
||||
*/
|
||||
public function __construct(array $overrides = [], EnvInterface $env = null)
|
||||
public function __construct(array $overrides = [], ?EnvInterface $env = null)
|
||||
{
|
||||
$this->overrideDirs($overrides);
|
||||
$this->env = $env ?: new SuperglobalsEnv();
|
||||
|
||||
$this->env = $env ?: (\PHP_SAPI === 'cli-server' ? new SystemEnv() : new SuperglobalsEnv());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,32 +120,6 @@ class ConfigPaths
|
||||
return $this->allDirNames(\array_merge([$this->homeConfigDir()], $configDirs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getConfigDirs(): array
|
||||
{
|
||||
return (new self())->configDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get potential home config directory paths.
|
||||
*
|
||||
* Returns `~/.psysh`, `%APPDATA%/PsySH` (when on Windows), and the
|
||||
* XDG Base Directory home config directory:
|
||||
*
|
||||
* http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getHomeConfigDirs(): array
|
||||
{
|
||||
// Not quite the same, but this is deprecated anyway /shrug
|
||||
return self::getConfigDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current home config directory.
|
||||
*
|
||||
@@ -154,8 +129,6 @@ class ConfigPaths
|
||||
* everywhere else).
|
||||
*
|
||||
* @see self::homeConfigDir
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function currentConfigDir(): string
|
||||
{
|
||||
@@ -174,14 +147,6 @@ class ConfigPaths
|
||||
return $configDirs[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getCurrentConfigDir(): string
|
||||
{
|
||||
return (new self())->currentConfigDir();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find real config files in config directories.
|
||||
*
|
||||
@@ -194,14 +159,6 @@ class ConfigPaths
|
||||
return $this->allRealFiles($this->configDirs(), $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getConfigFiles(array $names, $configDir = null): array
|
||||
{
|
||||
return (new self(['configDir' => $configDir]))->configFiles($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get potential data directory paths.
|
||||
*
|
||||
@@ -226,14 +183,6 @@ class ConfigPaths
|
||||
return $this->allDirNames(\array_merge([$homeDataDir], $dataDirs));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getDataDirs(): array
|
||||
{
|
||||
return (new self())->dataDirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find real data files in config directories.
|
||||
*
|
||||
@@ -246,20 +195,10 @@ class ConfigPaths
|
||||
return $this->allRealFiles($this->dataDirs(), $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static function getDataFiles(array $names, $dataDir = null): array
|
||||
{
|
||||
return (new self(['dataDir' => $dataDir]))->dataFiles($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a runtime directory.
|
||||
*
|
||||
* Defaults to `/psysh` inside the system's temp dir.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function runtimeDir(): string
|
||||
{
|
||||
@@ -274,11 +213,37 @@ class ConfigPaths
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Get a list of directories in PATH.
|
||||
*
|
||||
* If $PATH is unset/empty it defaults to '/usr/sbin:/usr/bin:/sbin:/bin'.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getRuntimeDir(): string
|
||||
public function pathDirs(): array
|
||||
{
|
||||
return (new self())->runtimeDir();
|
||||
return $this->getEnvArray('PATH') ?: ['/usr/sbin', '/usr/bin', '/sbin', '/bin'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate a command (an executable) in $PATH.
|
||||
*
|
||||
* Behaves like 'command -v COMMAND' or 'which COMMAND'.
|
||||
* If $PATH is unset/empty it defaults to '/usr/sbin:/usr/bin:/sbin:/bin'.
|
||||
*
|
||||
* @param string $command the executable to locate
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function which($command)
|
||||
{
|
||||
foreach ($this->pathDirs() as $path) {
|
||||
$fullpath = $path.\DIRECTORY_SEPARATOR.$command;
|
||||
if (@\is_file($fullpath) && @\is_executable($fullpath)) {
|
||||
return $fullpath;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -405,7 +370,7 @@ class ConfigPaths
|
||||
private function getEnvArray($key)
|
||||
{
|
||||
if ($value = $this->getEnv($key)) {
|
||||
return \explode(':', $value);
|
||||
return \explode(\PATH_SEPARATOR, $value);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user