Example (code added 13 years ago):
$saveOrder = $listOrder == 'a.ordering';
This is in many files, and I stumbled upon it as I find is very cryptic to read personally.
According to PSR-12 then
The body of each structure MUST be enclosed by braces. This standardizes how the structures look and reduces the likelihood of introducing errors as new lines get added to the body.
I am just curious if this is considered acceptable in the Joomla code base?
If it should be PRS-12 compatible, then I believe that code should be written more ugly but easier to understand:
$saveOrder = false;
if ($listOrder == 'a.ordering' ) {
$saveOrder = true;
}
Labels |
Added:
No Code Attached Yet
|
Title |
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-03-10 10:14:24 |
Closed_By | ⇒ | aDaneInSpain |
Hi,
If I not mistaken, it a Ternary operator.
$saveOrder = $listOrder == 'a.ordering';
is shorter version of:And the quote you posted about Control structures is about to avoid stuff like: