diff --git a/src/ExtensionSet.php b/src/ExtensionSet.php index 7cf7fa7ee..2bd40daf7 100644 --- a/src/ExtensionSet.php +++ b/src/ExtensionSet.php @@ -69,22 +69,12 @@ final class ExtensionSet public function hasExtension(string $class): bool { - $class = ltrim($class, '\\'); - if (!isset($this->extensions[$class]) && class_exists($class, false)) { - // For BC/FC with namespaced aliases - $class = (new \ReflectionClass($class))->name; - } - - return isset($this->extensions[$class]); + return isset($this->extensions[ltrim($class, '\\')]); } public function getExtension(string $class): ExtensionInterface { $class = ltrim($class, '\\'); - if (!isset($this->extensions[$class]) && class_exists($class, false)) { - // For BC/FC with namespaced aliases - $class = (new \ReflectionClass($class))->name; - } if (!isset($this->extensions[$class])) { throw new RuntimeError(sprintf('The "%s" extension is not enabled.', $class)); @@ -149,8 +139,6 @@ final class ExtensionSet throw new \LogicException(sprintf('Unable to register extension "%s" as it is already registered.', $class)); } - // For BC/FC with namespaced aliases - $class = (new \ReflectionClass($class))->name; $this->extensions[$class] = $extension; } diff --git a/src/Node/Expression/CallExpression.php b/src/Node/Expression/CallExpression.php index 455be50c1..8be84cab2 100644 --- a/src/Node/Expression/CallExpression.php +++ b/src/Node/Expression/CallExpression.php @@ -37,8 +37,7 @@ abstract class CallExpression extends AbstractExpression $compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1])); } } elseif ($r instanceof \ReflectionMethod && $callable[0] instanceof ExtensionInterface) { - // For BC/FC with namespaced aliases - $class = (new \ReflectionClass(\get_class($callable[0])))->name; + $class = \get_class($callable[0]); if (!$compiler->getEnvironment()->hasExtension($class)) { // Compile a non-optimized call to trigger a \Twig\Error\RuntimeError, which cannot be a compile-time error $compiler->raw(sprintf('$this->env->getExtension(\'%s\')', $class));