Bad:
$ymdstr = $moment->format('y-m-d');
Good:
$currentDate = $moment->format('y-m-d');
Both are inferior to "$ymd". Use searchable names
addExpireAt(DateGlobal::SECONDS_IN_A_DAY);
Who would ever need to search for that? You'd search for "Expire". This doesn't preclude from using named constants, but it has nothing to do with search-ability per se. Don't use flags as function parameters
Good:
function createFile($name) { touch($name); }
function createTempFile($name) { touch('./temp/'.$name); }
Now, this is how you create the good old copypasta.What you need instead is a single universal function that does in fact accept a boatload of parameters, but that is never meant to be called directly. You then supplement it with a host of simpler one-liners that fill in most of the parameters with defaults and forward just the select few.
Avoid negative conditionals
should be "Avoid double-negative conditionals". Avoid conditionals
this is just overly broad to the point of being completely pointless. What the example proposes is to use abstraction and inheritance instead. In some cases it helps, but it many it leads to needlessly obscure code that's impossible to read off the page. Use method chaining
Good:
$car = (new Car())
->setColor('pink')
->setMake('Ford')
->setModel('F-150')
->dump();
Except at some point you will need setModel() to fail for some arguments, e.g. setModel('Trabant'), and you will end up with some methods returning $this and some not. This is not going to be a "clean code" by any measure.(edited for clarity a bit)