Skip to content

Deprecated Functionality: Optional parameter $data declared

We’re in the process of upgrading our store from Magento 2.4.2 to 2.4.4 and encountered the error shown in the image below. Please help us fix this issue.

enter image description here

Script in the project folder:

<?php

namespace StripeIntegrationPaymentsBlockCustomer;

use MagentoFrameworkAppFilesystemDirectoryList;
use MagentoFrameworkFilesystem;
use MagentoFrameworkViewElement;
use StripeIntegrationPaymentsHelperLogger;

class Cards extends MagentoFrameworkViewElementTemplate
{
    public function __construct(
        MagentoFrameworkViewElementTemplateContext $context,
        array $data = [],
        StripeIntegrationPaymentsHelperGeneric $helper,
        MagentoPaymentBlockFormCc $ccBlock,
        StripeIntegrationPaymentsModelConfig $config
    ) {
        $this->stripeCustomer = $helper->getCustomerModel();
        $this->helper = $helper;

        $this->ccBlock = $ccBlock;
        $this->config = $config;

        parent::__construct($context, $data);
    }

    public function getCards()
    {
        try
        {
            return $this->stripeCustomer->getCustomerCards();
        }
        catch (Exception $e)
        {
            $this->helper->addError($e->getMessage());
            $this->helper->logError($e->getMessage());
            $this->helper->logError($e->getTraceAsString());
        }
    }

    public function verifyBillingAddress()
    {
        $address = $this->helper->getCustomerDefaultBillingAddress();

        if (!$address || empty($address->getStreet()))
            return false;

        return true;
    }

    public function getCcMonths()
    {
        return $this->ccBlock->getCcMonths();
    }

    public function getCcYears()
    {
        return $this->ccBlock->getCcYears();
    }

    public function cardType($code)
    {
        return $this->helper->cardType($code);
    }
}