Testing Methods That Make Static Calls

I had trouble testing a particularly painful codebase. It had static calls and implicit dependencies all over the place, to name just a few problems. One of the things that it often did was to call static methods that would increment counters in the database and cache stuff. Example: Record::incrementViews() It was making things difficult. To avoid messing with the…

Read More

Converting a Joined Resultset Into a Hierarchy

I needed nested resultsets in some projects. I’ve seen a lot of StackOverflow chatter which essentially pointed people towards Doctrine or Propel ORMs, which was overkill when you didn’t want mapping or even model classes. I built a very small function that will transform joined results into a hierarchy. This avoids using heavy ORMs if you just…

Read More

Naming functions consistently

I believe that in order to write readable and maintainable code, we must name our functions in a consistent way. What I noticed by reading a lot of code, especially frameworks, is that developers use too many different verbs when naming functions. It’s even worse when the verbs are meaningless, such as handle, execute, do, match,…

Read More

Composer Security Checker

Stefan Priebsch made some very interesting points in his IPC talk about dependencies. Someone in the audience asked how often should we update our dependencies. Stefan recommends not to touch dependencies if everything is working and only monitor for security updates. However, monitoring security updates for a big dependency tree would be tedious. Here comes my…

Read More

Magento 1.9 on PHP7

I tested many applications on PHP7 and only one of them had an issue: Magento 1.9. The issue was very easy to fix. I couldn’t find a way to submit a patch because only Magento 2 was on GitHub, so here’s the patch if you decide to upgrade. File: app/code/core/Mage/Core/Model/Layout.php Inside function getOutput(), change this line:

to this:…

Read More