Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too few arguments to function IconRendererPlugin::beforeRenderAsSvg #29

Open
hostep opened this issue Feb 25, 2025 · 1 comment
Open

Comments

@hostep
Copy link

hostep commented Feb 25, 2025

When trying to go to the 2nd step of checkout, the following error is being thrown

ArgumentCountError: Too few arguments to function MultiSafepay\HyvaCheckout\Plugin\Checkout\Model\MethodMetaData\IconRendererPlugin::beforeRenderAsSvg(), 2 passed in vendor/magento/framework/Interception/Interceptor.php on line 121 and exactly 3 expected in vendor/multisafepay/magento2-hyva-checkout/Plugin/Checkout/Model/MethodMetaData/IconRendererPlugin.php

Issue can be explained because the method arguments weren't taken over exactly as they are in Hyvä Checkout: https://gitlab.hyva.io/hyva-checkout/checkout/-/blob/main/src/Model/MethodMetaData/IconRenderer.php?ref_type=heads#L62, and if you call renderAsSvg with one argument, then the code will crash.

This change fixes it:

diff --git a/Plugin/Checkout/Model/MethodMetaData/IconRendererPlugin.php b/Plugin/Checkout/Model/MethodMetaData/IconRendererPlugin.php
index 860eb1b..7153cd0 100644
--- a/Plugin/Checkout/Model/MethodMetaData/IconRendererPlugin.php
+++ b/Plugin/Checkout/Model/MethodMetaData/IconRendererPlugin.php
@@ -43,7 +43,7 @@ class IconRendererPlugin
      * @return array
      * @SuppressWarnings(PHPMD.UnusedFormalParameter)
      */
-    public function beforeRenderAsSvg(IconRenderer $subject, string $path, array $attributes): array
+    public function beforeRenderAsSvg(IconRenderer $subject, string $path, array $attributes = []): array
     {
         if ($path !== 'multisafepay/multisafepay_creditcard_default') {
             return [$path, $attributes];
@vinodsowdagar
Copy link
Member

Hi @hostep ,

Thanks for the feedback! We'll look into it and add the change as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants