Traits with interfaces

In PHP, Traits can't implement interfaces. They can, however, include abstract methods. These methods then need to be implemented by the concrete class that implements the trait. This allows a trait to provide some boilerplate implementation that depends on an concrete implementation. This isn't always a good idea (it's verging on violating the Dependency Inversion Principle but it's better than a trait attempting to use a method that has no contract.

»
Author's profile picture Dave Hulbert on design and php

Thoughts on PSR-7

PSR-7 contains interfaces for HTTP messages. These are like Symfony Kernel's Request and Response interfaces. Having these new interfaces would be great for the PHP community but there's a couple of issues with their current state that I'm not happy with.

»
Author's profile picture Dave Hulbert on design and php

Singletons: bad. Shared resources in a DIC: good.

Singletons

»
Author's profile picture Dave Hulbert on design, php, and solid

Should I use global variables?

Someone posted a question about using global variables on r/php, which I answered. Copied here for posterity.

»
Author's profile picture Dave Hulbert on design, php, and solid

Notes on designing through mocking

My notes on Everzet's talk "Design how your objects talk through mocking" at PHPNW14

»
Author's profile picture Dave Hulbert on design and php