Error 500: Attempted to load class “Twig_Function” from the global namespace. Did you forget a “use” statement?

During the Pimcore update from older versions to the most recent 10.5 at this time I’ve got the following errpr:

Attempted to load class "Twig_Function" from the global namespace. Did you forget a "use" statement?

To fix it add the following use statement to your class:

use Twig\TwigFunction;

And replace all Twig_Function to TwigFunction in your php class file code.