In the process of resolving a ticket, Pedro C found this representative line, which has nothing to do with the bug he was fixing, but was just something he couldn’t leave un-fixed:
$categories = (isset($categoryMap[$product['department']]) ?
(isset($categoryMap[$product['department']][$product['classification']])
?
$categoryMap[$product['department']][$product['classification']]
: NULL) : NULL);
Yes, the venerable ternary expression, used once again to obfuscate and confuse.
It took Pedro a few readings before he even understood what it did, and then it took him a few more readings to wonder about why anyone would solve the problem this way. Then, he fixed it.
$department = $product['department'];
$classification = $product['classification'];
$categories = NULL;
//ED: isset never triggers as error with an undefined expression, but simply returns false, because PHP
if( isset($categoryMap[$department][$classification]) ) {
$categories = $categoryMap[$department][$classification];
}
He submitted the change for code-review, but it was kicked back. You see, Pedro had fixed the bug, which had a ticket associated with it. There were to be no code changes without a ticket from a business user, and since this change wasn’t strictly related to the bug, he couldn’t submit this change.