Marco Borgeaud 6550e65756
Diff blocks: fix some incorrect use for php (#2804)
Improvement identified in #2790.

Add a prefix to the diff-id when it is used multiple times in different
"how to fix it in XYZ" sections to avoid ambiguity and pedantically
follow the spec:

> A single and unique diff-id should be used only once for each type of
code example as shown in the description of a rule.

Obvious typos around `diff-type` were fixed.
2023-08-10 15:57:24 +02:00

32 lines
640 B
Plaintext

== 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[]