Posts

PHPUnit beyond basics: configuration

If you just got started with PHPUnit, its configuration file may be a bit daunting. Today we’re gonna walk through (what i consider) the ideal config file. If you’re just here to copy paste the config, then you can find it at thebottom 👇.

Feb 19, 2021

Every day design pattern: Builder

Just like the factory pattern, the builder is a creational pattern, meaning it is about how objects are created. But unlike a factory, a builder allows you to build an object in parts. I tend to use it for creating objects that take a configuration.

Feb 12, 2021

Every day design pattern: Factory

The previous two chapter of this blog series were about the decorator and the adapter. These are structural design patterns. Meaning they deal with the structure of a system. They can help with simplifying relationships, and moving responsibilities.

Jan 25, 2021

Every Day Design Pattern: Adapter

This is the second post in a series of design patterns i use (almost) daily. You will find the other posts at the bottom of this article. On wikipedia, the adapter pattern is described like so:

Jan 10, 2021

Every day design pattern: Decorator

This is the first post in a series of design patterns i use (almost) daily. You will find the other posts at the bottom of this article. The Decorator pattern On wikipedia, the decorator pattern is described like so:

Jan 1, 2021

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); }

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.) Typescript adds a lot of new syntax to tha language, which allows for type checking. The transpiler then simply won’t transpile if there are type errors( depending on your configuration). Your code doesn’t do these checks during runtime, so technically you could still create errors by not using the transpiler and writing the JS code directly.

Aug 16, 2019