2

I'm new to Magento and working on upgrading an existing project to 2.4.3. When running php -dmemory_limit=5G bin/magento setup:di:compile I'm encountering an error:

Fatal error: Declaration of X\RecurringService\Model\Export\MetadataProvider::getHeaders(Magento\Framework\View\Element\UiComponentInterface $component) must be compatible with Magento\Ui\Model\Export\MetadataProvider::getHeaders(Magento\Framework\View\Element\UiComponentInterface $component): array in /code/X/RecurringService/Model/Export/MetadataProvider.php on line 82

That points to the following:

/**
 * Retrieve Headers row array for Export
 *
 * @param UiComponentInterface $component
 * @return string[]
 */
public function getHeaders(UiComponentInterface $component)
{
    return array(
        'Next Delivery Date',
        'Service?',
        'Diaper#',
        'Wipes',
        'Doublers',
        'Name',
        'Address 1',
        'Address 2',
        'Exchange Notes',
        'Old #s',
        'Action Date',
        'Action Req',
        'Driver Date',
        'Driver Action',
        'Driver',
        'Status'
    );
}

I'm guessing this is the result of something changing in the new version, but can't seem to find any explanation or docs referencing it.

0

1 Answer 1

2

Change your function code with below as your function is not compatible with the Magento's core function. You missed the function as array : array

Then run setup:di:compile command

/**
 * Retrieve Headers row array for Export
 *
 * @param UiComponentInterface $component
 * @return string[]
 */
public function getHeaders(UiComponentInterface $component): array
{
    return array(
        'Next Delivery Date',
        'Service?',
        'Diaper#',
        'Wipes',
        'Doublers',
        'Name',
        'Address 1',
        'Address 2',
        'Exchange Notes',
        'Old #s',
        'Action Date',
        'Action Req',
        'Driver Date',
        'Driver Action',
        'Driver',
        'Status'
    );
}

Hope this will hep you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.