ALPHA 3.0.2a

This commit is contained in:
TheGamecraft
2018-09-10 08:51:18 -04:00
parent 7fe13ae0a7
commit 0e0ef86b71
1404 changed files with 10604 additions and 33714 deletions

View File

@@ -38,11 +38,11 @@ class CodeFormatter implements Formatter
$colorMode = $colorMode ?: Configuration::COLOR_MODE_AUTO;
if ($fileName = $reflector->getFileName()) {
if (!is_file($fileName)) {
if (!\is_file($fileName)) {
throw new RuntimeException('Source code unavailable');
}
$file = file_get_contents($fileName);
$file = \file_get_contents($fileName);
$start = $reflector->getStartLine();
$end = $reflector->getEndLine() - $start;

View File

@@ -45,20 +45,20 @@ class DocblockFormatter implements Formatter
if (!empty($docblock->tags)) {
foreach ($docblock::$vectors as $name => $vector) {
if (isset($docblock->tags[$name])) {
$chunks[] = sprintf('<comment>%s:</comment>', self::inflect($name));
$chunks[] = \sprintf('<comment>%s:</comment>', self::inflect($name));
$chunks[] = self::formatVector($vector, $docblock->tags[$name]);
$chunks[] = '';
}
}
$tags = self::formatTags(array_keys($docblock::$vectors), $docblock->tags);
$tags = self::formatTags(\array_keys($docblock::$vectors), $docblock->tags);
if (!empty($tags)) {
$chunks[] = $tags;
$chunks[] = '';
}
}
return rtrim(implode("\n", $chunks));
return \rtrim(\implode("\n", $chunks));
}
/**
@@ -78,7 +78,7 @@ class DocblockFormatter implements Formatter
$max = 0;
foreach ($lines as $line) {
$chunk = $line[$type];
$cur = empty($chunk) ? 0 : strlen($chunk) + 1;
$cur = empty($chunk) ? 0 : \strlen($chunk) + 1;
if ($cur > $max) {
$max = $cur;
}
@@ -86,12 +86,12 @@ class DocblockFormatter implements Formatter
$template[] = self::getVectorParamTemplate($type, $max);
}
$template = implode(' ', $template);
$template = \implode(' ', $template);
return implode("\n", array_map(function ($line) use ($template) {
$escaped = array_map(['Symfony\Component\Console\Formatter\OutputFormatter', 'escape'], $line);
return \implode("\n", \array_map(function ($line) use ($template) {
$escaped = \array_map(['Symfony\Component\Console\Formatter\OutputFormatter', 'escape'], $line);
return rtrim(vsprintf($template, $escaped));
return \rtrim(\vsprintf($template, $escaped));
}, $lines));
}
@@ -108,18 +108,18 @@ class DocblockFormatter implements Formatter
$chunks = [];
foreach ($tags as $name => $values) {
if (in_array($name, $skip)) {
if (\in_array($name, $skip)) {
continue;
}
foreach ($values as $value) {
$chunks[] = sprintf('<comment>%s%s</comment> %s', self::inflect($name), empty($value) ? '' : ':', OutputFormatter::escape($value));
$chunks[] = \sprintf('<comment>%s%s</comment> %s', self::inflect($name), empty($value) ? '' : ':', OutputFormatter::escape($value));
}
$chunks[] = '';
}
return implode("\n", $chunks);
return \implode("\n", $chunks);
}
/**
@@ -133,10 +133,10 @@ class DocblockFormatter implements Formatter
private static function getVectorParamTemplate($type, $max)
{
if (!isset(self::$vectorParamTemplates[$type])) {
return sprintf('%%-%ds', $max);
return \sprintf('%%-%ds', $max);
}
return sprintf('<%s>%%-%ds</%s>', self::$vectorParamTemplates[$type], $max, self::$vectorParamTemplates[$type]);
return \sprintf('<%s>%%-%ds</%s>', self::$vectorParamTemplates[$type], $max, self::$vectorParamTemplates[$type]);
}
/**
@@ -149,7 +149,7 @@ class DocblockFormatter implements Formatter
*/
private static function indent($text, $indent = ' ')
{
return $indent . str_replace("\n", "\n" . $indent, $text);
return $indent . \str_replace("\n", "\n" . $indent, $text);
}
/**
@@ -161,8 +161,8 @@ class DocblockFormatter implements Formatter
*/
private static function inflect($text)
{
$words = trim(preg_replace('/[\s_-]+/', ' ', preg_replace('/([a-z])([A-Z])/', '$1 $2', $text)));
$words = \trim(\preg_replace('/[\s_-]+/', ' ', \preg_replace('/([a-z])([A-Z])/', '$1 $2', $text)));
return implode(' ', array_map('ucfirst', explode(' ', $words)));
return \implode(' ', \array_map('ucfirst', \explode(' ', $words)));
}
}

View File

