thephpleague / plates

Native PHP template system
https://platesphp.com
MIT License
1.47k stars 180 forks source link

Deprecated dynamic property in extensions #323

Open basteyy opened 12 months ago

basteyy commented 12 months ago

Currently, the ExtensionInterface requires only one method (register). In L102 from Func.php , the script tries to assign the Template $template to the extension's variable $template. If strict mode is enabled, you will receive a Deprecated warning:

Deprecated: Creation of dynamic property SomeExtension::$template is deprecated in /var/www/html/vendor/league/plates/src/Template/Func.php on line 104

This can be fixed by adding the following to the extension:

public Template $template;

A better fix would be:

  1. Create an extendable MasterExtension class with the variable defined within it.
  2. Add a setTemplate method to the ExtensionInterface and allow the user to handle this themselves.
dsmithhayes commented 10 months ago

I have created a PR that will address this issue.

delboy1978uk commented 6 months ago

any movement on this?

dsmithhayes commented 6 months ago

@delboy1978uk No.

o251298 commented 4 months ago

Good day. I would really like to use the library on Php 8.2))

ChrisGalliano commented 4 months ago

  Hi @reinink, do we have any chance to resolve this issue and achieve PHP 8.2 compatibility in the foreseeable future?

delboy1978uk commented 4 months ago

Guys, just add public Template $template; in your extension, it will work in PHP 8.2. Of course it would be better in the plates library itself but you don't need to wait on that!

ragboyjr commented 16 hours ago

https://github.com/thephpleague/plates/pull/329 - this should be fixed here.