mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-25 12:19:11 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -68,10 +68,10 @@ HELP
|
||||
*/
|
||||
protected function formatLines(array $lines, $type = 'return')
|
||||
{
|
||||
$template = sprintf('<%s>%%s</%s>', $type, $type);
|
||||
$template = \sprintf('<%s>%%s</%s>', $type, $type);
|
||||
|
||||
return array_map(function ($line) use ($template) {
|
||||
return sprintf($template, $line);
|
||||
return \array_map(function ($line) use ($template) {
|
||||
return \sprintf($template, $line);
|
||||
}, $lines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,6 @@ HELP
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->write(sprintf('%c[2J%c[0;0f', 27, 27));
|
||||
$output->write(\sprintf('%c[2J%c[0;0f', 27, 27));
|
||||
}
|
||||
}
|
||||
|
||||
54
vendor/psy/psysh/src/Command/Command.php
vendored
54
vendor/psy/psysh/src/Command/Command.php
vendored
@@ -65,10 +65,10 @@ abstract class Command extends BaseCommand
|
||||
|
||||
if ($help = $this->getProcessedHelp()) {
|
||||
$messages[] = '<comment>Help:</comment>';
|
||||
$messages[] = ' ' . str_replace("\n", "\n ", $help) . "\n";
|
||||
$messages[] = ' ' . \str_replace("\n", "\n ", $help) . "\n";
|
||||
}
|
||||
|
||||
return implode("\n", $messages);
|
||||
return \implode("\n", $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,8 +78,8 @@ abstract class Command extends BaseCommand
|
||||
{
|
||||
$hidden = $this->getHiddenArguments();
|
||||
|
||||
return array_filter($this->getNativeDefinition()->getArguments(), function ($argument) use ($hidden) {
|
||||
return !in_array($argument->getName(), $hidden);
|
||||
return \array_filter($this->getNativeDefinition()->getArguments(), function ($argument) use ($hidden) {
|
||||
return !\in_array($argument->getName(), $hidden);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ abstract class Command extends BaseCommand
|
||||
{
|
||||
$hidden = $this->getHiddenOptions();
|
||||
|
||||
return array_filter($this->getNativeDefinition()->getOptions(), function ($option) use ($hidden) {
|
||||
return !in_array($option->getName(), $hidden);
|
||||
return \array_filter($this->getNativeDefinition()->getOptions(), function ($option) use ($hidden) {
|
||||
return !\in_array($option->getName(), $hidden);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ abstract class Command extends BaseCommand
|
||||
*/
|
||||
private function aliasesAsText()
|
||||
{
|
||||
return '<comment>Aliases:</comment> <info>' . implode(', ', $this->getAliases()) . '</info>' . PHP_EOL;
|
||||
return '<comment>Aliases:</comment> <info>' . \implode(', ', $this->getAliases()) . '</info>' . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,21 +139,21 @@ abstract class Command extends BaseCommand
|
||||
if (!empty($arguments)) {
|
||||
$messages[] = '<comment>Arguments:</comment>';
|
||||
foreach ($arguments as $argument) {
|
||||
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
|
||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));
|
||||
if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
|
||||
$default = \sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($argument->getDefault()));
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
|
||||
$description = str_replace("\n", "\n" . str_pad('', $max + 2, ' '), $argument->getDescription());
|
||||
$description = \str_replace("\n", "\n" . \str_pad('', $max + 2, ' '), $argument->getDescription());
|
||||
|
||||
$messages[] = sprintf(" <info>%-${max}s</info> %s%s", $argument->getName(), $description, $default);
|
||||
$messages[] = \sprintf(" <info>%-${max}s</info> %s%s", $argument->getName(), $description, $default);
|
||||
}
|
||||
|
||||
$messages[] = '';
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $messages);
|
||||
return \implode(PHP_EOL, $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,20 +171,20 @@ abstract class Command extends BaseCommand
|
||||
$messages[] = '<comment>Options:</comment>';
|
||||
|
||||
foreach ($options as $option) {
|
||||
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
|
||||
$default = sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault()));
|
||||
if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
|
||||
$default = \sprintf('<comment> (default: %s)</comment>', $this->formatDefaultValue($option->getDefault()));
|
||||
} else {
|
||||
$default = '';
|
||||
}
|
||||
|
||||
$multiple = $option->isArray() ? '<comment> (multiple values allowed)</comment>' : '';
|
||||
$description = str_replace("\n", "\n" . str_pad('', $max + 2, ' '), $option->getDescription());
|
||||
$description = \str_replace("\n", "\n" . \str_pad('', $max + 2, ' '), $option->getDescription());
|
||||
|
||||
$optionMax = $max - strlen($option->getName()) - 2;
|
||||
$messages[] = sprintf(
|
||||
$optionMax = $max - \strlen($option->getName()) - 2;
|
||||
$messages[] = \sprintf(
|
||||
" <info>%s</info> %-${optionMax}s%s%s%s",
|
||||
'--' . $option->getName(),
|
||||
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',
|
||||
$option->getShortcut() ? \sprintf('(-%s) ', $option->getShortcut()) : '',
|
||||
$description,
|
||||
$default,
|
||||
$multiple
|
||||
@@ -194,7 +194,7 @@ abstract class Command extends BaseCommand
|
||||
$messages[] = '';
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $messages);
|
||||
return \implode(PHP_EOL, $messages);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,16 +207,16 @@ abstract class Command extends BaseCommand
|
||||
$max = 0;
|
||||
|
||||
foreach ($this->getOptions() as $option) {
|
||||
$nameLength = strlen($option->getName()) + 2;
|
||||
$nameLength = \strlen($option->getName()) + 2;
|
||||
if ($option->getShortcut()) {
|
||||
$nameLength += strlen($option->getShortcut()) + 3;
|
||||
$nameLength += \strlen($option->getShortcut()) + 3;
|
||||
}
|
||||
|
||||
$max = max($max, $nameLength);
|
||||
$max = \max($max, $nameLength);
|
||||
}
|
||||
|
||||
foreach ($this->getArguments() as $argument) {
|
||||
$max = max($max, strlen($argument->getName()));
|
||||
$max = \max($max, \strlen($argument->getName()));
|
||||
}
|
||||
|
||||
return ++$max;
|
||||
@@ -231,11 +231,11 @@ abstract class Command extends BaseCommand
|
||||
*/
|
||||
private function formatDefaultValue($default)
|
||||
{
|
||||
if (is_array($default) && $default === array_values($default)) {
|
||||
return sprintf("array('%s')", implode("', '", $default));
|
||||
if (\is_array($default) && $default === \array_values($default)) {
|
||||
return \sprintf("array('%s')", \implode("', '", $default));
|
||||
}
|
||||
|
||||
return str_replace("\n", '', var_export($default, true));
|
||||
return \str_replace("\n", '', \var_export($default, true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,7 +247,7 @@ abstract class Command extends BaseCommand
|
||||
*/
|
||||
protected function getTable(OutputInterface $output)
|
||||
{
|
||||
if (!class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
if (!\class_exists('Symfony\Component\Console\Helper\Table')) {
|
||||
return $this->getTableHelper();
|
||||
}
|
||||
|
||||
|
||||
5
vendor/psy/psysh/src/Command/DocCommand.php
vendored
5
vendor/psy/psysh/src/Command/DocCommand.php
vendored
@@ -14,7 +14,6 @@ namespace Psy\Command;
|
||||
use Psy\Formatter\DocblockFormatter;
|
||||
use Psy\Formatter\SignatureFormatter;
|
||||
use Psy\Input\CodeArgument;
|
||||
use Psy\Reflection\ReflectionClassConstant;
|
||||
use Psy\Reflection\ReflectionLanguageConstruct;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -87,7 +86,7 @@ HELP
|
||||
|
||||
private function getManualDoc($reflector)
|
||||
{
|
||||
switch (get_class($reflector)) {
|
||||
switch (\get_class($reflector)) {
|
||||
case 'ReflectionClass':
|
||||
case 'ReflectionObject':
|
||||
case 'ReflectionFunction':
|
||||
@@ -125,7 +124,7 @@ HELP
|
||||
{
|
||||
if ($db = $this->getApplication()->getManualDb()) {
|
||||
return $db
|
||||
->query(sprintf('SELECT doc FROM php_manual WHERE id = %s', $db->quote($id)))
|
||||
->query(\sprintf('SELECT doc FROM php_manual WHERE id = %s', $db->quote($id)))
|
||||
->fetchColumn(0);
|
||||
}
|
||||
}
|
||||
|
||||
4
vendor/psy/psysh/src/Command/DumpCommand.php
vendored
4
vendor/psy/psysh/src/Command/DumpCommand.php
vendored
@@ -73,7 +73,7 @@ HELP
|
||||
$target = $this->resolveCode($input->getArgument('target'));
|
||||
$output->page($this->presenter->present($target, $depth, $input->getOption('all') ? Presenter::VERBOSE : 0));
|
||||
|
||||
if (is_object($target)) {
|
||||
if (\is_object($target)) {
|
||||
$this->setCommandScopeVariables(new \ReflectionObject($target));
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ HELP
|
||||
*/
|
||||
protected function resolveTarget($name)
|
||||
{
|
||||
@trigger_error('`resolveTarget` is deprecated; use `resolveCode` instead.', E_USER_DEPRECATED);
|
||||
@\trigger_error('`resolveTarget` is deprecated; use `resolveCode` instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->resolveCode($name);
|
||||
}
|
||||
|
||||
16
vendor/psy/psysh/src/Command/EditCommand.php
vendored
16
vendor/psy/psysh/src/Command/EditCommand.php
vendored
@@ -95,7 +95,7 @@ class EditCommand extends Command implements ContextAware
|
||||
$shouldRemoveFile = false;
|
||||
|
||||
if ($filePath === null) {
|
||||
$filePath = tempnam($this->runtimeDir, 'psysh-edit-command');
|
||||
$filePath = \tempnam($this->runtimeDir, 'psysh-edit-command');
|
||||
$shouldRemoveFile = true;
|
||||
}
|
||||
|
||||
@@ -138,9 +138,9 @@ class EditCommand extends Command implements ContextAware
|
||||
{
|
||||
// If the file argument was a variable, get it from the context
|
||||
if ($fileArgument !== null &&
|
||||
strlen($fileArgument) > 0 &&
|
||||
\strlen($fileArgument) > 0 &&
|
||||
$fileArgument[0] === '$') {
|
||||
$fileArgument = $this->context->get(preg_replace('/^\$/', '', $fileArgument));
|
||||
$fileArgument = $this->context->get(\preg_replace('/^\$/', '', $fileArgument));
|
||||
}
|
||||
|
||||
return $fileArgument;
|
||||
@@ -156,16 +156,16 @@ class EditCommand extends Command implements ContextAware
|
||||
*/
|
||||
private function editFile($filePath, $shouldRemoveFile)
|
||||
{
|
||||
$escapedFilePath = escapeshellarg($filePath);
|
||||
$escapedFilePath = \escapeshellarg($filePath);
|
||||
|
||||
$pipes = [];
|
||||
$proc = proc_open((getenv('EDITOR') ?: 'nano') . " {$escapedFilePath}", [STDIN, STDOUT, STDERR], $pipes);
|
||||
proc_close($proc);
|
||||
$proc = \proc_open((\getenv('EDITOR') ?: 'nano') . " {$escapedFilePath}", [STDIN, STDOUT, STDERR], $pipes);
|
||||
\proc_close($proc);
|
||||
|
||||
$editedContent = @file_get_contents($filePath);
|
||||
$editedContent = @\file_get_contents($filePath);
|
||||
|
||||
if ($shouldRemoveFile) {
|
||||
@unlink($filePath);
|
||||
@\unlink($filePath);
|
||||
}
|
||||
|
||||
if ($editedContent === false) {
|
||||
|
||||
4
vendor/psy/psysh/src/Command/HelpCommand.php
vendored
4
vendor/psy/psysh/src/Command/HelpCommand.php
vendored
@@ -74,13 +74,13 @@ class HelpCommand extends Command
|
||||
}
|
||||
|
||||
if ($command->getAliases()) {
|
||||
$aliases = sprintf('<comment>Aliases:</comment> %s', implode(', ', $command->getAliases()));
|
||||
$aliases = \sprintf('<comment>Aliases:</comment> %s', \implode(', ', $command->getAliases()));
|
||||
} else {
|
||||
$aliases = '';
|
||||
}
|
||||
|
||||
$table->addRow([
|
||||
sprintf('<info>%s</info>', $name),
|
||||
\sprintf('<info>%s</info>', $name),
|
||||
$command->getDescription(),
|
||||
$aliases,
|
||||
]);
|
||||
|
||||
40
vendor/psy/psysh/src/Command/HistoryCommand.php
vendored
40
vendor/psy/psysh/src/Command/HistoryCommand.php
vendored
@@ -110,11 +110,11 @@ HELP
|
||||
foreach ($history as $i => $line) {
|
||||
if ($this->filter->match($line, $matches)) {
|
||||
if (isset($matches[0])) {
|
||||
$chunks = explode($matches[0], $history[$i]);
|
||||
$chunks = array_map([__CLASS__, 'escape'], $chunks);
|
||||
$glue = sprintf('<urgent>%s</urgent>', self::escape($matches[0]));
|
||||
$chunks = \explode($matches[0], $history[$i]);
|
||||
$chunks = \array_map([__CLASS__, 'escape'], $chunks);
|
||||
$glue = \sprintf('<urgent>%s</urgent>', self::escape($matches[0]));
|
||||
|
||||
$highlighted[$i] = implode($glue, $chunks);
|
||||
$highlighted[$i] = \implode($glue, $chunks);
|
||||
}
|
||||
} else {
|
||||
unset($history[$i]);
|
||||
@@ -123,16 +123,16 @@ HELP
|
||||
}
|
||||
|
||||
if ($save = $input->getOption('save')) {
|
||||
$output->writeln(sprintf('Saving history in %s...', $save));
|
||||
file_put_contents($save, implode(PHP_EOL, $history) . PHP_EOL);
|
||||
$output->writeln(\sprintf('Saving history in %s...', $save));
|
||||
\file_put_contents($save, \implode(PHP_EOL, $history) . PHP_EOL);
|
||||
$output->writeln('<info>History saved.</info>');
|
||||
} elseif ($input->getOption('replay')) {
|
||||
if (!($input->getOption('show') || $input->getOption('head') || $input->getOption('tail'))) {
|
||||
throw new \InvalidArgumentException('You must limit history via --head, --tail or --show before replaying');
|
||||
}
|
||||
|
||||
$count = count($history);
|
||||
$output->writeln(sprintf('Replaying %d line%s of history', $count, ($count !== 1) ? 's' : ''));
|
||||
$count = \count($history);
|
||||
$output->writeln(\sprintf('Replaying %d line%s of history', $count, ($count !== 1) ? 's' : ''));
|
||||
$this->getApplication()->addInput($history);
|
||||
} elseif ($input->getOption('clear')) {
|
||||
$this->clearHistory();
|
||||
@@ -156,14 +156,14 @@ HELP
|
||||
*/
|
||||
private function extractRange($range)
|
||||
{
|
||||
if (preg_match('/^\d+$/', $range)) {
|
||||
if (\preg_match('/^\d+$/', $range)) {
|
||||
return [$range, $range + 1];
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if ($range !== '..' && preg_match('/^(\d*)\.\.(\d*)$/', $range, $matches)) {
|
||||
$start = $matches[1] ? intval($matches[1]) : 0;
|
||||
$end = $matches[2] ? intval($matches[2]) + 1 : PHP_INT_MAX;
|
||||
if ($range !== '..' && \preg_match('/^(\d*)\.\.(\d*)$/', $range, $matches)) {
|
||||
$start = $matches[1] ? \intval($matches[1]) : 0;
|
||||
$end = $matches[2] ? \intval($matches[2]) + 1 : PHP_INT_MAX;
|
||||
|
||||
return [$start, $end];
|
||||
}
|
||||
@@ -185,30 +185,30 @@ HELP
|
||||
$history = $this->readline->listHistory();
|
||||
|
||||
// don't show the current `history` invocation
|
||||
array_pop($history);
|
||||
\array_pop($history);
|
||||
|
||||
if ($show) {
|
||||
list($start, $end) = $this->extractRange($show);
|
||||
$length = $end - $start;
|
||||
} elseif ($head) {
|
||||
if (!preg_match('/^\d+$/', $head)) {
|
||||
if (!\preg_match('/^\d+$/', $head)) {
|
||||
throw new \InvalidArgumentException('Please specify an integer argument for --head');
|
||||
}
|
||||
|
||||
$start = 0;
|
||||
$length = intval($head);
|
||||
$length = \intval($head);
|
||||
} elseif ($tail) {
|
||||
if (!preg_match('/^\d+$/', $tail)) {
|
||||
if (!\preg_match('/^\d+$/', $tail)) {
|
||||
throw new \InvalidArgumentException('Please specify an integer argument for --tail');
|
||||
}
|
||||
|
||||
$start = count($history) - $tail;
|
||||
$length = intval($tail) + 1;
|
||||
$start = \count($history) - $tail;
|
||||
$length = \intval($tail) + 1;
|
||||
} else {
|
||||
return $history;
|
||||
}
|
||||
|
||||
return array_slice($history, $start, $length, true);
|
||||
return \array_slice($history, $start, $length, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +227,7 @@ HELP
|
||||
}
|
||||
|
||||
if ($count > 1) {
|
||||
throw new \InvalidArgumentException('Please specify only one of --' . implode(', --', $options));
|
||||
throw new \InvalidArgumentException('Please specify only one of --' . \implode(', --', $options));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
8
vendor/psy/psysh/src/Command/ListCommand.php
vendored
8
vendor/psy/psysh/src/Command/ListCommand.php
vendored
@@ -178,8 +178,8 @@ HELP
|
||||
}
|
||||
|
||||
foreach ($result as $label => $items) {
|
||||
$names = array_map([$this, 'formatItemName'], $items);
|
||||
$output->writeln(sprintf('<strong>%s</strong>: %s', $label, implode(', ', $names)));
|
||||
$names = \array_map([$this, 'formatItemName'], $items);
|
||||
$output->writeln(\sprintf('<strong>%s</strong>: %s', $label, \implode(', ', $names)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ HELP
|
||||
|
||||
foreach ($result as $label => $items) {
|
||||
$output->writeln('');
|
||||
$output->writeln(sprintf('<strong>%s:</strong>', $label));
|
||||
$output->writeln(\sprintf('<strong>%s:</strong>', $label));
|
||||
|
||||
$table->setRows([]);
|
||||
foreach ($items as $item) {
|
||||
@@ -225,7 +225,7 @@ HELP
|
||||
*/
|
||||
private function formatItemName($item)
|
||||
{
|
||||
return sprintf('<%s>%s</%s>', $item['style'], OutputFormatter::escape($item['name']), $item['style']);
|
||||
return \sprintf('<%s>%s</%s>', $item['style'], OutputFormatter::escape($item['name']), $item['style']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ class ClassConstantEnumerator extends Enumerator
|
||||
|
||||
$constants = [];
|
||||
foreach ($reflector->getConstants() as $name => $constant) {
|
||||
$constReflector = ReflectionClassConstant::create($reflector, $name);
|
||||
$constReflector = ReflectionClassConstant::create($reflector->name, $name);
|
||||
|
||||
if ($noInherit && $constReflector->getDeclaringClass()->getName() !== $className) {
|
||||
continue;
|
||||
@@ -77,7 +77,7 @@ class ClassConstantEnumerator extends Enumerator
|
||||
$constants[$name] = $constReflector;
|
||||
}
|
||||
|
||||
ksort($constants, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
\ksort($constants, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
|
||||
return $constants;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ class ClassConstantEnumerator extends Enumerator
|
||||
{
|
||||
if ($reflector->isInterface()) {
|
||||
return 'Interface Constants';
|
||||
} elseif (method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
} elseif (\method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
return 'Trait Constants';
|
||||
} else {
|
||||
return 'Class Constants';
|
||||
|
||||
@@ -43,18 +43,18 @@ class ClassEnumerator extends Enumerator
|
||||
// only list classes, interfaces and traits if we are specifically asked
|
||||
|
||||
if ($input->getOption('classes')) {
|
||||
$ret = array_merge($ret, $this->filterClasses('Classes', get_declared_classes(), $internal, $user));
|
||||
$ret = \array_merge($ret, $this->filterClasses('Classes', \get_declared_classes(), $internal, $user));
|
||||
}
|
||||
|
||||
if ($input->getOption('interfaces')) {
|
||||
$ret = array_merge($ret, $this->filterClasses('Interfaces', get_declared_interfaces(), $internal, $user));
|
||||
$ret = \array_merge($ret, $this->filterClasses('Interfaces', \get_declared_interfaces(), $internal, $user));
|
||||
}
|
||||
|
||||
if ($input->getOption('traits')) {
|
||||
$ret = array_merge($ret, $this->filterClasses('Traits', get_declared_traits(), $internal, $user));
|
||||
$ret = \array_merge($ret, $this->filterClasses('Traits', \get_declared_traits(), $internal, $user));
|
||||
}
|
||||
|
||||
return array_map([$this, 'prepareClasses'], array_filter($ret));
|
||||
return \array_map([$this, 'prepareClasses'], \array_filter($ret));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ class ClassEnumerator extends Enumerator
|
||||
$ret = [];
|
||||
|
||||
if ($internal) {
|
||||
$ret['Internal ' . $key] = array_filter($classes, function ($class) {
|
||||
$ret['Internal ' . $key] = \array_filter($classes, function ($class) {
|
||||
$refl = new \ReflectionClass($class);
|
||||
|
||||
return $refl->isInternal();
|
||||
@@ -83,7 +83,7 @@ class ClassEnumerator extends Enumerator
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$ret['User ' . $key] = array_filter($classes, function ($class) {
|
||||
$ret['User ' . $key] = \array_filter($classes, function ($class) {
|
||||
$refl = new \ReflectionClass($class);
|
||||
|
||||
return !$refl->isInternal();
|
||||
@@ -106,7 +106,7 @@ class ClassEnumerator extends Enumerator
|
||||
*/
|
||||
protected function prepareClasses(array $classes)
|
||||
{
|
||||
natcasesort($classes);
|
||||
\natcasesort($classes);
|
||||
|
||||
// My kingdom for a generator.
|
||||
$ret = [];
|
||||
|
||||
@@ -54,7 +54,7 @@ class ConstantEnumerator extends Enumerator
|
||||
}
|
||||
|
||||
if ($category) {
|
||||
$label = ucfirst($category) . ' Constants';
|
||||
$label = \ucfirst($category) . ' Constants';
|
||||
$ret[$label] = $this->getConstants($category);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class ConstantEnumerator extends Enumerator
|
||||
$ret['Constants'] = $this->getConstants();
|
||||
}
|
||||
|
||||
return array_map([$this, 'prepareConstants'], array_filter($ret));
|
||||
return \array_map([$this, 'prepareConstants'], \array_filter($ret));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,15 +78,15 @@ class ConstantEnumerator extends Enumerator
|
||||
protected function getConstants($category = null)
|
||||
{
|
||||
if (!$category) {
|
||||
return get_defined_constants();
|
||||
return \get_defined_constants();
|
||||
}
|
||||
|
||||
$consts = get_defined_constants(true);
|
||||
$consts = \get_defined_constants(true);
|
||||
|
||||
if ($category === 'internal') {
|
||||
unset($consts['user']);
|
||||
|
||||
return call_user_func_array('array_merge', $consts);
|
||||
return \call_user_func_array('array_merge', $consts);
|
||||
}
|
||||
|
||||
return isset($consts[$category]) ? $consts[$category] : [];
|
||||
@@ -104,8 +104,8 @@ class ConstantEnumerator extends Enumerator
|
||||
// My kingdom for a generator.
|
||||
$ret = [];
|
||||
|
||||
$names = array_keys($constants);
|
||||
natcasesort($names);
|
||||
$names = \array_keys($constants);
|
||||
\natcasesort($names);
|
||||
|
||||
foreach ($names as $name) {
|
||||
if ($this->showItem($name)) {
|
||||
|
||||
@@ -74,12 +74,12 @@ class FunctionEnumerator extends Enumerator
|
||||
*/
|
||||
protected function getFunctions($type = null)
|
||||
{
|
||||
$funcs = get_defined_functions();
|
||||
$funcs = \get_defined_functions();
|
||||
|
||||
if ($type) {
|
||||
return $funcs[$type];
|
||||
} else {
|
||||
return array_merge($funcs['internal'], $funcs['user']);
|
||||
return \array_merge($funcs['internal'], $funcs['user']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ class FunctionEnumerator extends Enumerator
|
||||
*/
|
||||
protected function prepareFunctions(array $functions)
|
||||
{
|
||||
natcasesort($functions);
|
||||
\natcasesort($functions);
|
||||
|
||||
// My kingdom for a generator.
|
||||
$ret = [];
|
||||
|
||||
@@ -53,8 +53,8 @@ class GlobalVariableEnumerator extends Enumerator
|
||||
{
|
||||
global $GLOBALS;
|
||||
|
||||
$names = array_keys($GLOBALS);
|
||||
natcasesort($names);
|
||||
$names = \array_keys($GLOBALS);
|
||||
\natcasesort($names);
|
||||
|
||||
$ret = [];
|
||||
foreach ($names as $name) {
|
||||
|
||||
@@ -23,7 +23,7 @@ class InterfaceEnumerator extends Enumerator
|
||||
{
|
||||
public function __construct(Presenter $presenter)
|
||||
{
|
||||
@trigger_error('InterfaceEnumerator is no longer used', E_USER_DEPRECATED);
|
||||
@\trigger_error('InterfaceEnumerator is no longer used', E_USER_DEPRECATED);
|
||||
parent::__construct($presenter);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class InterfaceEnumerator extends Enumerator
|
||||
return;
|
||||
}
|
||||
|
||||
$interfaces = $this->prepareInterfaces(get_declared_interfaces());
|
||||
$interfaces = $this->prepareInterfaces(\get_declared_interfaces());
|
||||
|
||||
if (empty($interfaces)) {
|
||||
return;
|
||||
@@ -69,7 +69,7 @@ class InterfaceEnumerator extends Enumerator
|
||||
*/
|
||||
protected function prepareInterfaces(array $interfaces)
|
||||
{
|
||||
natcasesort($interfaces);
|
||||
\natcasesort($interfaces);
|
||||
|
||||
// My kingdom for a generator.
|
||||
$ret = [];
|
||||
|
||||
@@ -77,7 +77,7 @@ class MethodEnumerator extends Enumerator
|
||||
}
|
||||
}
|
||||
|
||||
ksort($methods, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
\ksort($methods, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
|
||||
return $methods;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ class MethodEnumerator extends Enumerator
|
||||
{
|
||||
if ($reflector->isInterface()) {
|
||||
return 'Interface Methods';
|
||||
} elseif (method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
} elseif (\method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
return 'Trait Methods';
|
||||
} else {
|
||||
return 'Class Methods';
|
||||
|
||||
@@ -77,7 +77,7 @@ class PropertyEnumerator extends Enumerator
|
||||
}
|
||||
}
|
||||
|
||||
ksort($properties, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
\ksort($properties, SORT_NATURAL | SORT_FLAG_CASE);
|
||||
|
||||
return $properties;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class PropertyEnumerator extends Enumerator
|
||||
{
|
||||
if ($reflector->isInterface()) {
|
||||
return 'Interface Properties';
|
||||
} elseif (method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
} elseif (\method_exists($reflector, 'isTrait') && $reflector->isTrait()) {
|
||||
return 'Trait Properties';
|
||||
} else {
|
||||
return 'Class Properties';
|
||||
@@ -156,11 +156,11 @@ class PropertyEnumerator extends Enumerator
|
||||
{
|
||||
// If $target is a class, trait or interface (try to) get the default
|
||||
// value for the property.
|
||||
if (!is_object($target)) {
|
||||
if (!\is_object($target)) {
|
||||
try {
|
||||
$refl = new \ReflectionClass($target);
|
||||
$props = $refl->getDefaultProperties();
|
||||
if (array_key_exists($property->name, $props)) {
|
||||
if (\array_key_exists($property->name, $props)) {
|
||||
$suffix = $property->isStatic() ? '' : ' <aside>(default)</aside>';
|
||||
|
||||
return $this->presentRef($props[$property->name]) . $suffix;
|
||||
|
||||
@@ -23,7 +23,7 @@ class TraitEnumerator extends Enumerator
|
||||
{
|
||||
public function __construct(Presenter $presenter)
|
||||
{
|
||||
@trigger_error('TraitEnumerator is no longer used', E_USER_DEPRECATED);
|
||||
@\trigger_error('TraitEnumerator is no longer used', E_USER_DEPRECATED);
|
||||
parent::__construct($presenter);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class TraitEnumerator extends Enumerator
|
||||
return;
|
||||
}
|
||||
|
||||
$traits = $this->prepareTraits(get_declared_traits());
|
||||
$traits = $this->prepareTraits(\get_declared_traits());
|
||||
|
||||
if (empty($traits)) {
|
||||
return;
|
||||
@@ -69,7 +69,7 @@ class TraitEnumerator extends Enumerator
|
||||
*/
|
||||
protected function prepareTraits(array $traits)
|
||||
{
|
||||
natcasesort($traits);
|
||||
\natcasesort($traits);
|
||||
|
||||
// My kingdom for a generator.
|
||||
$ret = [];
|
||||
|
||||
@@ -79,9 +79,9 @@ class VariableEnumerator extends Enumerator
|
||||
protected function getVariables($showAll)
|
||||
{
|
||||
$scopeVars = $this->context->getAll();
|
||||
uksort($scopeVars, function ($a, $b) {
|
||||
$aIndex = array_search($a, self::$specialNames);
|
||||
$bIndex = array_search($b, self::$specialNames);
|
||||
\uksort($scopeVars, function ($a, $b) {
|
||||
$aIndex = \array_search($a, self::$specialNames);
|
||||
$bIndex = \array_search($b, self::$specialNames);
|
||||
|
||||
if ($aIndex !== false) {
|
||||
if ($bIndex !== false) {
|
||||
@@ -95,12 +95,12 @@ class VariableEnumerator extends Enumerator
|
||||
return -1;
|
||||
}
|
||||
|
||||
return strnatcasecmp($a, $b);
|
||||
return \strnatcasecmp($a, $b);
|
||||
});
|
||||
|
||||
$ret = [];
|
||||
foreach ($scopeVars as $name => $val) {
|
||||
if (!$showAll && in_array($name, self::$specialNames)) {
|
||||
if (!$showAll && \in_array($name, self::$specialNames)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class VariableEnumerator extends Enumerator
|
||||
$fname = '$' . $name;
|
||||
$ret[$fname] = [
|
||||
'name' => $fname,
|
||||
'style' => in_array($name, self::$specialNames) ? self::IS_PRIVATE : self::IS_PUBLIC,
|
||||
'style' => \in_array($name, self::$specialNames) ? self::IS_PRIVATE : self::IS_PUBLIC,
|
||||
'value' => $this->presentRef($val),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class ParseCommand extends Command implements ContextAware, PresenterAware
|
||||
|
||||
if ($this->parserFactory->hasKindsSupport()) {
|
||||
$msg = 'One of PhpParser\\ParserFactory constants: '
|
||||
. implode(', ', ParserFactory::getPossibleKinds())
|
||||
. \implode(', ', ParserFactory::getPossibleKinds())
|
||||
. " (default is based on current interpreter's version).";
|
||||
$defaultKind = $this->parserFactory->getDefaultKind();
|
||||
|
||||
@@ -128,7 +128,7 @@ HELP
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$code = $input->getArgument('code');
|
||||
if (strpos('<?', $code) === false) {
|
||||
if (\strpos('<?', $code) === false) {
|
||||
$code = '<?php ' . $code;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ HELP
|
||||
try {
|
||||
return $parser->parse($code);
|
||||
} catch (\PhpParser\Error $e) {
|
||||
if (strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ HELP
|
||||
*/
|
||||
private function getParser($kind = null)
|
||||
{
|
||||
if (!array_key_exists($kind, $this->parsers)) {
|
||||
if (!\array_key_exists($kind, $this->parsers)) {
|
||||
$this->parsers[$kind] = $this->parserFactory->createParser($kind);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,19 +56,19 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
*/
|
||||
protected function getTarget($valueName)
|
||||
{
|
||||
$valueName = trim($valueName);
|
||||
$valueName = \trim($valueName);
|
||||
$matches = [];
|
||||
switch (true) {
|
||||
case preg_match(self::CLASS_OR_FUNC, $valueName, $matches):
|
||||
case \preg_match(self::CLASS_OR_FUNC, $valueName, $matches):
|
||||
return [$this->resolveName($matches[0], true), null, 0];
|
||||
|
||||
case preg_match(self::CLASS_MEMBER, $valueName, $matches):
|
||||
case \preg_match(self::CLASS_MEMBER, $valueName, $matches):
|
||||
return [$this->resolveName($matches[1]), $matches[2], Mirror::CONSTANT | Mirror::METHOD];
|
||||
|
||||
case preg_match(self::CLASS_STATIC, $valueName, $matches):
|
||||
case \preg_match(self::CLASS_STATIC, $valueName, $matches):
|
||||
return [$this->resolveName($matches[1]), $matches[2], Mirror::STATIC_PROPERTY | Mirror::PROPERTY];
|
||||
|
||||
case preg_match(self::INSTANCE_MEMBER, $valueName, $matches):
|
||||
case \preg_match(self::INSTANCE_MEMBER, $valueName, $matches):
|
||||
if ($matches[2] === '->') {
|
||||
$kind = Mirror::METHOD | Mirror::PROPERTY;
|
||||
} else {
|
||||
@@ -97,27 +97,27 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
$shell = $this->getApplication();
|
||||
|
||||
// While not *technically* 100% accurate, let's treat `self` and `static` as equivalent.
|
||||
if (in_array(strtolower($name), ['self', 'static'])) {
|
||||
if (\in_array(\strtolower($name), ['self', 'static'])) {
|
||||
if ($boundClass = $shell->getBoundClass()) {
|
||||
return $boundClass;
|
||||
}
|
||||
|
||||
if ($boundObject = $shell->getBoundObject()) {
|
||||
return get_class($boundObject);
|
||||
return \get_class($boundObject);
|
||||
}
|
||||
|
||||
$msg = sprintf('Cannot use "%s" when no class scope is active', strtolower($name));
|
||||
$msg = \sprintf('Cannot use "%s" when no class scope is active', \strtolower($name));
|
||||
throw new ErrorException($msg, 0, E_USER_ERROR, "eval()'d code", 1);
|
||||
}
|
||||
|
||||
if (substr($name, 0, 1) === '\\') {
|
||||
if (\substr($name, 0, 1) === '\\') {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if ($namespace = $shell->getNamespace()) {
|
||||
$fullName = $namespace . '\\' . $name;
|
||||
|
||||
if (class_exists($fullName) || interface_exists($fullName) || ($includeFunctions && function_exists($fullName))) {
|
||||
if (\class_exists($fullName) || \interface_exists($fullName) || ($includeFunctions && \function_exists($fullName))) {
|
||||
return $fullName;
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
{
|
||||
$value = $this->resolveCode($code);
|
||||
|
||||
if (!is_object($value)) {
|
||||
if (!\is_object($value)) {
|
||||
throw new RuntimeException('Unable to inspect a non-object');
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
*/
|
||||
protected function resolveInstance($name)
|
||||
{
|
||||
@trigger_error('`resolveInstance` is deprecated; use `resolveCode` instead.', E_USER_DEPRECATED);
|
||||
@\trigger_error('`resolveInstance` is deprecated; use `resolveCode` instead.', E_USER_DEPRECATED);
|
||||
|
||||
return $this->resolveCode($name);
|
||||
}
|
||||
@@ -230,7 +230,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
{
|
||||
$vars = [];
|
||||
|
||||
switch (get_class($reflector)) {
|
||||
switch (\get_class($reflector)) {
|
||||
case 'ReflectionClass':
|
||||
case 'ReflectionObject':
|
||||
$vars['__class'] = $reflector->name;
|
||||
@@ -240,7 +240,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
break;
|
||||
|
||||
case 'ReflectionMethod':
|
||||
$vars['__method'] = sprintf('%s::%s', $reflector->class, $reflector->name);
|
||||
$vars['__method'] = \sprintf('%s::%s', $reflector->class, $reflector->name);
|
||||
$vars['__class'] = $reflector->class;
|
||||
$classReflector = $reflector->getDeclaringClass();
|
||||
if ($classReflector->inNamespace()) {
|
||||
@@ -264,7 +264,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
if ($fileName = $reflector->getExecutingFile()) {
|
||||
$vars['__file'] = $fileName;
|
||||
$vars['__line'] = $reflector->getExecutingLine();
|
||||
$vars['__dir'] = dirname($fileName);
|
||||
$vars['__dir'] = \dirname($fileName);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -279,7 +279,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
// no line for these, but this'll do
|
||||
if ($fileName = $reflector->getDeclaringClass()->getFileName()) {
|
||||
$vars['__file'] = $fileName;
|
||||
$vars['__dir'] = dirname($fileName);
|
||||
$vars['__dir'] = \dirname($fileName);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -294,7 +294,7 @@ abstract class ReflectingCommand extends Command implements ContextAware
|
||||
if ($fileName = $reflector->getFileName()) {
|
||||
$vars['__file'] = $fileName;
|
||||
$vars['__line'] = $reflector->getStartLine();
|
||||
$vars['__dir'] = dirname($fileName);
|
||||
$vars['__dir'] = \dirname($fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
vendor/psy/psysh/src/Command/ShowCommand.php
vendored
26
vendor/psy/psysh/src/Command/ShowCommand.php
vendored
@@ -140,16 +140,16 @@ HELP
|
||||
$index = 0;
|
||||
}
|
||||
} else {
|
||||
$index = max(0, intval($input->getOption('ex')) - 1);
|
||||
$index = \max(0, \intval($input->getOption('ex')) - 1);
|
||||
}
|
||||
|
||||
$trace = $exception->getTrace();
|
||||
array_unshift($trace, [
|
||||
\array_unshift($trace, [
|
||||
'file' => $exception->getFile(),
|
||||
'line' => $exception->getLine(),
|
||||
]);
|
||||
|
||||
if ($index >= count($trace)) {
|
||||
if ($index >= \count($trace)) {
|
||||
$index = 0;
|
||||
}
|
||||
|
||||
@@ -169,25 +169,25 @@ HELP
|
||||
$file = isset($trace[$index]['file']) ? $this->replaceCwd($trace[$index]['file']) : 'n/a';
|
||||
$line = isset($trace[$index]['line']) ? $trace[$index]['line'] : 'n/a';
|
||||
|
||||
$output->writeln(sprintf(
|
||||
$output->writeln(\sprintf(
|
||||
'From <info>%s:%d</info> at <strong>level %d</strong> of backtrace (of %d).',
|
||||
OutputFormatter::escape($file),
|
||||
OutputFormatter::escape($line),
|
||||
$index + 1,
|
||||
count($trace)
|
||||
\count($trace)
|
||||
));
|
||||
}
|
||||
|
||||
private function replaceCwd($file)
|
||||
{
|
||||
if ($cwd = getcwd()) {
|
||||
$cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
if ($cwd = \getcwd()) {
|
||||
$cwd = \rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if ($cwd === false) {
|
||||
return $file;
|
||||
} else {
|
||||
return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file);
|
||||
return \preg_replace('/^' . \preg_quote($cwd, '/') . '/', '', $file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ HELP
|
||||
$line = $trace[$index]['line'];
|
||||
}
|
||||
|
||||
if (is_file($file)) {
|
||||
$code = @file_get_contents($file);
|
||||
if (\is_file($file)) {
|
||||
$code = @\file_get_contents($file);
|
||||
}
|
||||
|
||||
if (empty($code)) {
|
||||
@@ -268,12 +268,12 @@ HELP
|
||||
$line = $context['line'];
|
||||
}
|
||||
|
||||
if (is_file($file)) {
|
||||
if (\is_file($file)) {
|
||||
$vars['__file'] = $file;
|
||||
if (isset($line)) {
|
||||
$vars['__line'] = $line;
|
||||
}
|
||||
$vars['__dir'] = dirname($file);
|
||||
$vars['__dir'] = \dirname($file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ HELP
|
||||
|
||||
private function extractEvalFileAndLine($file)
|
||||
{
|
||||
if (preg_match('/(.*)\\((\\d+)\\) : eval\\(\\)\'d code$/', $file, $matches)) {
|
||||
if (\preg_match('/(.*)\\((\\d+)\\) : eval\\(\\)\'d code$/', $file, $matches)) {
|
||||
return [$matches[1], $matches[2]];
|
||||
}
|
||||
}
|
||||
|
||||
8
vendor/psy/psysh/src/Command/SudoCommand.php
vendored
8
vendor/psy/psysh/src/Command/SudoCommand.php
vendored
@@ -103,13 +103,13 @@ HELP
|
||||
// special case for !!
|
||||
if ($code === '!!') {
|
||||
$history = $this->readline->listHistory();
|
||||
if (count($history) < 2) {
|
||||
if (\count($history) < 2) {
|
||||
throw new \InvalidArgumentException('No previous command to replay');
|
||||
}
|
||||
$code = $history[count($history) - 2];
|
||||
$code = $history[\count($history) - 2];
|
||||
}
|
||||
|
||||
if (strpos('<?', $code) === false) {
|
||||
if (\strpos('<?', $code) === false) {
|
||||
$code = '<?php ' . $code;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ HELP
|
||||
try {
|
||||
return $this->parser->parse($code);
|
||||
} catch (\PhpParser\Error $e) {
|
||||
if (strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,12 +125,12 @@ HELP
|
||||
return [new Arg(new Variable('_e'))];
|
||||
}
|
||||
|
||||
if (strpos('<?', $code) === false) {
|
||||
if (\strpos('<?', $code) === false) {
|
||||
$code = '<?php ' . $code;
|
||||
}
|
||||
|
||||
$nodes = $this->parse($code);
|
||||
if (count($nodes) !== 1) {
|
||||
if (\count($nodes) !== 1) {
|
||||
throw new \InvalidArgumentException('No idea how to throw this');
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ HELP
|
||||
try {
|
||||
return $this->parser->parse($code);
|
||||
} catch (\PhpParser\Error $e) {
|
||||
if (strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
17
vendor/psy/psysh/src/Command/TimeitCommand.php
vendored
17
vendor/psy/psysh/src/Command/TimeitCommand.php
vendored
@@ -16,7 +16,6 @@ use PhpParser\PrettyPrinter\Standard as Printer;
|
||||
use Psy\Command\TimeitCommand\TimeitVisitor;
|
||||
use Psy\Input\CodeArgument;
|
||||
use Psy\ParserFactory;
|
||||
use Psy\Shell;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -99,13 +98,13 @@ HELP
|
||||
self::$times = [];
|
||||
|
||||
if ($num === 1) {
|
||||
$output->writeln(sprintf(self::RESULT_MSG, $times[0]));
|
||||
$output->writeln(\sprintf(self::RESULT_MSG, $times[0]));
|
||||
} else {
|
||||
$total = array_sum($times);
|
||||
rsort($times);
|
||||
$median = $times[round($num / 2)];
|
||||
$total = \array_sum($times);
|
||||
\rsort($times);
|
||||
$median = $times[\round($num / 2)];
|
||||
|
||||
$output->writeln(sprintf(self::AVG_RESULT_MSG, $total / $num, $median, $total));
|
||||
$output->writeln(\sprintf(self::AVG_RESULT_MSG, $total / $num, $median, $total));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +117,7 @@ HELP
|
||||
*/
|
||||
public static function markStart()
|
||||
{
|
||||
self::$start = microtime(true);
|
||||
self::$start = \microtime(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +136,7 @@ HELP
|
||||
*/
|
||||
public static function markEnd($ret = null)
|
||||
{
|
||||
self::$times[] = microtime(true) - self::$start;
|
||||
self::$times[] = \microtime(true) - self::$start;
|
||||
self::$start = null;
|
||||
|
||||
return $ret;
|
||||
@@ -185,7 +184,7 @@ HELP
|
||||
try {
|
||||
return $this->parser->parse($code);
|
||||
} catch (\PhpParser\Error $e) {
|
||||
if (strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
if (\strpos($e->getMessage(), 'unexpected EOF') === false) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,15 +75,15 @@ class TimeitVisitor extends NodeVisitorAbstract
|
||||
public function afterTraverse(array $nodes)
|
||||
{
|
||||
// prepend a `markStart` call
|
||||
array_unshift($nodes, $this->maybeExpression($this->getStartCall()));
|
||||
\array_unshift($nodes, $this->maybeExpression($this->getStartCall()));
|
||||
|
||||
// append a `markEnd` call (wrapping the final node, if it's an expression)
|
||||
$last = $nodes[count($nodes) - 1];
|
||||
$last = $nodes[\count($nodes) - 1];
|
||||
if ($last instanceof Expr) {
|
||||
array_pop($nodes);
|
||||
\array_pop($nodes);
|
||||
$nodes[] = $this->getEndCall($last);
|
||||
} elseif ($last instanceof Expression) {
|
||||
array_pop($nodes);
|
||||
\array_pop($nodes);
|
||||
$nodes[] = new Expression($this->getEndCall($last->expr), $last->getAttributes());
|
||||
} elseif ($last instanceof Return_) {
|
||||
// nothing to do here, we're already ending with a return call
|
||||
@@ -134,6 +134,6 @@ class TimeitVisitor extends NodeVisitorAbstract
|
||||
*/
|
||||
private function maybeExpression($expr, $attrs = [])
|
||||
{
|
||||
return class_exists('PhpParser\Node\Stmt\Expression') ? new Expression($expr, $attrs) : $expr;
|
||||
return \class_exists('PhpParser\Node\Stmt\Expression') ? new Expression($expr, $attrs) : $expr;
|
||||
}
|
||||
}
|
||||
|
||||
22
vendor/psy/psysh/src/Command/TraceCommand.php
vendored
22
vendor/psy/psysh/src/Command/TraceCommand.php
vendored
@@ -90,8 +90,8 @@ HELP
|
||||
*/
|
||||
protected function getBacktrace(\Exception $e, $count = null, $includePsy = true)
|
||||
{
|
||||
if ($cwd = getcwd()) {
|
||||
$cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
if ($cwd = \getcwd()) {
|
||||
$cwd = \rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if ($count === null) {
|
||||
@@ -101,7 +101,7 @@ HELP
|
||||
$lines = [];
|
||||
|
||||
$trace = $e->getTrace();
|
||||
array_unshift($trace, [
|
||||
\array_unshift($trace, [
|
||||
'function' => '',
|
||||
'file' => $e->getFile() !== null ? $e->getFile() : 'n/a',
|
||||
'line' => $e->getLine() !== null ? $e->getLine() : 'n/a',
|
||||
@@ -109,16 +109,16 @@ HELP
|
||||
]);
|
||||
|
||||
if (!$includePsy) {
|
||||
for ($i = count($trace) - 1; $i >= 0; $i--) {
|
||||
for ($i = \count($trace) - 1; $i >= 0; $i--) {
|
||||
$thing = isset($trace[$i]['class']) ? $trace[$i]['class'] : $trace[$i]['function'];
|
||||
if (preg_match('/\\\\?Psy\\\\/', $thing)) {
|
||||
$trace = array_slice($trace, $i + 1);
|
||||
if (\preg_match('/\\\\?Psy\\\\/', $thing)) {
|
||||
$trace = \array_slice($trace, $i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0, $count = min($count, count($trace)); $i < $count; $i++) {
|
||||
for ($i = 0, $count = \min($count, \count($trace)); $i < $count; $i++) {
|
||||
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
|
||||
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
|
||||
$function = $trace[$i]['function'];
|
||||
@@ -126,16 +126,16 @@ HELP
|
||||
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
|
||||
|
||||
// Leave execution loop out of the `eval()'d code` lines
|
||||
if (preg_match("#/src/Execution(?:Loop)?Closure.php\(\d+\) : eval\(\)'d code$#", str_replace('\\', '/', $file))) {
|
||||
if (\preg_match("#/src/Execution(?:Loop)?Closure.php\(\d+\) : eval\(\)'d code$#", \str_replace('\\', '/', $file))) {
|
||||
$file = "eval()'d code";
|
||||
}
|
||||
|
||||
// Skip any lines that don't match our filter options
|
||||
if (!$this->filter->match(sprintf('%s%s%s() at %s:%s', $class, $type, $function, $file, $line))) {
|
||||
if (!$this->filter->match(\sprintf('%s%s%s() at %s:%s', $class, $type, $function, $file, $line))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$lines[] = sprintf(
|
||||
$lines[] = \sprintf(
|
||||
' <class>%s</class>%s%s() at <info>%s:%s</info>',
|
||||
OutputFormatter::escape($class),
|
||||
OutputFormatter::escape($type),
|
||||
@@ -161,7 +161,7 @@ HELP
|
||||
if ($cwd === false) {
|
||||
return $file;
|
||||
} else {
|
||||
return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file);
|
||||
return \preg_replace('/^' . \preg_quote($cwd, '/') . '/', '', $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
vendor/psy/psysh/src/Command/WhereamiCommand.php
vendored
24
vendor/psy/psysh/src/Command/WhereamiCommand.php
vendored
@@ -33,7 +33,7 @@ class WhereamiCommand extends Command
|
||||
public function __construct($colorMode = null)
|
||||
{
|
||||
$this->colorMode = $colorMode ?: Configuration::COLOR_MODE_AUTO;
|
||||
$this->backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
$this->backtrace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -69,13 +69,13 @@ HELP
|
||||
*/
|
||||
protected function trace()
|
||||
{
|
||||
foreach (array_reverse($this->backtrace) as $stackFrame) {
|
||||
foreach (\array_reverse($this->backtrace) as $stackFrame) {
|
||||
if ($this->isDebugCall($stackFrame)) {
|
||||
return $stackFrame;
|
||||
}
|
||||
}
|
||||
|
||||
return end($this->backtrace);
|
||||
return \end($this->backtrace);
|
||||
}
|
||||
|
||||
private static function isDebugCall(array $stackFrame)
|
||||
@@ -84,7 +84,7 @@ HELP
|
||||
$function = isset($stackFrame['function']) ? $stackFrame['function'] : null;
|
||||
|
||||
return ($class === null && $function === 'Psy\debug') ||
|
||||
($class === 'Psy\Shell' && in_array($function, ['__construct', 'debug']));
|
||||
($class === 'Psy\Shell' && \in_array($function, ['__construct', 'debug']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,8 +95,8 @@ HELP
|
||||
protected function fileInfo()
|
||||
{
|
||||
$stackFrame = $this->trace();
|
||||
if (preg_match('/eval\(/', $stackFrame['file'])) {
|
||||
preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);
|
||||
if (\preg_match('/eval\(/', $stackFrame['file'])) {
|
||||
\preg_match_all('/([^\(]+)\((\d+)/', $stackFrame['file'], $matches);
|
||||
$file = $matches[1][0];
|
||||
$line = (int) $matches[2][0];
|
||||
} else {
|
||||
@@ -104,7 +104,7 @@ HELP
|
||||
$line = $stackFrame['line'];
|
||||
}
|
||||
|
||||
return compact('file', 'line');
|
||||
return \compact('file', 'line');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,11 +117,11 @@ HELP
|
||||
$factory = new ConsoleColorFactory($this->colorMode);
|
||||
$colors = $factory->getConsoleColor();
|
||||
$highlighter = new Highlighter($colors);
|
||||
$contents = file_get_contents($info['file']);
|
||||
$contents = \file_get_contents($info['file']);
|
||||
|
||||
$output->startPaging();
|
||||
$output->writeln('');
|
||||
$output->writeln(sprintf('From <info>%s:%s</info>:', $this->replaceCwd($info['file']), $info['line']));
|
||||
$output->writeln(\sprintf('From <info>%s:%s</info>:', $this->replaceCwd($info['file']), $info['line']));
|
||||
$output->writeln('');
|
||||
$output->write($highlighter->getCodeSnippet($contents, $info['line'], $num, $num), ShellOutput::OUTPUT_RAW);
|
||||
$output->stopPaging();
|
||||
@@ -136,13 +136,13 @@ HELP
|
||||
*/
|
||||
private function replaceCwd($file)
|
||||
{
|
||||
$cwd = getcwd();
|
||||
$cwd = \getcwd();
|
||||
if ($cwd === false) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
$cwd = rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
$cwd = \rtrim($cwd, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||
|
||||
return preg_replace('/^' . preg_quote($cwd, '/') . '/', '', $file);
|
||||
return \preg_replace('/^' . \preg_quote($cwd, '/') . '/', '', $file);
|
||||
}
|
||||
}
|
||||
|
||||
14
vendor/psy/psysh/src/Command/WtfCommand.php
vendored
14
vendor/psy/psysh/src/Command/WtfCommand.php
vendored
@@ -86,26 +86,26 @@ HELP
|
||||
{
|
||||
$this->filter->bind($input);
|
||||
|
||||
$incredulity = implode('', $input->getArgument('incredulity'));
|
||||
if (strlen(preg_replace('/[\\?!]/', '', $incredulity))) {
|
||||
$incredulity = \implode('', $input->getArgument('incredulity'));
|
||||
if (\strlen(\preg_replace('/[\\?!]/', '', $incredulity))) {
|
||||
throw new \InvalidArgumentException('Incredulity must include only "?" and "!"');
|
||||
}
|
||||
|
||||
$exception = $this->context->getLastException();
|
||||
$count = $input->getOption('all') ? PHP_INT_MAX : max(3, pow(2, strlen($incredulity) + 1));
|
||||
$count = $input->getOption('all') ? PHP_INT_MAX : \max(3, \pow(2, \strlen($incredulity) + 1));
|
||||
|
||||
$shell = $this->getApplication();
|
||||
$output->startPaging();
|
||||
do {
|
||||
$traceCount = count($exception->getTrace());
|
||||
$traceCount = \count($exception->getTrace());
|
||||
$showLines = $count;
|
||||
// Show the whole trace if we'd only be hiding a few lines
|
||||
if ($traceCount < max($count * 1.2, $count + 2)) {
|
||||
if ($traceCount < \max($count * 1.2, $count + 2)) {
|
||||
$showLines = PHP_INT_MAX;
|
||||
}
|
||||
|
||||
$trace = $this->getBacktrace($exception, $showLines);
|
||||
$moreLines = $traceCount - count($trace);
|
||||
$moreLines = $traceCount - \count($trace);
|
||||
|
||||
$output->writeln($shell->formatException($exception));
|
||||
$output->writeln('--');
|
||||
@@ -113,7 +113,7 @@ HELP
|
||||
$output->writeln('');
|
||||
|
||||
if ($moreLines > 0) {
|
||||
$output->writeln(sprintf(
|
||||
$output->writeln(\sprintf(
|
||||
'<aside>Use <return>wtf -a</return> to see %d more lines</aside>',
|
||||
$moreLines
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user