magento / magento/magento-coding-standard
False positive Magento2.Legacy.ObsoleteResponse
- 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
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