Adding Delegation to PHP

Rube Goldberg Machine

In summary I am proposing the PHP leverage the use statement like the PHP trait does, but with a class modifier to allow for automatic delegation of method calls to contained instances.

Also I am proposing we leverage the disambiguation syntax that is already available for traits, and extend it in a few ways that traits do not address such as:

  1. Use as to allow for renaming from the property names for delegate classes,
  2. Add include or exclude to allow including or excluding specific methods, and
  3. Add use method to allow for including specific methods.

PHP’s Composer is the worst tool, but it is the best we’ve got

Selective focus of person composing on a piano

“Democracy is the worst form of government except for all those other forms that have been tried.” Winston Churchill, plagiarized Composer for PHP is much like democracy, except for there are no others. So I have always hated Composer, for many reasons. And my views on Composer are admittedly in stark contrast with many others …

A better alternative to “return early” – PHP / WordPress edition

Exit sign

Yes, complex conditionals are worse. But there is a third, better way. And no, it does not involve GOTOs. Me This post is about a coding pattern I have never seen used by anyone else for writing guard clauses, especially when those guard clauses are complex. This pattern results in code that is significantly more …

How to explicitly declare that a struct implements an interface in Go

rules to follow

One of the things I love about Go and find to be a strong supporter of serendipitous interface standardization is Go’s implicitly declared interfaces. However, there are times you really, really want to explicitly declare an interface, such as when you have a larger interface and you want your IDE and/or the compiler to tell …