Skip to content

False positive Magento2.Legacy.ObsoleteResponse #352

Open
@DmitryFurs

Description

@DmitryFurs

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.
-----------------------------------------------------------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions