: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
$message = \sprintf('Impossible to access a key ("%s") on a null variable.', $item);
$message = \sprintf('Impossible to access a key ("%s") on a %s variable ("%s").', $item, \gettype($object), $object);
} elseif (null === $object) {
$message = \sprintf('Impossible to access an attribute ("%s") on a null variable.', $item);
$message = \sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s").', $item, \gettype($object), $object);
throw new \WPML\Core\Twig\Error\RuntimeError($message, -1, $this->getSourceContext());
if (!\is_object($object)) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
$message = \sprintf('Impossible to invoke a method ("%s") on a null variable.', $item);
} elseif (\is_array($object)) {
$message = \sprintf('Impossible to invoke a method ("%s") on an array.', $item);
$message = \sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s").', $item, \gettype($object), $object);
throw new \WPML\Core\Twig\Error\RuntimeError($message, -1, $this->getSourceContext());
if (self::METHOD_CALL !== $type && !$object instanceof self) {
// \Twig\Template does not have public properties, and we don't want to allow access to internal ones
if (isset($object->{$item}) || \array_key_exists((string) $item, (array) $object)) {
if ($this->env->hasExtension('WPML\\Core\\Twig\\Extension\\SandboxExtension')) {
$this->env->getExtension('WPML\\Core\\Twig\\Extension\\SandboxExtension')->checkPropertyAllowed($object, $item);
$class = \get_class($object);
if (!isset(self::$cache[$class])) {
// get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
if ($object instanceof self) {
$ref = new \ReflectionClass($class);
foreach ($ref->getMethods(\ReflectionMethod::IS_PUBLIC) as $refMethod) {
// Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
if ('getenvironment' !== \strtolower($refMethod->name)) {
$methods[] = $refMethod->name;
$methods = \get_class_methods($object);
// sort values to have consistent behavior, so that "get" methods win precedence over "is" methods
foreach ($methods as $method) {
$cache[$method] = $method;
$cache[$lcName = \strtolower($method)] = $method;
if ('g' === $lcName[0] && 0 === \strpos($lcName, 'get')) {
$name = \substr($method, 3);
$lcName = \substr($lcName, 3);
} elseif ('i' === $lcName[0] && 0 === \strpos($lcName, 'is')) {
$name = \substr($method, 2);
$lcName = \substr($lcName, 2);
// skip get() and is() methods (in which case, $name is empty)
if (!isset($cache[$name])) {
if (!isset($cache[$lcName])) {
$cache[$lcName] = $method;
self::$cache[$class] = $cache;
if (isset(self::$cache[$class][$item])) {
$method = self::$cache[$class][$item];
} elseif (isset(self::$cache[$class][$lcItem = \strtolower($item)])) {
$method = self::$cache[$class][$lcItem];
} elseif (isset(self::$cache[$class]['__call'])) {
if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
throw new \WPML\Core\Twig\Error\RuntimeError(\sprintf('Neither the property "%1$s" nor one of the methods "%1$s()", "get%1$s()"/"is%1$s()" or "__call()" exist and have public access in class "%2$s".', $item, $class), -1, $this->getSourceContext());
if ($this->env->hasExtension('WPML\\Core\\Twig\\Extension\\SandboxExtension')) {
$this->env->getExtension('WPML\\Core\\Twig\\Extension\\SandboxExtension')->checkMethodAllowed($object, $method);
// Some objects throw exceptions when they have __call, and the method we try
// to call is not supported. If ignoreStrictCheck is true, we should return null.
$ret = $object->{$method}();
$ret = \call_user_func_array([$object, $method], $arguments);
} catch (\BadMethodCallException $e) {
if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
if ($object instanceof \WPML\Core\Twig_TemplateInterface) {
$self = $object->getTemplateName() === $this->getTemplateName();
$message = \sprintf('Calling "%s" on template "%s" from template "%s" is deprecated since version 1.28 and won\'t be supported anymore in 2.0.', $item, $object->getTemplateName(), $this->getTemplateName());
if ('renderBlock' === $method || 'displayBlock' === $method) {
$message .= \sprintf(' Use block("%s"%s) instead).', $arguments[0], $self ? '' : ', template');
} elseif ('hasBlock' === $method) {
$message .= \sprintf(' Use "block("%s"%s) is defined" instead).', $arguments[0], $self ? '' : ', template');
} elseif ('render' === $method || 'display' === $method) {
$message .= \sprintf(' Use include("%s") instead).', $object->getTemplateName());
@\trigger_error($message, \E_USER_DEPRECATED);
return '' === $ret ? '' : new \WPML\Core\Twig\Markup($ret, $this->env->getCharset());
\class_alias('WPML\\Core\\Twig\\Template', 'WPML\\Core\\Twig_Template');