mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-24 03:49:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
@@ -38,7 +38,7 @@ class AutoCompleter
|
||||
*/
|
||||
public function activate()
|
||||
{
|
||||
readline_completion_function([&$this, 'callback']);
|
||||
\readline_completion_function([&$this, 'callback']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,27 +56,27 @@ class AutoCompleter
|
||||
// try to work around it.
|
||||
$line = $info['line_buffer'];
|
||||
if (isset($info['end'])) {
|
||||
$line = substr($line, 0, $info['end']);
|
||||
$line = \substr($line, 0, $info['end']);
|
||||
}
|
||||
if ($line === '' && $input !== '') {
|
||||
$line = $input;
|
||||
}
|
||||
|
||||
$tokens = token_get_all('<?php ' . $line);
|
||||
$tokens = \token_get_all('<?php ' . $line);
|
||||
|
||||
// remove whitespaces
|
||||
$tokens = array_filter($tokens, function ($token) {
|
||||
$tokens = \array_filter($tokens, function ($token) {
|
||||
return !AbstractMatcher::tokenIs($token, AbstractMatcher::T_WHITESPACE);
|
||||
});
|
||||
|
||||
$matches = [];
|
||||
foreach ($this->matchers as $matcher) {
|
||||
if ($matcher->hasMatched($tokens)) {
|
||||
$matches = array_merge($matcher->getMatches($tokens), $matches);
|
||||
$matches = \array_merge($matcher->getMatches($tokens), $matches);
|
||||
}
|
||||
}
|
||||
|
||||
$matches = array_unique($matches);
|
||||
$matches = \array_unique($matches);
|
||||
|
||||
return !empty($matches) ? $matches : [''];
|
||||
}
|
||||
@@ -93,7 +93,7 @@ class AutoCompleter
|
||||
*/
|
||||
public function callback($input, $index)
|
||||
{
|
||||
return $this->processCallback($input, $index, readline_info());
|
||||
return $this->processCallback($input, $index, \readline_info());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -103,8 +103,8 @@ class AutoCompleter
|
||||
{
|
||||
// PHP didn't implement the whole readline API when they first switched
|
||||
// to libedit. And they still haven't.
|
||||
if (function_exists('readline_callback_handler_remove')) {
|
||||
readline_callback_handler_remove();
|
||||
if (\function_exists('readline_callback_handler_remove')) {
|
||||
\readline_callback_handler_remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ abstract class AbstractDefaultParametersMatcher extends AbstractContextAwareMatc
|
||||
return [];
|
||||
}
|
||||
|
||||
return [implode(', ', $parametersProcessed) . ')'];
|
||||
return [\implode(', ', $parametersProcessed) . ')'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,8 +50,8 @@ abstract class AbstractDefaultParametersMatcher extends AbstractContextAwareMatc
|
||||
*/
|
||||
private function valueToShortString($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return json_encode($value);
|
||||
if (!\is_array($value)) {
|
||||
return \json_encode($value);
|
||||
}
|
||||
|
||||
$chunks = [];
|
||||
@@ -60,7 +60,7 @@ abstract class AbstractDefaultParametersMatcher extends AbstractContextAwareMatc
|
||||
$allSequential = true;
|
||||
|
||||
foreach ($value as $key => $item) {
|
||||
$allSequential = $allSequential && is_numeric($key) && $key === count($chunksSequential);
|
||||
$allSequential = $allSequential && \is_numeric($key) && $key === \count($chunksSequential);
|
||||
|
||||
$keyString = $this->valueToShortString($key);
|
||||
$itemString = $this->valueToShortString($item);
|
||||
@@ -71,6 +71,6 @@ abstract class AbstractDefaultParametersMatcher extends AbstractContextAwareMatc
|
||||
|
||||
$chunksToImplode = $allSequential ? $chunksSequential : $chunks;
|
||||
|
||||
return '[' . implode(', ', $chunksToImplode) . ']';
|
||||
return '[' . \implode(', ', $chunksToImplode) . ']';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ abstract class AbstractMatcher
|
||||
protected function getInput(array $tokens)
|
||||
{
|
||||
$var = '';
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
$var = $firstToken[1];
|
||||
}
|
||||
@@ -84,7 +84,7 @@ abstract class AbstractMatcher
|
||||
$class = '';
|
||||
while (self::hasToken(
|
||||
[self::T_NS_SEPARATOR, self::T_STRING],
|
||||
$token = array_pop($tokens)
|
||||
$token = \array_pop($tokens)
|
||||
)) {
|
||||
if (self::needCompleteClass($token)) {
|
||||
continue;
|
||||
@@ -116,7 +116,7 @@ abstract class AbstractMatcher
|
||||
*/
|
||||
public static function startsWith($prefix, $word)
|
||||
{
|
||||
return preg_match(sprintf('#^%s#', $prefix), $word);
|
||||
return \preg_match(\sprintf('#^%s#', $prefix), $word);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,13 +129,13 @@ abstract class AbstractMatcher
|
||||
*/
|
||||
public static function hasSyntax($token, $syntax = self::VAR_SYNTAX)
|
||||
{
|
||||
if (!is_array($token)) {
|
||||
if (!\is_array($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$regexp = sprintf('#%s#', $syntax);
|
||||
$regexp = \sprintf('#%s#', $syntax);
|
||||
|
||||
return (bool) preg_match($regexp, $token[1]);
|
||||
return (bool) \preg_match($regexp, $token[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,11 +148,11 @@ abstract class AbstractMatcher
|
||||
*/
|
||||
public static function tokenIs($token, $which)
|
||||
{
|
||||
if (!is_array($token)) {
|
||||
if (!\is_array($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return token_name($token[0]) === $which;
|
||||
return \token_name($token[0]) === $which;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,16 +164,16 @@ abstract class AbstractMatcher
|
||||
*/
|
||||
public static function isOperator($token)
|
||||
{
|
||||
if (!is_string($token)) {
|
||||
if (!\is_string($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return strpos(self::MISC_OPERATORS, $token) !== false;
|
||||
return \strpos(self::MISC_OPERATORS, $token) !== false;
|
||||
}
|
||||
|
||||
public static function needCompleteClass($token)
|
||||
{
|
||||
return in_array($token[1], ['doc', 'ls', 'show']);
|
||||
return \in_array($token[1], ['doc', 'ls', 'show']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,10 +186,10 @@ abstract class AbstractMatcher
|
||||
*/
|
||||
public static function hasToken(array $coll, $token)
|
||||
{
|
||||
if (!is_array($token)) {
|
||||
if (!\is_array($token)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array(token_name($token[0]), $coll);
|
||||
return \in_array(\token_name($token[0]), $coll);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ class ClassAttributesMatcher extends AbstractMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the nekudotayim operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
|
||||
$class = $this->getNamespaceAndClass($tokens);
|
||||
@@ -42,24 +42,24 @@ class ClassAttributesMatcher extends AbstractMatcher
|
||||
return [];
|
||||
}
|
||||
|
||||
$vars = array_merge(
|
||||
array_map(
|
||||
$vars = \array_merge(
|
||||
\array_map(
|
||||
function ($var) {
|
||||
return '$' . $var;
|
||||
},
|
||||
array_keys($reflection->getStaticProperties())
|
||||
\array_keys($reflection->getStaticProperties())
|
||||
),
|
||||
array_keys($reflection->getConstants())
|
||||
\array_keys($reflection->getConstants())
|
||||
);
|
||||
|
||||
return array_map(
|
||||
return \array_map(
|
||||
function ($name) use ($class) {
|
||||
$chunks = explode('\\', $class);
|
||||
$className = array_pop($chunks);
|
||||
$chunks = \explode('\\', $class);
|
||||
$className = \array_pop($chunks);
|
||||
|
||||
return $className . '::' . $name;
|
||||
},
|
||||
array_filter(
|
||||
\array_filter(
|
||||
$vars,
|
||||
function ($var) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $var);
|
||||
@@ -73,8 +73,8 @@ class ClassAttributesMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING):
|
||||
|
||||
@@ -15,9 +15,9 @@ class ClassMethodDefaultParametersMatcher extends AbstractDefaultParametersMatch
|
||||
{
|
||||
public function getMatches(array $tokens, array $info = [])
|
||||
{
|
||||
$openBracket = array_pop($tokens);
|
||||
$functionName = array_pop($tokens);
|
||||
$methodOperator = array_pop($tokens);
|
||||
$openBracket = \array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
$methodOperator = \array_pop($tokens);
|
||||
|
||||
$class = $this->getNamespaceAndClass($tokens);
|
||||
|
||||
@@ -41,19 +41,19 @@ class ClassMethodDefaultParametersMatcher extends AbstractDefaultParametersMatch
|
||||
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$openBracket = array_pop($tokens);
|
||||
$openBracket = \array_pop($tokens);
|
||||
|
||||
if ($openBracket !== '(') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$functionName = array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
|
||||
if (!self::tokenIs($functionName, self::T_STRING)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$operator = array_pop($tokens);
|
||||
$operator = \array_pop($tokens);
|
||||
|
||||
if (!self::tokenIs($operator, self::T_DOUBLE_COLON)) {
|
||||
return false;
|
||||
|
||||
@@ -28,10 +28,10 @@ class ClassMethodsMatcher extends AbstractMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the nekudotayim operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
|
||||
$class = $this->getNamespaceAndClass($tokens);
|
||||
@@ -48,18 +48,18 @@ class ClassMethodsMatcher extends AbstractMatcher
|
||||
$methods = $reflection->getMethods(\ReflectionMethod::IS_STATIC);
|
||||
}
|
||||
|
||||
$methods = array_map(function (\ReflectionMethod $method) {
|
||||
$methods = \array_map(function (\ReflectionMethod $method) {
|
||||
return $method->getName();
|
||||
}, $methods);
|
||||
|
||||
return array_map(
|
||||
return \array_map(
|
||||
function ($name) use ($class) {
|
||||
$chunks = explode('\\', $class);
|
||||
$className = array_pop($chunks);
|
||||
$chunks = \explode('\\', $class);
|
||||
$className = \array_pop($chunks);
|
||||
|
||||
return $className . '::' . $name;
|
||||
},
|
||||
array_filter($methods, function ($method) use ($input) {
|
||||
\array_filter($methods, function ($method) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $method);
|
||||
})
|
||||
);
|
||||
@@ -70,8 +70,8 @@ class ClassMethodsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING):
|
||||
|
||||
@@ -26,21 +26,21 @@ class ClassNamesMatcher extends AbstractMatcher
|
||||
public function getMatches(array $tokens, array $info = [])
|
||||
{
|
||||
$class = $this->getNamespaceAndClass($tokens);
|
||||
if (strlen($class) > 0 && $class[0] === '\\') {
|
||||
$class = substr($class, 1, strlen($class));
|
||||
if (\strlen($class) > 0 && $class[0] === '\\') {
|
||||
$class = \substr($class, 1, \strlen($class));
|
||||
}
|
||||
$quotedClass = preg_quote($class);
|
||||
$quotedClass = \preg_quote($class);
|
||||
|
||||
return array_map(
|
||||
return \array_map(
|
||||
function ($className) use ($class) {
|
||||
// get the number of namespace separators
|
||||
$nsPos = substr_count($class, '\\');
|
||||
$pieces = explode('\\', $className);
|
||||
$nsPos = \substr_count($class, '\\');
|
||||
$pieces = \explode('\\', $className);
|
||||
//$methods = Mirror::get($class);
|
||||
return implode('\\', array_slice($pieces, $nsPos, count($pieces)));
|
||||
return \implode('\\', \array_slice($pieces, $nsPos, \count($pieces)));
|
||||
},
|
||||
array_filter(
|
||||
get_declared_classes(),
|
||||
\array_filter(
|
||||
\get_declared_classes(),
|
||||
function ($className) use ($quotedClass) {
|
||||
return AbstractMatcher::startsWith($quotedClass, $className);
|
||||
}
|
||||
@@ -53,8 +53,8 @@ class ClassNamesMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
$blacklistedTokens = [
|
||||
self::T_INCLUDE, self::T_INCLUDE_ONCE, self::T_REQUIRE, self::T_REQUIRE_ONCE,
|
||||
@@ -63,7 +63,7 @@ class ClassNamesMatcher extends AbstractMatcher
|
||||
switch (true) {
|
||||
case self::hasToken([$blacklistedTokens], $token):
|
||||
case self::hasToken([$blacklistedTokens], $prevToken):
|
||||
case is_string($token) && $token === '$':
|
||||
case \is_string($token) && $token === '$':
|
||||
return false;
|
||||
case self::hasToken([self::T_NEW, self::T_OPEN_TAG, self::T_NS_SEPARATOR, self::T_STRING], $prevToken):
|
||||
case self::hasToken([self::T_NEW, self::T_OPEN_TAG, self::T_NS_SEPARATOR], $token):
|
||||
|
||||
@@ -45,8 +45,8 @@ class CommandsMatcher extends AbstractMatcher
|
||||
{
|
||||
$names = [];
|
||||
foreach ($commands as $command) {
|
||||
$names = array_merge([$command->getName()], $names);
|
||||
$names = array_merge($command->getAliases(), $names);
|
||||
$names = \array_merge([$command->getName()], $names);
|
||||
$names = \array_merge($command->getAliases(), $names);
|
||||
}
|
||||
$this->commands = $names;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ class CommandsMatcher extends AbstractMatcher
|
||||
*/
|
||||
protected function isCommand($name)
|
||||
{
|
||||
return in_array($name, $this->commands);
|
||||
return \in_array($name, $this->commands);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,7 +88,7 @@ class CommandsMatcher extends AbstractMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
return array_filter($this->commands, function ($command) use ($input) {
|
||||
return \array_filter($this->commands, function ($command) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $command);
|
||||
});
|
||||
}
|
||||
@@ -98,8 +98,8 @@ class CommandsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
/* $openTag */ array_shift($tokens);
|
||||
$command = array_shift($tokens);
|
||||
/* $openTag */ \array_shift($tokens);
|
||||
$command = \array_shift($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($command, self::T_STRING) &&
|
||||
|
||||
@@ -27,7 +27,7 @@ class ConstantsMatcher extends AbstractMatcher
|
||||
{
|
||||
$const = $this->getInput($tokens);
|
||||
|
||||
return array_filter(array_keys(get_defined_constants()), function ($constant) use ($const) {
|
||||
return \array_filter(\array_keys(\get_defined_constants()), function ($constant) use ($const) {
|
||||
return AbstractMatcher::startsWith($const, $constant);
|
||||
});
|
||||
}
|
||||
@@ -37,8 +37,8 @@ class ConstantsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($prevToken, self::T_NEW):
|
||||
|
||||
@@ -15,9 +15,9 @@ class FunctionDefaultParametersMatcher extends AbstractDefaultParametersMatcher
|
||||
{
|
||||
public function getMatches(array $tokens, array $info = [])
|
||||
{
|
||||
array_pop($tokens); // open bracket
|
||||
\array_pop($tokens); // open bracket
|
||||
|
||||
$functionName = array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
|
||||
try {
|
||||
$reflection = new \ReflectionFunction($functionName[1]);
|
||||
@@ -32,19 +32,19 @@ class FunctionDefaultParametersMatcher extends AbstractDefaultParametersMatcher
|
||||
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$openBracket = array_pop($tokens);
|
||||
$openBracket = \array_pop($tokens);
|
||||
|
||||
if ($openBracket !== '(') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$functionName = array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
|
||||
if (!self::tokenIs($functionName, self::T_STRING)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!function_exists($functionName[1])) {
|
||||
if (!\function_exists($functionName[1])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ class FunctionsMatcher extends AbstractMatcher
|
||||
{
|
||||
$func = $this->getInput($tokens);
|
||||
|
||||
$functions = get_defined_functions();
|
||||
$allFunctions = array_merge($functions['user'], $functions['internal']);
|
||||
$functions = \get_defined_functions();
|
||||
$allFunctions = \array_merge($functions['user'], $functions['internal']);
|
||||
|
||||
return array_filter($allFunctions, function ($function) use ($func) {
|
||||
return \array_filter($allFunctions, function ($function) use ($func) {
|
||||
return AbstractMatcher::startsWith($func, $function);
|
||||
});
|
||||
}
|
||||
@@ -40,8 +40,8 @@ class FunctionsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($prevToken, self::T_NEW):
|
||||
|
||||
@@ -48,7 +48,7 @@ class KeywordsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function isKeyword($keyword)
|
||||
{
|
||||
return in_array($keyword, $this->keywords);
|
||||
return \in_array($keyword, $this->keywords);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ class KeywordsMatcher extends AbstractMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
return array_filter($this->keywords, function ($keyword) use ($input) {
|
||||
return \array_filter($this->keywords, function ($keyword) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $keyword);
|
||||
});
|
||||
}
|
||||
@@ -68,8 +68,8 @@ class KeywordsMatcher extends AbstractMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::hasToken([self::T_OPEN_TAG, self::T_VARIABLE], $token):
|
||||
|
||||
@@ -27,13 +27,13 @@ class MongoClientMatcher extends AbstractContextAwareMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the object operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
$objectToken = array_pop($tokens);
|
||||
$objectName = str_replace('$', '', $objectToken[1]);
|
||||
$objectToken = \array_pop($tokens);
|
||||
$objectName = \str_replace('$', '', $objectToken[1]);
|
||||
$object = $this->getVariable($objectName);
|
||||
|
||||
if (!$object instanceof \MongoClient) {
|
||||
@@ -42,8 +42,8 @@ class MongoClientMatcher extends AbstractContextAwareMatcher
|
||||
|
||||
$list = $object->listDBs();
|
||||
|
||||
return array_filter(
|
||||
array_map(function ($info) {
|
||||
return \array_filter(
|
||||
\array_map(function ($info) {
|
||||
return $info['name'];
|
||||
}, $list['databases']),
|
||||
function ($var) use ($input) {
|
||||
@@ -57,8 +57,8 @@ class MongoClientMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($token, self::T_OBJECT_OPERATOR):
|
||||
|
||||
@@ -27,20 +27,20 @@ class MongoDatabaseMatcher extends AbstractContextAwareMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the object operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
$objectToken = array_pop($tokens);
|
||||
$objectName = str_replace('$', '', $objectToken[1]);
|
||||
$objectToken = \array_pop($tokens);
|
||||
$objectName = \str_replace('$', '', $objectToken[1]);
|
||||
$object = $this->getVariable($objectName);
|
||||
|
||||
if (!$object instanceof \MongoDB) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_filter(
|
||||
return \array_filter(
|
||||
$object->getCollectionNames(),
|
||||
function ($var) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $var);
|
||||
@@ -53,8 +53,8 @@ class MongoDatabaseMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($token, self::T_OBJECT_OPERATOR):
|
||||
|
||||
@@ -30,16 +30,16 @@ class ObjectAttributesMatcher extends AbstractContextAwareMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the object operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
$objectToken = array_pop($tokens);
|
||||
if (!is_array($objectToken)) {
|
||||
$objectToken = \array_pop($tokens);
|
||||
if (!\is_array($objectToken)) {
|
||||
return [];
|
||||
}
|
||||
$objectName = str_replace('$', '', $objectToken[1]);
|
||||
$objectName = \str_replace('$', '', $objectToken[1]);
|
||||
|
||||
try {
|
||||
$object = $this->getVariable($objectName);
|
||||
@@ -47,12 +47,12 @@ class ObjectAttributesMatcher extends AbstractContextAwareMatcher
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!is_object($object)) {
|
||||
if (!\is_object($object)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_filter(
|
||||
array_keys(get_class_vars(get_class($object))),
|
||||
return \array_filter(
|
||||
\array_keys(\get_class_vars(\get_class($object))),
|
||||
function ($var) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $var);
|
||||
}
|
||||
@@ -64,8 +64,8 @@ class ObjectAttributesMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($token, self::T_OBJECT_OPERATOR):
|
||||
|
||||
@@ -15,16 +15,16 @@ class ObjectMethodDefaultParametersMatcher extends AbstractDefaultParametersMatc
|
||||
{
|
||||
public function getMatches(array $tokens, array $info = [])
|
||||
{
|
||||
$openBracket = array_pop($tokens);
|
||||
$functionName = array_pop($tokens);
|
||||
$methodOperator = array_pop($tokens);
|
||||
$openBracket = \array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
$methodOperator = \array_pop($tokens);
|
||||
|
||||
$objectToken = array_pop($tokens);
|
||||
if (!is_array($objectToken)) {
|
||||
$objectToken = \array_pop($tokens);
|
||||
if (!\is_array($objectToken)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$objectName = str_replace('$', '', $objectToken[1]);
|
||||
$objectName = \str_replace('$', '', $objectToken[1]);
|
||||
|
||||
try {
|
||||
$object = $this->getVariable($objectName);
|
||||
@@ -48,19 +48,19 @@ class ObjectMethodDefaultParametersMatcher extends AbstractDefaultParametersMatc
|
||||
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$openBracket = array_pop($tokens);
|
||||
$openBracket = \array_pop($tokens);
|
||||
|
||||
if ($openBracket !== '(') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$functionName = array_pop($tokens);
|
||||
$functionName = \array_pop($tokens);
|
||||
|
||||
if (!self::tokenIs($functionName, self::T_STRING)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$operator = array_pop($tokens);
|
||||
$operator = \array_pop($tokens);
|
||||
|
||||
if (!self::tokenIs($operator, self::T_OBJECT_OPERATOR)) {
|
||||
return false;
|
||||
|
||||
@@ -30,16 +30,16 @@ class ObjectMethodsMatcher extends AbstractContextAwareMatcher
|
||||
{
|
||||
$input = $this->getInput($tokens);
|
||||
|
||||
$firstToken = array_pop($tokens);
|
||||
$firstToken = \array_pop($tokens);
|
||||
if (self::tokenIs($firstToken, self::T_STRING)) {
|
||||
// second token is the object operator
|
||||
array_pop($tokens);
|
||||
\array_pop($tokens);
|
||||
}
|
||||
$objectToken = array_pop($tokens);
|
||||
if (!is_array($objectToken)) {
|
||||
$objectToken = \array_pop($tokens);
|
||||
if (!\is_array($objectToken)) {
|
||||
return [];
|
||||
}
|
||||
$objectName = str_replace('$', '', $objectToken[1]);
|
||||
$objectName = \str_replace('$', '', $objectToken[1]);
|
||||
|
||||
try {
|
||||
$object = $this->getVariable($objectName);
|
||||
@@ -47,12 +47,12 @@ class ObjectMethodsMatcher extends AbstractContextAwareMatcher
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!is_object($object)) {
|
||||
if (!\is_object($object)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return array_filter(
|
||||
get_class_methods($object),
|
||||
return \array_filter(
|
||||
\get_class_methods($object),
|
||||
function ($var) use ($input) {
|
||||
return AbstractMatcher::startsWith($input, $var) &&
|
||||
// also check that we do not suggest invoking a super method(__construct, __wakeup, …)
|
||||
@@ -66,8 +66,8 @@ class ObjectMethodsMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$prevToken = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
$prevToken = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::tokenIs($token, self::T_OBJECT_OPERATOR):
|
||||
|
||||
@@ -25,9 +25,9 @@ class VariablesMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function getMatches(array $tokens, array $info = [])
|
||||
{
|
||||
$var = str_replace('$', '', $this->getInput($tokens));
|
||||
$var = \str_replace('$', '', $this->getInput($tokens));
|
||||
|
||||
return array_filter(array_keys($this->getVariables()), function ($variable) use ($var) {
|
||||
return \array_filter(\array_keys($this->getVariables()), function ($variable) use ($var) {
|
||||
return AbstractMatcher::startsWith($var, $variable);
|
||||
});
|
||||
}
|
||||
@@ -37,11 +37,11 @@ class VariablesMatcher extends AbstractContextAwareMatcher
|
||||
*/
|
||||
public function hasMatched(array $tokens)
|
||||
{
|
||||
$token = array_pop($tokens);
|
||||
$token = \array_pop($tokens);
|
||||
|
||||
switch (true) {
|
||||
case self::hasToken([self::T_OPEN_TAG, self::T_VARIABLE], $token):
|
||||
case is_string($token) && $token === '$':
|
||||
case \is_string($token) && $token === '$':
|
||||
case self::isOperator($token):
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user