mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-06 23:48:50 +00:00
fixed deprecation warning when using the namespaced class for extensions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user