2023-05-03 11:06:20 +02:00
== Why is this an issue?
2023-05-12 16:04:03 +02:00
The `elseif` keyword is preferred over the `else if` keywords in PHP due to its consistency with other programming languages.
2021-04-28 16:49:39 +02:00
2023-05-12 16:04:03 +02:00
`elseif` is a single token, making it more efficient for the PHP parser to process. Additionally, using `elseif` encourages developers to follow a unified coding style and maintain a consistent syntax throughout their PHP codebase.
2021-04-28 16:49:39 +02:00
2023-05-12 16:04:03 +02:00
Overall, the use of `elseif` improves code clarity, reduces potential errors, and enhances the overall maintainability of PHP projects.
2021-04-28 16:49:39 +02:00
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2023-05-12 16:04:03 +02:00
[source,php,diff-id=1,diff-type=noncompliant]
2021-04-28 16:49:39 +02:00
----
if ($expr1) {
...
} else if ($expr2) {
...
} else {...}
----
2021-04-28 18:08:03 +02:00
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-04-28 16:49:39 +02:00
2023-05-12 16:04:03 +02:00
[source,php,diff-id=1,diff-type=compliant]
2021-04-28 16:49:39 +02:00
----
if ($expr1) {
...
} elseif ($expr2) {
...
} else {...}
----
2021-04-28 18:08:03 +02:00
2023-05-12 16:04:03 +02:00
== Resources
=== Documentation
* https://www.php.net/manual/de/control-structures.elseif.php[PHP Manual - elseif/else if]
2021-09-20 15:38:42 +02:00
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
2023-05-25 14:18:12 +02:00
=== Message
Replace this "else if" keyword sequence by "elseif" keyword.
2021-09-20 15:38:42 +02:00
endif::env-github,rspecator-view[]