Posts

Replacing private services with mocks during tests

Use a custom services file for your tests, to allow changing dependencies as needed.

Dec 18, 2020

Testing code that generates warnings

Our code base has a lot of code that looks like this: <?php try { $this->doScaryThing(); } catch(Exception $e) { trigger_error("Downgraded: " . get_class($e) . ":" . $e->getMessage(), E_USER_WARNING); } Or sometimes trigger_error is used as a way to log other thigns.

Nov 21, 2019

What is the boy scout rule

Our code base is a lot like a camp site, and we can learn a thing or two from the boy scouts.

Nov 11, 2019

When to add comments

Most code bases have far too much comments, while only a few are really usefull.

Oct 31, 2019

PHP is already strictly typed

PHP is already strictly typed, in the same way that JavaScript is. Not through the language itself, but with the help of tooling. JavaScript achieves this through tools like Typescript. (I use typescript as an example, as that is what i normally use.

Aug 16, 2019

The modern PHP developers toolbox

The tools a modern PHP developer needs to strive.

Apr 26, 2019

What Is Big O
What Is Big O

Big O is used to notate the 'time and space complexity' of algorithms. It provides us with key insights into how fast an algorithm is, without getting bogged down with details.

Feb 12, 2019

Math Is Fun

$\sqrt{x} = \frac{x}{\sqrt{x}}$ Seeing the above equation may look completely logical, or not. When i saw it a few days ago, i thought it was wrong. When i understood that it was correct, i thought it was the most beautiful thing ever.

Feb 6, 2019

Semantic versioning

Chances are, if you are writing software, you have some dependencies on other peoples code. There is no reason to reinvent the wheel, so you use the code someone else wrote. One of your options is to copy paste it, but then you won’t get any updates if they release a new version. This is where dependency managers come into play. With a set of instructions, they retrieve the needed dependencies for you, and allow you to lock into specific versions, and update when you want. Before we head into dependency managers, lets first talk about semantic versioning (semver).

Nov 9, 2018

Add an editorconfig to your project

One of the hardest things to spot during a pr are whitespace issues. Did someone use tabs instead of spaces, trailing whitespace etc. So, why not make it easy on yourself and help any contributors by adding an .editorconfig file that automatcially fixes those things for you.

Aug 17, 2018