Skip to content

Intercepted methods returning self are generated with incompatible signature #23084

@sshymko

Description

@sshymko

Preconditions (*)

  • Magento 2.3.1
  • Class with pluginized method returning self

Steps to reproduce (*)

  1. Extend any class with intercepted methods returning self, for example:
    magento2_catalog_indexer_full
    namespace Example\Module\Catalog\Model\Indexer\Category\Product\Action;
    
    class Full extends \Magento\Catalog\Model\Indexer\Category\Product\Action\Full
    {
    
    }
  2. Generate interceptors by compiling DI:
    php bin/magento setup:di:compile
  3. Locate generated interceptors for descendant classes:
    generated/code/Example/Module/Model/Indexer/Category/Product/Action/Full/Interceptor.php
    

Expected result (*)

  1. DI compilation completes successfully
  2. Generated interceptor classes are compatible with classes they inherit/intercept

Actual result (*)

  1. Return type of the intercepted method is incompatible with the parent:
    magento2_catalog_indexer_child_interceptor
  2. PHP Fatal error upon any attempt to use the intercepted descendant class

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions