plates icon indicating copy to clipboard operation
plates copied to clipboard

Deprecated dynamic property in extensions

Open basteyy opened this issue 2 years ago • 7 comments

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.

basteyy avatar Nov 04 '23 20:11 basteyy

I have created a PR that will address this issue.

dsmithhayes avatar Dec 18 '23 03:12 dsmithhayes

any movement on this?

delboy1978uk avatar May 06 '24 18:05 delboy1978uk

@delboy1978uk No.

dsmithhayes avatar May 07 '24 01:05 dsmithhayes

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

o251298 avatar Jun 18 '24 08:06 o251298

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

ChrisGalliano avatar Jun 18 '24 08:06 ChrisGalliano

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!

delboy1978uk avatar Jun 18 '24 10:06 delboy1978uk