Skip to content

Replacing $this with $block in templates is not universally safe / correct #407

Open
@fredden

Description

@fredden

Preconditions

  1. In a template (.phtml file), make use of $this->helper(SomeClass:class);. For example, https://github.com/magento/magento2/blob/2.4.4/app/code/Magento/Catalog/view/frontend/templates/product/listing.phtml#L20
  2. Magento Coding Standard version 25

Steps to reproduce

  1. Run phpcbf --standard=Magento2 on template

Expected result

  1. Template works the same as before auto-fixes are applied.

Actual result

  1. Exception is throw: Invalid method Vendor\Module\Block\SomeBlockClass\Interceptor::helper

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy