noiselabs / SmartyBundle

Smarty3 template engine bundle for Symfony
http://smartybundle.readthedocs.io/
GNU Lesser General Public License v3.0
51 stars 36 forks source link

php8 compatibility #77

Closed oldy777 closed 2 years ago

oldy777 commented 2 years ago

I have some "php Deprecated" messages after switching to php 8. All connected with plugins:

PHP Deprecated:  Required parameter $controller follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 87
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 87
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 119
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 85
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 85
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 98
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 98
PHP Deprecated:  Required parameter $template follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 75
PHP Deprecated:  Required parameter $repeat follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 75
PHP Deprecated:  Required parameter $template follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 109
PHP Deprecated:  Required parameter $repeat follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 109

In some cases we don't use all parameters in method.

public function renderBlockAction(array $parameters = array(), $controller, $template, &$repeat)
    {
        // only output on the closing tag
        if (!$repeat) {
            $parameters = array_merge(array(
                'attributes'    => array(),
                'options'       => array()
            ), $parameters);

            return $this->render($controller, $parameters['attributes'], $parameters['options']);
        }
    }

Is there any reason to have $template parameter in this method? Also, I think set $repeat default value as null will be safe.

renderBlockAction(array $parameters = array(), $controller, &$repeat = null)

And I believe, change parameter order will be a good idea. But it will break BC

vitorbrandao commented 2 years ago

Hi @oldy777, thanks for reporting this issue. May I ask which Symfony version you are using?

oldy777 commented 2 years ago

@vitorbrandao symfony 4.4 currently

oldy777 commented 2 years ago

@vitorbrandao tell me pls if I can help

vitorbrandao commented 2 years ago

Thanks for your help. I'm trying to spin up a test stack in order to reproduce this issue. Can you just confirm what is the requirement for SmartyBundle in both composer.json and composer.lock?

oldy777 commented 2 years ago

composer.json "noiselabs/smarty-bundle": "3.0.x-dev"

composer.lock

{
            "name": "noiselabs/smarty-bundle",
            "version": "3.0.x-dev",
            "source": {
                "type": "git",
                "url": "https://github.com/noiselabs/SmartyBundle.git",
                "reference": "0e06859f4df4fa3f7373f187b2bff7b7816a6a02"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/noiselabs/SmartyBundle/zipball/0e06859f4df4fa3f7373f187b2bff7b7816a6a02",
                "reference": "0e06859f4df4fa3f7373f187b2bff7b7816a6a02",
                "shasum": ""
            },
            "require": {
                "ext-intl": "*",
                "ext-simplexml": "*",
                "php": ">=7.0",
                "smarty/smarty": "^3.1.28",
                "symfony/framework-bundle": "^2.8|^3.0|^4.0",
                "symfony/templating": "^2.8|^3.0|^4.0"
            },
            "require-dev": {
                "phpunit/phpunit": ">=5.4,<8",
                "symfony/asset": "^2.8|^3.0|^4.0",
                "symfony/console": "^2.8|^3.0|^4.0",
                "symfony/expression-language": "^2.8|^3.0|^4.0",
                "symfony/security": "^2.8|^3.0|^4.0",
                "symfony/security-acl": "^2.8|^3.0|^4.0",
                "symfony/translation": "^2.8|^3.0|^4.0",
                "symfony/twig-bundle": "^2.8|^3.0|^4.0",
                "symfony/yaml": "^2.8|^3.0|^4.0"
            },
            "type": "symfony-bundle",
            "extra": {
                "branch-alias": {
                    "dev-master": "3.0.x-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "NoiseLabs\\Bundle\\SmartyBundle\\": ""
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "LGPL-3.0"
            ],
            "authors": [
                {
                    "name": "Vítor Brandão",
                    "email": "vitor@noiselabs.io",
                    "homepage": "https://noiselabs.io"
                },
                {
                    "name": "Community contributions",
                    "homepage": "https://github.com/noiselabs/SmartyBundle/contributors"
                }
            ],
            "description": "This Symfony bundle provides integration for the Smarty3 template engine.",
            "homepage": "http://smartybundle.noiselabs.org",
            "keywords": [
                "noiselabs",
                "smarty",
                "symfony",
                "templating"
            ],
            "support": {
                "docs": "https://smartybundle.readthedocs.io/en/latest/",
                "forum": "https://gitter.im/noiselabs/SmartyBundle",
                "irc": "irc://irc.freenode.org/noiselabs",
                "issues": "https://github.com/noiselabs/SmartyBundle/issues",
                "source": "https://github.com/noiselabs/SmartyBundle/tree/3.0"
            },
            "time": "2019-08-08T16:47:23+00:00"
        },
vitorbrandao commented 2 years ago

Hello @oldy777. I've been working on a new release and I'm currently testing with Symfony 4, PHP 7 and PHP 8. All of these changes are now in the master branch. Do you mind giving these changes a try by updating your composer.json to use dev-master or 4.0.x-dev. Thank you!

oldy777 commented 2 years ago

@vitorbrandao Hi! I tested it on the stage server, everything seems to be working well. Next week I will try it on prod