== How to fix it in Symfony

=== Code examples

include::../../common/fix/code-rationale.adoc[]

==== Noncompliant code example

[source,php,diff-id=21,diff-type=noncompliant]
----
function route(): RedirectResponse {
    $route = $request->get('route');
    return $this->redirect($route); // Noncompliant
}
----

==== Compliant solution

[source,php,diff-id=21,diff-type=compliant]
----
function route(): RedirectResponse {
    $route = $request->get('route');
    return $this->redirectToRoute($route, [], 301);
}
----

include::../../common/fix/how-does-this-work.adoc[]

=== Pitfalls

include::../../common/pitfalls/starts-with.adoc[]
