2019-Jun-27: What’s in a Name?

<– Back to all “Work Diary” entries

Sometimes, I really do miss the “batteries included” aspect of RoR. It definitely does prevent the type of issue that bit me this morning when working in Symfony PHP.

At the top of the service class I was creating, I added a directive like:

use App\Main\Statements\SelectFooByBar;

There are a ton of other use statements like this scattered around the app, so I figured all good. Only, when I went to test my work, PHP kept complaining:

Class 'App\Main\Statements\SelectFooByBar' not found

What the heck?? Dutifully, I:

  • Inspect the filesystem…the file is there ✔️
  • Inspect file permissions and ownership…same as all other app files ✔️
  • Check the spelling of the class and file…yep, they match 100% ✔️
  • Try adding a syntax error to the file…hmmm PHP doesn’t complain about it 🤔

This is when I try the handy class_exists PHP function and try testing my statement class vs. other classes I know are working, but this doesn’t tell me anything that I don’t already know.

At this point, I’m thinking gremlins or something. Browsing directories in vifm, I suddenly notice the spelling of the directory my statement class lives in. It’s statement, not statements

I thought I’d copied/pasted this from a functional use directive, but either a) I didn’t, or b) I did and added the extra “s”. Either way, I changed the spelling in the use directive and all was well. 🌇

Key Takeaways

  • I’d often really really like it to be gremlins, but it’s just not. PEBCAK as they say 🤓
  • When debugging a line of code, carefully look at all aspects of the line. Don’t assume there’s not a typo lurking in there somewhere.
  • Make sure your tools are up to the task. It might be time to explore expanding my vim setup. This is the second bug in as many weeks that a full-fledged IDE would have prevented. I have a very productive code writing environment, but I’m finding my setup is lacking on the debugging side of things.

<– Back to all “Work Diary” entries