Skip to content

[Issue] Declare optional argument after required. #31291

Closed
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #31275: Declare optional argument after required.


Description

This prevents PHP fatal error when a plugin is added to the one of parent classes.

Manual testing scenarios

  1. Create a plugin for \Magento\Framework\View\Element\BlockInterface.
  2. Navigate to Content > Pages.

Plugin example

Open Magento/Cms/etc/di.xml and add the following code:

<type name="Magento\Framework\View\Element\BlockInterface">
    <plugin name="cms_plugin" type="Magento\Cms\Plugin\Block" />
</type>

Create Magento\Cms\Plugin\Block class:

<?php

namespace Magento\Cms\Plugin;

class Block
{
    /**
     * @param mixed $subject
     * @param mixed $result
     * @return mixed
     */
    public function afterToHtml(
        $subject,
        $result
    ) {
        return $result;
    }
}

Actual Result: ✖️ A fatal error will be rendered: 'Error: Cannot instantiate interface Magento\Framework\Data\OptionSourceInterface'Magento\Framework\Data\OptionSourceInterface

Screenshot from 2020-12-16 09-52-15

Expected Result: ✔️ The page is successfully loaded

Screenshot from 2020-12-16 10-36-58

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

Labels

Component: MediaGalleryUiFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions