mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-25 20:16:28 +00:00
Replace strtr() by strtolower()
This commit is contained in:
@@ -707,7 +707,7 @@ class ExpressionParser
|
||||
$stream->expect(Token::NAME_TYPE, null, 'Only variables can be assigned to');
|
||||
}
|
||||
$value = $token->getValue();
|
||||
if (\in_array(strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), ['true', 'false', 'none', 'null'])) {
|
||||
if (\in_array(strtolower($value), ['true', 'false', 'none', 'null'])) {
|
||||
throw new SyntaxError(\sprintf('You cannot assign a value to "%s".', $value), $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
$targets[] = new AssignNameExpression($value, $token->getLine());
|
||||
|
||||
@@ -1686,7 +1686,7 @@ final class CoreExtension extends AbstractExtension
|
||||
if (!isset($cache[$class])) {
|
||||
$methods = get_class_methods($object);
|
||||
sort($methods);
|
||||
$lcMethods = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, $methods);
|
||||
$lcMethods = array_map('strtolower', $methods);
|
||||
$classCache = [];
|
||||
foreach ($methods as $i => $method) {
|
||||
$classCache[$method] = $method;
|
||||
@@ -1725,7 +1725,7 @@ final class CoreExtension extends AbstractExtension
|
||||
$call = false;
|
||||
if (isset($cache[$class][$item])) {
|
||||
$method = $cache[$class][$item];
|
||||
} elseif (isset($cache[$class][$lcItem = strtr($item, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')])) {
|
||||
} elseif (isset($cache[$class][$lcItem = strtolower($item)])) {
|
||||
$method = $cache[$class][$lcItem];
|
||||
} elseif (isset($cache[$class]['__call'])) {
|
||||
$method = $item;
|
||||
|
||||
@@ -50,7 +50,7 @@ final class SecurityPolicy implements SecurityPolicyInterface
|
||||
{
|
||||
$this->allowedMethods = [];
|
||||
foreach ($methods as $class => $m) {
|
||||
$this->allowedMethods[$class] = array_map(function ($value) { return strtr($value, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'); }, \is_array($m) ? $m : [$m]);
|
||||
$this->allowedMethods[$class] = array_map('strtolower', \is_array($m) ? $m : [$m]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ final class SecurityPolicy implements SecurityPolicyInterface
|
||||
}
|
||||
|
||||
$allowed = false;
|
||||
$method = strtr($method, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
||||
$method = strtolower($method);
|
||||
foreach ($this->allowedMethods as $class => $methods) {
|
||||
if ($obj instanceof $class && \in_array($method, $methods)) {
|
||||
$allowed = true;
|
||||
|
||||
Reference in New Issue
Block a user