When Daniel was young, he took one of those adventure trips that included a multi-day hike through a rainforest. At the time, it was one of the most difficult and laborious experiences he'd ever had.

Then he inherited an antique PHP 5.3 application, written by someone who names variables like they're spreadsheet columns: $ag, $ah, and $az are all variables which show up. Half of those are globals. The application is "modularized" into many, many PHP files, but this ends up creating include chains tens of files deep, which makes it nigh impossible to actually understand.

But then there are lines like this one:

drdtoarr() { global $arr; return $arr; }

This function uses a global $arr variable and… returns it. That's it, that's the function. This function is used everywhere, especially the variable $arr, which is one of the most popular globals in the application. There is no indication anywhere in the code about what drd stands for, what it's supposed to mean, or why it sometimes maybe is stored in $arr.

While this function seems useless, I'd argue that it has a vague, if limited point. $arr is a global variable that might be storing wildly different things during the lifecycle of the application. drdtoarr at least tells us that we expect to see drd in there.

Now, if only something would tell us what drd actually means, we'd be on our way.

[Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.