function SecurityPolicy::checkMethodAllowed
Overrides SecurityPolicyInterface::checkMethodAllowed
File
-
vendor/
twig/ twig/ src/ Sandbox/ SecurityPolicy.php, line 94
Class
- SecurityPolicy
- Represents a security policy which need to be enforced when sandbox mode is enabled.
Namespace
Twig\SandboxCode
public function checkMethodAllowed($obj, $method) : void {
if ($obj instanceof Template || $obj instanceof Markup) {
return;
}
$allowed = false;
$method = strtolower($method);
foreach ($this->allowedMethods as $class => $methods) {
if ($obj instanceof $class && \in_array($method, $methods)) {
$allowed = true;
break;
}
}
if (!$allowed) {
$class = \get_class($obj);
throw new SecurityNotAllowedMethodError(\sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, $class), $class, $method);
}
}