PHP Quality Tools – magic number detector

Got magic numbers in your PHP? Find ’em fast with PHP Magic Number Detector tool.

if ($locationId === 8) {
  // do something awesome
}

probably seems OK to start with, but the next person (including yourself!) coming at this later will wonder what the heck ‘8’ is. And… if you want to search for any other reference to this ‘magic’ location ID… good luck searching your code for the number 8…

Collapsed output in the image below, just to fit it in the picture.

Similar Posts

  • Bad I9 PDF form

    Have been needing to programmatically fill out an I9 PDF, retrieved from gov site. Should be fairly straightforward, right? Well… the field names are… a mess. Field names like topmostSubform[0].Page1[0].U\.S\._Social_Security_Number__Last_4_numbers_[0]topmostSubform[0].Page1[0].expiration_date__if_applicable__mm_dd_yyyy[0] topmostSubform[0].Page2[0].Employers_Business_or_Organization_Address_Street_Number_and_Name[0] and so on make it pretty… not straightforward to create a usable key/value combination to search and replace. But… today, I noticed it got…

  • Four Thousand Weeks

    I’m starting to read “Four Thousand Weeks” from Oliver Burkeman. I initially listened to much of the audio book, then bought a copy (link above to Amazon – no affiliate link). Have not finished yet, but the core message of the book seems to be There’s certainly more to it than this, and again, I’m…

  • k as in knife

    Many moons ago my earlier version of my blog had this list I use when spelling things for people over the phone. I managed to find it at archive.org and thought I’d repost… a as in aisle (or aye) b as in bdellium  c as in czar d as in djibouti e as in eight…

Leave a Reply

Your email address will not be published. Required fields are marked *