magento / magento/magento-coding-standard

False positive Magento2.Legacy.ObsoleteResponse

Open
#352 1 comment 0 reactions 0 assignees View on GitHub
bug Progress: ready for grooming
Dominant language
PHP
Stars
375
Forks
165
PR merge metrics
No merged PRs in 30d

Description

### 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](https://github.com/magento/magento-coding-standard/blob/v16/Magento2/Sniffs/Legacy/ObsoleteResponseSniff.php#L18-L29)
```
renderLayout === null) {
$a = 1;
}
if ($this->_redirect === null) {
$b = 2;
}
}
}

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

Contributor guide

Open the contributing guide

Research direction

Start with Magento2/Sniffs/Legacy/ObsoleteResponseSniff.php, especially the methods list linked in the issue, and reproduce the report by running phpcs on the example class. Done means properties named renderLayout or _redirect no longer trigger Magento2.Legacy.ObsoleteResponse, while the issue's expected output remains satisfied.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.