smarty-php / smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
Other
2.23k stars 703 forks source link

Using unregistered static method in a template is deprecated and will be removed in a future release - deprecation warning #962

Closed stijnster closed 4 months ago

stijnster commented 4 months ago

Hi,

as also mentioned in #958 I too have a question/concern about the deprecation warning below;

Using unregistered static method [redacted] in a template is deprecated and will be removed in a future release. Use Smarty::registerClass to explicitly register a class for access.

This deprecation warning was only added last week (March 18th, 2024 2:44 PM) in preparation of the new 5.0 release, which came out yesterday. The upgrade documentation however does not mention deprecation or other information https://smarty-php.github.io/smarty/stable/upgrading/#namespaces

I also can't find any reasoning as to why this is deprecated. In our case, we abstract complex view logic into so called ViewHelpers or ViewClasses, written in PHP in order to reduce (and reuse) these complex structures.

For now, we have fixed the deprecation warnings, by registering all our classes with static methods (50+ helper classes with static methods).

Although the fix to register the classes currently works, we are concerned that eventually support for static methods on classes might be completely removed. Escpecially as we can't find reasoning for the deprecation or mentions about this in the new 5.0 documentation. Neither do we know if there is a long term planning for a new feature that will replace this type of functionalty.

So, will support for static methods be continued if they are registered, using Smarty::registerClass or do we need to start perapring for another solution?

wisskid commented 4 months ago

Support for static methods will be continued. Support for calling unregistered static methods from templates will be removed.