Dependency Management and WordPress: A Proposal

I came across this article – “Dependency Management and WordPress: A Proposal“, which provides an excellent overview of some of the recent developments and discussions in the area of composer integration with WordPress, and even more generically, some of the issues around dependency management in an ecosystem as large and complex as that of WordPress.

It’s been a while since I checked what’s going on in this area.  A couple of years back, I linked to an article that shows a way to use composer with WordPress, and since then I’ve built something similar for our use at work.

But it’s good to see that the problem is not tossed and forgotten, and that there are some very smart people still trying to work it out.

Payum – PHP 5.5+ payment processing library

Payum – PHP 5.5+ payment processing library, which is self-described as:

It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts etc.

The documentation looks extensive, and the list of supported gateways is probably the longest I’ve seen.

Creating Strictly Typed Arrays and Collections in PHP

This SitePoint PHP blog post (read at Planet PHP if the site is unavailable) brings to light a very useful feature available since PHP 5.6 – ellipses in functional arguments, which allows to define a variable number of arguments to a function.

I’ve seen the mentions of ellipses a few times now, but I assumed that it was a PHP 7 feature.  Turns out PHP 5.6 users can enjoy it as well:

<?php
function sum(...$numbers) {
    $acc = 0;
    foreach ($numbers as $n) {
        $acc += $n; 
    }   
    return $acc;
}
echo sum(1, 2, 3, 4); // prints out 10

This is very useful, but, as SitePoint PHP blog most mentions, it can be made even more useful with type hinting of the arguments.  For example:

<?php 
class Movie { private $dates = [];
    public function setAirDates(\DateTimeImmutable ...$dates) { 
        $this->dates = $dates;
    }   

    public function getAirDates() {
        return $this->dates;
    }   
}

The limitation is that you can only hint a single type for all the arguments. The workaround this is to use collection classes, which basically work as strictly typed arrays.

PHPQA all-in-one Analyzer CLI tool

PHPQA all-in-one Analyzer CLI tool.  This project bundles together all the usual PHP quality control tools, and then some.  It simplifies the installation and configuration of the tools and helps developers to push up the quality control bar on their projects.

The tools currently included are:

php-enqueue – enterprise queue solutions for PHP

php-enqueue – enterprise queue solutions for PHP.  There is a number of GitHub repositories for the project.  PHP Enqueue supports a number of transports – ampq, stomp, filesystem – and it provides a flexible collection of classes to deal both with the queue manager, as well as a client.  If your project needs a message queue, definitely check this one out.