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

  • CyclopsMonitor

    I’ve been posting more about this new service over on linkedin, but haven’t posted much here. CyclopsMonitor is a web monitoring service – checking if a web address is up, how fast it responds, if specific content is available, when SSL/TLS certs expire, when domain name expires, and… sending you notifications when problems occur. Currently,…

  • 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…

  • chunked file uploads with plupload

    Holy tamole… Have been wrestling with a client project using ‘plupload’ with a user base consistently uploading files from 150-500meg on a daily basis. They’d been uploading to youtube/vimeo mostly, because the experience with the older uploader (still plupload earlier version) was bad – slow, mostly, but some issues about determining whether items were uploaded/processed…

Leave a Reply

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