fixed deprecation warning when using the namespaced class for extensions

This commit is contained in:
Fabien Potencier
2019-03-04 19:02:29 +01:00
parent 04e1634047
commit fb6d12f721
+5 -3
View File
@@ -865,8 +865,9 @@ class Twig_Environment
if (!$extension instanceof InitRuntimeInterface) {
$m = new \ReflectionMethod($extension, 'initRuntime');
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig\Extension\InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
$parentClass = $m->getDeclaringClass()->getName();
if ('Twig_Extension' !== $parentClass && 'Twig\Extension\AbstractExtension' !== $parentClass) {
@trigger_error(sprintf('Defining the initRuntime() method in the "%s" extension is deprecated since version 1.23. Use the `needs_environment` option to get the \Twig_Environment instance in filters, functions, or tests; or explicitly implement Twig\Extension\InitRuntimeInterface if needed (not recommended).', $name), E_USER_DEPRECATED);
}
}
@@ -1503,7 +1504,8 @@ class Twig_Environment
if (!$extension instanceof GlobalsInterface) {
$m = new \ReflectionMethod($extension, 'getGlobals');
if ('Twig_Extension' !== $m->getDeclaringClass()->getName()) {
$parentClass = $m->getDeclaringClass()->getName();
if ('Twig_Extension' !== $parentClass && 'Twig\Extension\AbstractExtension' !== $parentClass) {
@trigger_error(sprintf('Defining the getGlobals() method in the "%s" extension without explicitly implementing Twig\Extension\GlobalsInterface is deprecated since version 1.23.', $name), E_USER_DEPRECATED);
}
}