function SecurityPolicy::checkPropertyAllowed
Overrides SecurityPolicyInterface::checkPropertyAllowed
File
-
vendor/
twig/ twig/ src/ Sandbox/ SecurityPolicy.php, line 115
Class
- SecurityPolicy
- Represents a security policy which need to be enforced when sandbox mode is enabled.
Namespace
Twig\SandboxCode
public function checkPropertyAllowed($obj, $property) : void {
$allowed = false;
foreach ($this->allowedProperties as $class => $properties) {
if ($obj instanceof $class && \in_array($property, \is_array($properties) ? $properties : [
$properties,
])) {
$allowed = true;
break;
}
}
if (!$allowed) {
$class = \get_class($obj);
throw new SecurityNotAllowedPropertyError(\sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, $class), $class, $property);
}
}