// explicit configFile option
if (isset($config['configFile'])) {
$this->configFile = $config['configFile'];
- } elseif ($configFile = getenv('PSYSH_CONFIG')) {
+ } elseif ($configFile = \getenv('PSYSH_CONFIG')) {
$this->configFile = $configFile;
}
public function init()
{
// feature detection
- $this->hasReadline = function_exists('readline');
- $this->hasPcntl = function_exists('pcntl_signal') && function_exists('posix_getpid');
+ $this->hasReadline = \function_exists('readline');
+ $this->hasPcntl = \function_exists('pcntl_signal') && \function_exists('posix_getpid');
if ($configFile = $this->getConfigFile()) {
$this->loadConfigFile($configFile);
$files = ConfigPaths::getConfigFiles(['config.php', 'rc.php'], $this->configDir);
if (!empty($files)) {
- if ($this->warnOnMultipleConfigs && count($files) > 1) {
- $msg = sprintf('Multiple configuration files found: %s. Using %s', implode($files, ', '), $files[0]);
- trigger_error($msg, E_USER_NOTICE);
+ if ($this->warnOnMultipleConfigs && \count($files) > 1) {
+ $msg = \sprintf('Multiple configuration files found: %s. Using %s', \implode($files, ', '), $files[0]);
+ \trigger_error($msg, E_USER_NOTICE);
}
return $files[0];
*/
public function getLocalConfigFile()
{
- $localConfig = getcwd() . '/.psysh.php';
+ $localConfig = \getcwd() . '/.psysh.php';
- if (@is_file($localConfig)) {
+ if (@\is_file($localConfig)) {
return $localConfig;
}
}
{
foreach (self::$AVAILABLE_OPTIONS as $option) {
if (isset($options[$option])) {
- $method = 'set' . ucfirst($option);
+ $method = 'set' . \ucfirst($option);
$this->$method($options[$option]);
}
}
// legacy `tabCompletion` option
if (isset($options['tabCompletion'])) {
$msg = '`tabCompletion` is deprecated; use `useTabCompletion` instead.';
- @trigger_error($msg, E_USER_DEPRECATED);
+ @\trigger_error($msg, E_USER_DEPRECATED);
$this->setUseTabCompletion($options['tabCompletion']);
}
foreach (['commands', 'matchers', 'casters'] as $option) {
if (isset($options[$option])) {
- $method = 'add' . ucfirst($option);
+ $method = 'add' . \ucfirst($option);
$this->$method($options[$option]);
}
}
// legacy `tabCompletionMatchers` option
if (isset($options['tabCompletionMatchers'])) {
$msg = '`tabCompletionMatchers` is deprecated; use `matchers` instead.';
- @trigger_error($msg, E_USER_DEPRECATED);
+ @\trigger_error($msg, E_USER_DEPRECATED);
$this->addMatchers($options['tabCompletionMatchers']);
}
$result = $load($this);
if (!empty($result)) {
- if (is_array($result)) {
+ if (\is_array($result)) {
$this->loadConfig($result);
} else {
throw new \InvalidArgumentException('Psy Shell configuration must return an array of options');
$this->runtimeDir = ConfigPaths::getRuntimeDir();
}
- if (!is_dir($this->runtimeDir)) {
- mkdir($this->runtimeDir, 0700, true);
+ if (!\is_dir($this->runtimeDir)) {
+ \mkdir($this->runtimeDir, 0700, true);
}
return $this->runtimeDir;
$files = ConfigPaths::getConfigFiles(['psysh_history', 'history'], $this->configDir);
if (!empty($files)) {
- if ($this->warnOnMultipleConfigs && count($files) > 1) {
- $msg = sprintf('Multiple history files found: %s. Using %s', implode($files, ', '), $files[0]);
- trigger_error($msg, E_USER_NOTICE);
+ if ($this->warnOnMultipleConfigs && \count($files) > 1) {
+ $msg = \sprintf('Multiple history files found: %s. Using %s', \implode($files, ', '), $files[0]);
+ \trigger_error($msg, E_USER_NOTICE);
}
$this->setHistoryFile($files[0]);
*/
public function getTempFile($type, $pid)
{
- return tempnam($this->getRuntimeDir(), $type . '_' . $pid . '_');
+ return \tempnam($this->getRuntimeDir(), $type . '_' . $pid . '_');
}
/**
*/
public function getPipe($type, $pid)
{
- return sprintf('%s/%s_%s', $this->getRuntimeDir(), $type, $pid);
+ return \sprintf('%s/%s_%s', $this->getRuntimeDir(), $type, $pid);
}
/**
*/
public function setPager($pager)
{
- if ($pager && !is_string($pager) && !$pager instanceof OutputPager) {
+ if ($pager && !\is_string($pager) && !$pager instanceof OutputPager) {
throw new \InvalidArgumentException('Unexpected pager instance');
}
public function getPager()
{
if (!isset($this->pager) && $this->usePcntl()) {
- if ($pager = ini_get('cli.pager')) {
- // use the default pager (5.4+)
+ if ($pager = \ini_get('cli.pager')) {
+ // use the default pager
$this->pager = $pager;
- } elseif ($less = exec('which less 2>/dev/null')) {
+ } elseif ($less = \exec('which less 2>/dev/null')) {
// check for the presence of less...
$this->pager = $less . ' -R -S -F -X';
}
*/
public function addMatchers(array $matchers)
{
- $this->newMatchers = array_merge($this->newMatchers, $matchers);
+ $this->newMatchers = \array_merge($this->newMatchers, $matchers);
if (isset($this->shell)) {
$this->doAddMatchers();
}
*/
public function addCommands(array $commands)
{
- $this->newCommands = array_merge($this->newCommands, $commands);
+ $this->newCommands = \array_merge($this->newCommands, $commands);
if (isset($this->shell)) {
$this->doAddCommands();
}
$files = ConfigPaths::getDataFiles(['php_manual.sqlite'], $this->dataDir);
if (!empty($files)) {
- if ($this->warnOnMultipleConfigs && count($files) > 1) {
- $msg = sprintf('Multiple manual database files found: %s. Using %s', implode($files, ', '), $files[0]);
- trigger_error($msg, E_USER_NOTICE);
+ if ($this->warnOnMultipleConfigs && \count($files) > 1) {
+ $msg = \sprintf('Multiple manual database files found: %s. Using %s', \implode($files, ', '), $files[0]);
+ \trigger_error($msg, E_USER_NOTICE);
}
return $this->manualDbFile = $files[0];
{
if (!isset($this->manualDb)) {
$dbFile = $this->getManualDbFile();
- if (is_file($dbFile)) {
+ if (\is_file($dbFile)) {
try {
$this->manualDb = new \PDO('sqlite:' . $dbFile);
} catch (\PDOException $e) {
self::COLOR_MODE_DISABLED,
];
- if (in_array($colorMode, $validColorModes)) {
+ if (\in_array($colorMode, $validColorModes)) {
$this->colorMode = $colorMode;
} else {
throw new \InvalidArgumentException('invalid color mode: ' . $colorMode);
Checker::NEVER,
];
- if (!in_array($interval, $validIntervals)) {
+ if (!\in_array($interval, $validIntervals)) {
throw new \InvalidArgumentException('invalid update check interval: ' . $interval);
}