magento-coding-standard icon indicating copy to clipboard operation
magento-coding-standard copied to clipboard

False positive Magento2.Legacy.ObsoleteResponse

Open DmitryFurs opened this issue 2 years ago • 1 comments

Preconditions

  1. a class that uses property (not method) _redirect or loadLayout
  2. magento-coding-standard v16

Steps to reproduce

  1. a class that uses properties (not methods) that are listed in the list of methods
<?php

declare(strict_types=1);

namespace Vendor\Module\Model;

class MyModel
{
    /**
     * @var string
     */
    private $renderLayout;

    /**
     * @var string
     */
    private $_redirect;

    /**
     * @return void
     */
    public function test()
    {
        if ($this->renderLayout === null) {
            $a = 1;
        }
        if ($this->_redirect === null) {
            $b = 2;
        }
    }
}

  1. run phpcs

Expected result

  1. No Magento2.Legacy.ObsoleteResponse triggered

Actual result

FILE: /Model/MyModel.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------
 24 | WARNING | renderLayout method is deprecated. Please use \Magento\Framework\Controller\ResultInterface::renderResult instead.
 27 | WARNING | _redirect method is deprecated. Please use \Magento\Backend\Model\View\Result\Redirect::render instead.
-----------------------------------------------------------------------------------------------------------------------------------

DmitryFurs avatar Dec 28 '21 08:12 DmitryFurs

Hi @DmitryFurs. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information.

Add a comment to assign the issue: @magento I am working on this


m2-assistant[bot] avatar Dec 28 '21 08:12 m2-assistant[bot]