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

@@ -101,18 +101,18 @@ class Docblock
protected static function prefixLength(array $lines)
{
// find only lines with interesting things
$lines = array_filter($lines, function ($line) {
return substr($line, strspn($line, "* \t\n\r\0\x0B"));
$lines = \array_filter($lines, function ($line) {
return \substr($line, \strspn($line, "* \t\n\r\0\x0B"));
});
// if we sort the lines, we only have to compare two items
sort($lines);
\sort($lines);
$first = reset($lines);
$last = end($lines);
$first = \reset($lines);
$last = \end($lines);
// find the longest common substring
$count = min(strlen($first), strlen($last));
$count = \min(\strlen($first), \strlen($last));
for ($i = 0; $i < $count; $i++) {
if ($first[$i] !== $last[$i]) {
return $i;
@@ -130,15 +130,15 @@ class Docblock
protected function parseComment($comment)
{
// Strip the opening and closing tags of the docblock
$comment = substr($comment, 3, -2);
$comment = \substr($comment, 3, -2);
// Split into arrays of lines
$comment = array_filter(preg_split('/\r?\n\r?/', $comment));
$comment = \array_filter(\preg_split('/\r?\n\r?/', $comment));
// Trim asterisks and whitespace from the beginning and whitespace from the end of lines
$prefixLength = self::prefixLength($comment);
$comment = array_map(function ($line) use ($prefixLength) {
return rtrim(substr($line, $prefixLength));
$comment = \array_map(function ($line) use ($prefixLength) {
return \rtrim(\substr($line, $prefixLength));
}, $comment);
// Group the lines together by @tags
@@ -157,30 +157,30 @@ class Docblock
// Parse the blocks
foreach ($blocks as $block => $body) {
$body = trim(implode("\n", $body));
$body = \trim(\implode("\n", $body));
if ($block === 0 && !self::isTagged($body)) {
// This is the description block
$this->desc = $body;
} else {
// This block is tagged
$tag = substr(self::strTag($body), 1);
$body = ltrim(substr($body, strlen($tag) + 2));
$tag = \substr(self::strTag($body), 1);
$body = \ltrim(\substr($body, \strlen($tag) + 2));
if (isset(self::$vectors[$tag])) {
// The tagged block is a vector
$count = count(self::$vectors[$tag]);
$count = \count(self::$vectors[$tag]);
if ($body) {
$parts = preg_split('/\s+/', $body, $count);
$parts = \preg_split('/\s+/', $body, $count);
} else {
$parts = [];
}
// Default the trailing values
$parts = array_pad($parts, $count, null);
$parts = \array_pad($parts, $count, null);
// Store as a mapped array
$this->tags[$tag][] = array_combine(self::$vectors[$tag], $parts);
$this->tags[$tag][] = \array_combine(self::$vectors[$tag], $parts);
} else {
// The tagged block is only text
$this->tags[$tag][] = $body;
@@ -198,7 +198,7 @@ class Docblock
*/
public function hasTag($tag)
{
return is_array($this->tags) && array_key_exists($tag, $this->tags);
return \is_array($this->tags) && \array_key_exists($tag, $this->tags);
}
/**
@@ -222,7 +222,7 @@ class Docblock
*/
public static function isTagged($str)
{
return isset($str[1]) && $str[0] === '@' && ctype_alpha($str[1]);
return isset($str[1]) && $str[0] === '@' && !\preg_match('/[^A-Za-z]/', $str[1]);
}
/**
@@ -234,7 +234,7 @@ class Docblock
*/
public static function strTag($str)
{
if (preg_match('/^@[a-z0-9_]+/', $str, $matches)) {
if (\preg_match('/^@[a-z0-9_]+/', $str, $matches)) {
return $matches[0];
}
}

View File

@@ -28,6 +28,6 @@ class Json
{
$opt |= JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
return json_encode($val, $opt);
return \json_encode($val, $opt);
}
}

View File

@@ -44,10 +44,10 @@ class Mirror
*/
public static function get($value, $member = null, $filter = 15)
{
if ($member === null && is_string($value)) {
if (function_exists($value)) {
if ($member === null && \is_string($value)) {
if (\function_exists($value)) {
return new \ReflectionFunction($value);
} elseif (defined($value) || ReflectionConstant_::isMagicConstant($value)) {
} elseif (\defined($value) || ReflectionConstant_::isMagicConstant($value)) {
return new ReflectionConstant_($value);
}
}
@@ -65,10 +65,10 @@ class Mirror
} elseif ($filter & self::STATIC_PROPERTY && $class->hasProperty($member) && $class->getProperty($member)->isStatic()) {
return $class->getProperty($member);
} else {
throw new RuntimeException(sprintf(
throw new RuntimeException(\sprintf(
'Unknown member %s on class %s',
$member,
is_object($value) ? get_class($value) : $value
\is_object($value) ? \get_class($value) : $value
));
}
}
@@ -84,13 +84,13 @@ class Mirror
*/
private static function getClass($value)
{
if (is_object($value)) {
if (\is_object($value)) {
return new \ReflectionObject($value);
}
if (!is_string($value)) {
if (!\is_string($value)) {
throw new \InvalidArgumentException('Mirror expects an object or class');
} elseif (!class_exists($value) && !interface_exists($value) && !trait_exists($value)) {
} elseif (!\class_exists($value) && !\interface_exists($value) && !\trait_exists($value)) {
throw new \InvalidArgumentException('Unknown class or function: ' . $value);
}

View File

@@ -61,9 +61,9 @@ EOS;
*/
public static function unvis($input)
{
$output = preg_replace_callback(self::UNVIS_RX, 'self::unvisReplace', $input);
$output = \preg_replace_callback(self::UNVIS_RX, 'self::unvisReplace', $input);
// other escapes & octal are handled by stripcslashes
return stripcslashes($output);
return \stripcslashes($output);
}
/**
@@ -88,27 +88,27 @@ EOS;
$chr = $match[3];
// unvis S_META1
$cp = 0200;
$cp |= ord($chr);
$cp |= \ord($chr);
return chr($cp);
return \chr($cp);
}
// \M^(.)
if (isset($match[4]) && $match[4] !== '') {
$chr = $match[4];
// unvis S_META | S_CTRL
$cp = 0200;
$cp |= ($chr === '?') ? 0177 : ord($chr) & 037;
$cp |= ($chr === '?') ? 0177 : \ord($chr) & 037;
return chr($cp);
return \chr($cp);
}
// \^(.)
if (isset($match[5]) && $match[5] !== '') {
$chr = $match[5];
// unvis S_CTRL
$cp = 0;
$cp |= ($chr === '?') ? 0177 : ord($chr) & 037;
$cp |= ($chr === '?') ? 0177 : \ord($chr) & 037;
return chr($cp);
return \chr($cp);
}
}
}