Turns status code numbers to constants
use Symfony\Component\HttpFoundation\Response;
class SomeController
{
public function index()
{
$response = new Response();
- $response->setStatusCode(200);
+ $response->setStatusCode(Response::HTTP_OK);
- if ($response->getStatusCode() === 200) {
+ if ($response->getStatusCode() === Response::HTTP_OK) {
}
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\Symfony\CodeQuality\Rector\BinaryOp\ResponseStatusCodeRector;
return RectorConfig::configure()
->withRules([
ResponseStatusCodeRector::class,
]);