fix everything anyway • The code is already terrible, it’s not like a little more bad code will hurt anything • PHP isn’t even a good language to begin with
• Refactoring terrible code is rewarding and a valuable skill • PHP handles most of our traffic and has the biggest impact towards users • PHP makes us money
all GET/POST data • Don’t assume a user who isn’t logged in will not hit your controller action • Don’t assume a user has access to a request • Check function return types and values • If you refactor code, check to make sure all variables you’re using are defined
fix errors • Access requests without POST/GET data and fix any errors • Monitor error logs / errbit and fix any errors or warnings • If you see some bad code, take a minute to fix it, even if you didn’t write it • If you’re not comfortable with PHP, ask someone who is if you have any questions
static functions • Deeply nested methods • Long methods • Long sections of if / else blocks (abstract or fail early) • Complex boolean expressions • Duplicated code • Long function argument list • Functions that return multiple types ( e.g. array or false )
and look out for common errors / mistakes • Be extremely careful with any code involving request touches • Leave the place a little cleaner than you found it • Don’t be afraid to pull code out into smaller single purpose objects (which you can then test) • When in doubt, ask for help