@@ -56,7 +56,7 @@ class SignatureFormatter implements Formatter
return self::formatConstant($reflector);
default:
throw new \InvalidArgumentException('Unexpected Reflector class: ' . get_class($reflector));
throw new \InvalidArgumentException('Unexpected Reflector class: ' . \get_class($reflector));
}
}
@@ -84,13 +84,13 @@ class SignatureFormatter implements Formatter
if ($reflector instanceof \ReflectionClass && $reflector->isTrait()) {
// For some reason, PHP 5.x returns `abstract public` modifiers for
// traits. Let's just ignore that business entirely.
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
if (\version_compare(PHP_VERSION, '7.0.0', '<')) {
return [];
}
}
return implode(' ', array_map(function ($modifier) {
return sprintf('<keyword>%s</keyword>', $modifier);
return \implode(' ', \array_map(function ($modifier) {
return \sprintf('<keyword>%s</keyword>', $modifier);
}, \Reflection::getModifierNames($reflector->getModifiers())));
}
@@ -115,24 +115,24 @@ class SignatureFormatter implements Formatter
$chunks[] = $reflector->isInterface() ? 'interface' : 'class';
}
$chunks[] = sprintf('<class>%s</class>', self::formatName($reflector));
$chunks[] = \sprintf('<class>%s</class>', self::formatName($reflector));
if ($parent = $reflector->getParentClass()) {
$chunks[] = 'extends';
$chunks[] = sprintf('<class>%s</class>', $parent->getName());
$chunks[] = \sprintf('<class>%s</class>', $parent->getName());
}
$interfaces = $reflector->getInterfaceNames();
if (!empty($interfaces)) {
sort($interfaces);
\sort($interfaces);
$chunks[] = 'implements';
$chunks[] = implode(', ', array_map(function ($name) {
return sprintf('<class>%s</class>', $name);
$chunks[] = \implode(', ', \array_map(function ($name) {
return \sprintf('<class>%s</class>', $name);
}, $interfaces));
}
return implode(' ', $chunks);
return \implode(' ', $chunks);
}
/**
@@ -147,7 +147,7 @@ class SignatureFormatter implements Formatter
$value = $reflector->getValue();
$style = self::getTypeStyle($value);
return sprintf(
return \sprintf(
'<keyword>const</keyword> <const>%s</const> = <%s>%s</%s>',
self::formatName($reflector),
$style,
@@ -168,7 +168,7 @@ class SignatureFormatter implements Formatter
$value = $reflector->getValue();
$style = self::getTypeStyle($value);
return sprintf(
return \sprintf(
'<keyword>define</keyword>(<string>%s</string>, <%s>%s</%s>)',
OutputFormatter::escape(Json::encode($reflector->getName())),
$style,
@@ -186,11 +186,11 @@ class SignatureFormatter implements Formatter
*/
private static function getTypeStyle($value)
{
if (is_int($value) || is_float($value)) {
if (\is_int($value) || \is_float($value)) {
return 'number';
} elseif (is_string($value)) {
} elseif (\is_string($value)) {
return 'string';
} elseif (is_bool($value) || is_null($value)) {
} elseif (\is_bool($value) || \is_null($value)) {
return 'bool';
} else {
return 'strong'; // @codeCoverageIgnore
@@ -206,7 +206,7 @@ class SignatureFormatter implements Formatter
*/
private static function formatProperty(\ReflectionProperty $reflector)
{
return sprintf(
return \sprintf(
'%s <strong>$%s</strong>',
self::formatModifiers($reflector),
$reflector->getName()
@@ -222,11 +222,11 @@ class SignatureFormatter implements Formatter
*/
private static function formatFunction(\ReflectionFunctionAbstract $reflector)
{
return sprintf(
return \sprintf(
'<keyword>function</keyword> %s<function>%s</function>(%s)',
$reflector->returnsReference() ? '&' : '',
self::formatName($reflector),
implode(', ', self::formatFunctionParams($reflector))
\implode(', ', self::formatFunctionParams($reflector))
);
}
@@ -239,7 +239,7 @@ class SignatureFormatter implements Formatter
*/
private static function formatMethod(\ReflectionMethod $reflector)
{
return sprintf(
return \sprintf(
'%s %s',
self::formatModifiers($reflector),
self::formatFunction($reflector)
@@ -262,7 +262,7 @@ class SignatureFormatter implements Formatter
if ($param->isArray()) {
$hint = '<keyword>array</keyword> ';
} elseif ($class = $param->getClass()) {
$hint = sprintf('<class>%s</class> ', $class->getName());
$hint = \sprintf('<class>%s</class> ', $class->getName());
}
} catch (\Exception $e) {
// sometimes we just don't know...
@@ -272,11 +272,11 @@ class SignatureFormatter implements Formatter
// Hax: we'll try to extract it :P
// @codeCoverageIgnoreStart
$chunks = explode('$' . $param->getName(), (string) $param);
$chunks = explode(' ', trim($chunks[0]));
$guess = end($chunks);
$chunks = \explode('$' . $param->getName(), (string) $param);
$chunks = \explode(' ', \trim($chunks[0]));
$guess = \end($chunks);
$hint = sprintf('<urgent>%s</urgent> ', $guess);
$hint = \sprintf('<urgent>%s</urgent> ', $guess);
// @codeCoverageIgnoreEnd
}
@@ -287,14 +287,14 @@ class SignatureFormatter implements Formatter
} else {
$value = $param->getDefaultValue();
$typeStyle = self::getTypeStyle($value);
$value = is_array($value) ? 'array()' : is_null($value) ? 'null' : var_export($value, true);
$value = \is_array($value) ? 'array()' : \is_null($value) ? 'null' : \var_export($value, true);
}
$default = sprintf(' = <%s>%s</%s>', $typeStyle, OutputFormatter::escape($value), $typeStyle);
$default = \sprintf(' = <%s>%s</%s>', $typeStyle, OutputFormatter::escape($value), $typeStyle);
} else {
$default = '';
}
$params[] = sprintf(
$params[] = \sprintf(
'%s%s<strong>$%s</strong>%s',
$param->isPassedByReference() ? '&' : '',
$hint,