That initial snippet and it's "Fixed" version I assume is Python... and it's a stunning example of why I consider python's "whitespace is your formatting" to result in difficult to read / uselessly cryptic code. When people point beginners at Python, I genuinely wonder what manner of evil has possessed them.

FFS, I'm an assembly language programmer, and code like that makes me wonder if the people who made these languages failed to grasp why we have high level languages.

That said, most of the article is pretty good, though your do_stuff PHP routine has a ... well. there's a pretty obvious way to make it better. Look at it. Think about it. If you're going to simplify, SIMPLIFY!

function do_stuff() {if (
!is_writable($folder) ||
!($fp = fopen($file_path, 'w')) ||
!($stuff = get_some_stuff()) ||
!fwrite($fp, $stuff)
) return false;
// actually do whatever here} // do_stuff

Though it’s really good to see someone else who isn’t afraid of “evaluation on assignment”… unlike the pedantic “linter” dirtbags who sucker nubes and rubes alike complaining about things like that.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store