Are there any files to send? That's the question that Chris C's predecessor had. So they asked it. Again. And again. And again.
Chris writes:
I'm occasionally called upon to troubleshoot an ecommerce application that was built in the PHP 5.x days and has been running largely untroubled by maintenance or modernity (aside from the backported security patches to its binaries) ever since.
if(sizeof($files) > 0){
if(sizeof($files) > 0){
foreach($files as $file){
$mime->addAttachment($file);
}
}
}
Indentation as per the original.
If the files array contains items, then if the files array contains items, then we iterate across the files array, which hopefully contains items, and add them as an attachment to an email.
I feel like the way this got indented, the developer responsible knew, deep down, that this was wrong. They lacked the reading comprehension to understand why, but deep down in their spleen, something was screaming at them. And thus those stacked curly brackets at the end there.
Of course, none of the conditionals are needed: a foreach on an empty object just does nothing.