Tyranron Tyranron - 1 month ago 11
PHP Question

What is idiomatic way to clear whole cache in Twig since 1.22.x?

Since

1.22.0
version of
Twig
, method
Twig_Environment::clearCacheFiles()
is deprecated. However, I didn't found anywhere (nor in documentation, nor in repo tickets, nor here on SO) something which can replace this deprecated method.

So what is the idiomatic (and not deprecated) way to clear all cache files now?

Clearing those files via implementing own function seems to be pretty weird.

Answer

So there is no new idiomatic way to clear all cache files.
Twig project maintainers leave it for library users on their own. The arguments are:

The argument was that Twig itself will only support filesystem cache (due to opcache). Thus clear() would be the same as removing the cache folder manually. Thus it doesn't need to be in the interface. So you have to clear your cache either manually or write the method yourself.

More details may be read in relevant issue early referred by @alain-tiemblo in comments.